You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2015/06/03 19:25:24 UTC

[01/50] [abbrv] qpid-proton git commit: NO-JIRA: Fix uninitialised variable issue (in the case that len=0, on function entry)

Repository: qpid-proton
Updated Branches:
  refs/heads/cjansen-cpp-client ef29b07c3 -> 8074793b8 (forced update)


NO-JIRA: Fix uninitialised variable issue (in the case that len=0, on function entry)


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/fa52f4e7
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/fa52f4e7
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/fa52f4e7

Branch: refs/heads/cjansen-cpp-client
Commit: fa52f4e7110fb7336b03d318b4381ea0a526a507
Parents: 223bbc8
Author: Andrew Stitcher <as...@apache.org>
Authored: Fri May 8 13:42:55 2015 -0400
Committer: Andrew Stitcher <as...@apache.org>
Committed: Fri May 8 13:42:55 2015 -0400

----------------------------------------------------------------------
 proton-c/src/util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/fa52f4e7/proton-c/src/util.c
----------------------------------------------------------------------
diff --git a/proton-c/src/util.c b/proton-c/src/util.c
index 2fe7e95..2b560a6 100644
--- a/proton-c/src/util.c
+++ b/proton-c/src/util.c
@@ -224,7 +224,7 @@ int pn_strcasecmp(const char *a, const char *b)
 
 int pn_strncasecmp(const char* a, const char* b, size_t len)
 {
-  char diff;
+  char diff = 0;
   while (*b && len > 0) {
     diff = tolower(*a++)-tolower(*b++);
     if ( diff!=0 ) return diff;


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


[47/50] [abbrv] qpid-proton git commit: PROTON-865: most of MessagingAdapter in place, SimpleSend/Recv

Posted by ac...@apache.org.
PROTON-865: most of MessagingAdapter in place, SimpleSend/Recv


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/648f7b36
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/648f7b36
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/648f7b36

Branch: refs/heads/cjansen-cpp-client
Commit: 648f7b36caa26e8078b92b50391d2e9f23e16080
Parents: ad7c977
Author: Clifford Jansen <cl...@apache.org>
Authored: Tue May 5 06:48:48 2015 -0700
Committer: Alan Conway <ac...@redhat.com>
Committed: Tue Jun 2 14:46:14 2015 -0400

----------------------------------------------------------------------
 proton-c/bindings/cpp/CMakeLists.txt            |   4 +
 proton-c/bindings/cpp/examples/SimpleRecv.cpp   | 109 +++++++
 proton-c/bindings/cpp/examples/SimpleSend.cpp   | 117 +++++++
 .../bindings/cpp/include/proton/cpp/Container.h |   1 +
 .../bindings/cpp/include/proton/cpp/Message.h   |  23 +-
 .../cpp/include/proton/cpp/MessagingAdapter.h   |  30 +-
 .../cpp/include/proton/cpp/MessagingEvent.h     |  16 +-
 .../cpp/include/proton/cpp/MessagingHandler.h   |  13 +-
 .../bindings/cpp/include/proton/cpp/Session.h   |   8 +-
 proton-c/bindings/cpp/src/Connection.cpp        |   2 +-
 proton-c/bindings/cpp/src/ConnectionImpl.cpp    |  12 +-
 proton-c/bindings/cpp/src/Connector.cpp         |   5 +-
 proton-c/bindings/cpp/src/Container.cpp         |   4 +
 proton-c/bindings/cpp/src/ContainerImpl.cpp     |  87 +++--
 proton-c/bindings/cpp/src/ContainerImpl.h       |   1 +
 proton-c/bindings/cpp/src/Message.cpp           | 194 ++++++++++--
 proton-c/bindings/cpp/src/MessagingAdapter.cpp  | 316 ++++++++++++++++---
 proton-c/bindings/cpp/src/MessagingEvent.cpp    |  31 +-
 proton-c/bindings/cpp/src/MessagingHandler.cpp  |  12 +-
 proton-c/bindings/cpp/src/Session.cpp           |  29 +-
 proton-c/bindings/cpp/src/contexts.cpp          |  47 +--
 proton-c/bindings/cpp/src/contexts.h            |   4 +
 22 files changed, 897 insertions(+), 168 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/648f7b36/proton-c/bindings/cpp/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/CMakeLists.txt b/proton-c/bindings/cpp/CMakeLists.txt
index 7e456a5..68baad7 100644
--- a/proton-c/bindings/cpp/CMakeLists.txt
+++ b/proton-c/bindings/cpp/CMakeLists.txt
@@ -93,6 +93,10 @@ add_executable (HelloWorld examples/HelloWorld.cpp)
 target_link_libraries (HelloWorld qpid-proton-cpp)
 add_executable (HelloWorldDirect examples/HelloWorldDirect.cpp)
 target_link_libraries (HelloWorldDirect qpid-proton-cpp)
+add_executable (SimpleRecv examples/SimpleRecv.cpp)
+target_link_libraries (SimpleRecv qpid-proton-cpp)
+add_executable (SimpleSend examples/SimpleSend.cpp)
+target_link_libraries (SimpleSend qpid-proton-cpp)
 
 install (TARGETS qpid-proton-cpp
   EXPORT  proton

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/648f7b36/proton-c/bindings/cpp/examples/SimpleRecv.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/examples/SimpleRecv.cpp b/proton-c/bindings/cpp/examples/SimpleRecv.cpp
new file mode 100644
index 0000000..22778f0
--- /dev/null
+++ b/proton-c/bindings/cpp/examples/SimpleRecv.cpp
@@ -0,0 +1,109 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "proton/cpp/Container.h"
+#include "proton/cpp/MessagingHandler.h"
+#include "proton/cpp/Link.h"
+
+#include <iostream>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+
+using namespace proton::reactor;
+
+class Recv : public MessagingHandler {
+  private:
+    std::string url;
+    int expected;
+    int received;
+  public:
+
+    Recv(const std::string &s, int c) : url(s), expected(c), received(0) {}
+
+    void onStart(Event &e) {
+        e.getContainer().createReceiver(url);
+    }
+
+    void onMessage(Event &e) {
+        uint64_t id = 0;
+        Message msg = e.getMessage();
+        if (msg.getIdType() == PN_ULONG) {
+            id = msg.getId();
+            if (id < received)
+                return; // ignore duplicate
+        }
+        if (expected == 0 || received < expected) {
+            std::cout << '[' << id << "]: " << msg.getBody() << std::endl;
+            received++;
+            if (received == expected) {
+                e.getReceiver().close();
+                e.getConnection().close();
+            }
+        }
+    }
+};
+
+static void parse_options(int argc, char **argv, int &count, std::string &addr);
+
+int main(int argc, char **argv) {
+    int messageCount = 100;
+    std::string address("localhost:5672/examples");
+    parse_options(argc, argv, messageCount, address);
+    Recv recv(address, messageCount);
+    Container(recv).run();
+}
+
+
+static void usage() {
+    std::cout << "Usage: SimpleRecv -m message_count -a address:" << std::endl;
+    exit (1);
+}
+
+
+static void parse_options(int argc, char **argv, int &count, std::string &addr) {
+    int c, i;
+    for (i = 1; i < argc; i++) {
+        if (strlen(argv[i]) == 2 && argv[i][0] == '-') {
+            c = argv[i][1];
+            const char *nextarg = i < argc ? argv[i+1] : NULL;
+
+            switch (c) {
+            case 'a':
+                if (!nextarg) usage();
+                addr = nextarg;
+                i++;
+                break;
+            case 'm':
+                if (!nextarg) usage();
+                unsigned newc;
+                if (sscanf( nextarg, "%d", &newc) != 1) usage();
+                count = newc;
+                i++;
+                break;
+            default:
+                usage();
+            }
+        }
+        else usage();
+    }
+}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/648f7b36/proton-c/bindings/cpp/examples/SimpleSend.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/examples/SimpleSend.cpp b/proton-c/bindings/cpp/examples/SimpleSend.cpp
new file mode 100644
index 0000000..89ca39d
--- /dev/null
+++ b/proton-c/bindings/cpp/examples/SimpleSend.cpp
@@ -0,0 +1,117 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "proton/cpp/Container.h"
+#include "proton/cpp/MessagingHandler.h"
+#include "proton/cpp/Connection.h"
+
+#include <iostream>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+
+using namespace proton::reactor;
+
+class Send : public MessagingHandler {
+  private:
+    std::string url;
+    int sent;
+    int confirmed;
+    int total;
+  public:
+
+    Send(const std::string &s, int c) : url(s), sent(0), confirmed(0), total(c) {}
+
+    void onStart(Event &e) {
+        e.getContainer().createSender(url);
+    }
+
+    void onSendable(Event &e) {
+        Sender sender = e.getSender();
+        while (sender.getCredit() && sent < total) {
+            Message msg;
+            msg.setId(sent + 1);
+            // TODO: fancy map body content as in Python example.  Simple binary for now.
+            const char *bin = "some arbitrary binary data";
+            msg.setBody(bin, strlen(bin));
+            sender.send(msg);
+            sent++;
+        }
+    }
+
+    void onAccepted(Event &e) {
+        confirmed++;
+        if (confirmed == total) {
+            std::cout << "all messages confirmed" << std::endl;
+            e.getConnection().close();
+        }
+    }
+
+    void onDisconnected(Event &e) {
+        sent = confirmed;
+    }
+};
+
+static void parse_options(int argc, char **argv, int &count, std::string &addr);
+
+int main(int argc, char **argv) {
+    int messageCount = 100;
+    std::string address("localhost:5672/examples");
+    parse_options(argc, argv, messageCount, address);
+    Send send(address, messageCount);
+    Container(send).run();
+}
+
+
+static void usage() {
+    std::cout << "Usage: SimpleSend -m message_count -a address:" << std::endl;
+    exit (1);
+}
+
+
+static void parse_options(int argc, char **argv, int &count, std::string &addr) {
+    int c, i;
+    for (i = 1; i < argc; i++) {
+        if (strlen(argv[i]) == 2 && argv[i][0] == '-') {
+            c = argv[i][1];
+            const char *nextarg = i < argc ? argv[i+1] : NULL;
+
+            switch (c) {
+            case 'a':
+                if (!nextarg) usage();
+                addr = nextarg;
+                i++;
+                break;
+            case 'm':
+                if (!nextarg) usage();
+                unsigned newc;
+                if (sscanf( nextarg, "%d", &newc) != 1) usage();
+                count = newc;
+                i++;
+                break;
+            default:
+                usage();
+            }
+        }
+        else usage();
+    }
+}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/648f7b36/proton-c/bindings/cpp/include/proton/cpp/Container.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Container.h b/proton-c/bindings/cpp/include/proton/cpp/Container.h
index fbb1a83..d596ab1 100644
--- a/proton-c/bindings/cpp/include/proton/cpp/Container.h
+++ b/proton-c/bindings/cpp/include/proton/cpp/Container.h
@@ -56,6 +56,7 @@ class Container : public Handle<ContainerImpl>
     PROTON_CPP_EXTERN Sender createSender(Connection &connection, std::string &addr);
     PROTON_CPP_EXTERN Sender createSender(std::string &url);
     PROTON_CPP_EXTERN Receiver createReceiver(Connection &connection, std::string &addr);
+    PROTON_CPP_EXTERN Receiver createReceiver(const std::string &url);
     PROTON_CPP_EXTERN Acceptor listen(const std::string &url);
     PROTON_CPP_EXTERN std::string getContainerId();
   private:

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/648f7b36/proton-c/bindings/cpp/include/proton/cpp/Message.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Message.h b/proton-c/bindings/cpp/include/proton/cpp/Message.h
index 51ca731..ae29ca2 100644
--- a/proton-c/bindings/cpp/include/proton/cpp/Message.h
+++ b/proton-c/bindings/cpp/include/proton/cpp/Message.h
@@ -22,6 +22,7 @@
  *
  */
 #include "proton/cpp/ImportExport.h"
+#include "proton/cpp/ProtonHandle.h"
 #include "proton/message.h"
 #include <string>
 
@@ -29,22 +30,36 @@
 namespace proton {
 namespace reactor {
 
-class Message
+class Message : public ProtonHandle<pn_message_t>
 {
   public:
     PROTON_CPP_EXTERN Message();
-    PROTON_CPP_EXTERN ~Message();
+    PROTON_CPP_EXTERN Message(pn_message_t *);
     PROTON_CPP_EXTERN Message(const Message&);
     PROTON_CPP_EXTERN Message& operator=(const Message&);
+    PROTON_CPP_EXTERN ~Message();
+
+    PROTON_CPP_EXTERN pn_message_t *getPnMessage() const;
+
+    PROTON_CPP_EXTERN void setId(uint64_t id);
+    PROTON_CPP_EXTERN uint64_t getId();
+    PROTON_CPP_EXTERN pn_type_t getIdType();
 
-    PROTON_CPP_EXTERN pn_message_t *getPnMessage();
     PROTON_CPP_EXTERN void setBody(const std::string &data);
     PROTON_CPP_EXTERN std::string getBody();
+
+    PROTON_CPP_EXTERN void getBody(std::string &str);
+
+    PROTON_CPP_EXTERN void setBody(const char *, size_t len);
+    PROTON_CPP_EXTERN size_t getBody(char *, size_t len);
+    PROTON_CPP_EXTERN size_t getBinaryBodySize();
+
+
     PROTON_CPP_EXTERN void encode(std::string &data);
     PROTON_CPP_EXTERN void decode(const std::string &data);
 
   private:
-    pn_message_t *pnMessage;
+    friend class ProtonImplRef<Message>;
 };
 
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/648f7b36/proton-c/bindings/cpp/include/proton/cpp/MessagingAdapter.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/MessagingAdapter.h b/proton-c/bindings/cpp/include/proton/cpp/MessagingAdapter.h
index 8551c9c..ac8b483 100644
--- a/proton-c/bindings/cpp/include/proton/cpp/MessagingAdapter.h
+++ b/proton-c/bindings/cpp/include/proton/cpp/MessagingAdapter.h
@@ -32,10 +32,10 @@
 namespace proton {
 namespace reactor {
 
-// For now, stands in for Python's: EndpointStateHandler, IncomingMessageHandler, OutgoingMessageHandler
+// Combine's Python's: EndpointStateHandler, IncomingMessageHandler, OutgoingMessageHandler
 
 
-class MessagingAdapter : public ProtonHandler
+class MessagingAdapter : public MessagingHandler
 {
   public:
     PROTON_CPP_EXTERN MessagingAdapter(MessagingHandler &delegate);
@@ -44,11 +44,37 @@ class MessagingAdapter : public ProtonHandler
     PROTON_CPP_EXTERN virtual void onLinkFlow(Event &e);
     PROTON_CPP_EXTERN virtual void onDelivery(Event &e);
     PROTON_CPP_EXTERN virtual void onUnhandled(Event &e);
+    PROTON_CPP_EXTERN virtual void onConnectionClosed(Event &e);
+    PROTON_CPP_EXTERN virtual void onConnectionClosing(Event &e);
+    PROTON_CPP_EXTERN virtual void onConnectionError(Event &e);
+    PROTON_CPP_EXTERN virtual void onConnectionLocalOpen(Event &e);
+    PROTON_CPP_EXTERN virtual void onConnectionRemoteOpen(Event &e);
     PROTON_CPP_EXTERN virtual void onConnectionRemoteClose(Event &e);
+    PROTON_CPP_EXTERN virtual void onConnectionOpened(Event &e);
+    PROTON_CPP_EXTERN virtual void onConnectionOpening(Event &e);
+    PROTON_CPP_EXTERN virtual void onSessionClosed(Event &e);
+    PROTON_CPP_EXTERN virtual void onSessionClosing(Event &e);
+    PROTON_CPP_EXTERN virtual void onSessionError(Event &e);
+    PROTON_CPP_EXTERN virtual void onSessionLocalOpen(Event &e);
+    PROTON_CPP_EXTERN virtual void onSessionRemoteOpen(Event &e);
+    PROTON_CPP_EXTERN virtual void onSessionRemoteClose(Event &e);
+    PROTON_CPP_EXTERN virtual void onSessionOpened(Event &e);
+    PROTON_CPP_EXTERN virtual void onSessionOpening(Event &e);
+    PROTON_CPP_EXTERN virtual void onLinkClosed(Event &e);
+    PROTON_CPP_EXTERN virtual void onLinkClosing(Event &e);
+    PROTON_CPP_EXTERN virtual void onLinkError(Event &e);
+    PROTON_CPP_EXTERN virtual void onLinkLocalOpen(Event &e);
     PROTON_CPP_EXTERN virtual void onLinkRemoteOpen(Event &e);
+    PROTON_CPP_EXTERN virtual void onLinkRemoteClose(Event &e);
+    PROTON_CPP_EXTERN virtual void onLinkOpened(Event &e);
+    PROTON_CPP_EXTERN virtual void onLinkOpening(Event &e);
+    PROTON_CPP_EXTERN virtual void onTransportTailClosed(Event &e);
   private:
     MessagingHandler &delegate;  // The actual MessagingHandler
     pn_handler_t *handshaker;
+    bool autoSettle;
+    bool autoAccept;
+    bool peerCloseIsError;
 };
 
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/648f7b36/proton-c/bindings/cpp/include/proton/cpp/MessagingEvent.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/MessagingEvent.h b/proton-c/bindings/cpp/include/proton/cpp/MessagingEvent.h
index d8d5c7f..de79618 100644
--- a/proton-c/bindings/cpp/include/proton/cpp/MessagingEvent.h
+++ b/proton-c/bindings/cpp/include/proton/cpp/MessagingEvent.h
@@ -37,17 +37,19 @@ typedef enum {
     PN_MESSAGING_ABORT,
     PN_MESSAGING_ACCEPTED,
     PN_MESSAGING_COMMIT,
-    PN_MESSAGING_CONNECTION_CLOSE,
     PN_MESSAGING_CONNECTION_CLOSED,
     PN_MESSAGING_CONNECTION_CLOSING,
-    PN_MESSAGING_CONNECTION_OPEN,
+    PN_MESSAGING_CONNECTION_ERROR,
     PN_MESSAGING_CONNECTION_OPENED,
+    PN_MESSAGING_CONNECTION_OPENING,
     PN_MESSAGING_DISCONNECTED,
     PN_MESSAGING_FETCH,
     PN_MESSAGING_ID_LOADED,
+    PN_MESSAGING_LINK_CLOSED,
     PN_MESSAGING_LINK_CLOSING,
     PN_MESSAGING_LINK_OPENED,
     PN_MESSAGING_LINK_OPENING,
+    PN_MESSAGING_LINK_ERROR,
     PN_MESSAGING_MESSAGE,
     PN_MESSAGING_QUIT,
     PN_MESSAGING_RECORD_INSERTED,
@@ -57,19 +59,25 @@ typedef enum {
     PN_MESSAGING_REQUEST,
     PN_MESSAGING_RESPONSE,
     PN_MESSAGING_SENDABLE,
+    PN_MESSAGING_SESSION_CLOSED,
+    PN_MESSAGING_SESSION_CLOSING,
+    PN_MESSAGING_SESSION_OPENED,
+    PN_MESSAGING_SESSION_OPENING,
+    PN_MESSAGING_SESSION_ERROR,
     PN_MESSAGING_SETTLED,
     PN_MESSAGING_START,
     PN_MESSAGING_TIMER,
     PN_MESSAGING_TRANSACTION_ABORTED,
     PN_MESSAGING_TRANSACTION_COMMITTED,
-    PN_MESSAGING_TRANSACTION_DECLARED
+    PN_MESSAGING_TRANSACTION_DECLARED,
+    PN_MESSAGING_TRANSPORT_CLOSED
 } MessagingEventType_t;
 
 class MessagingEvent : public ProtonEvent
 {
   public:
     MessagingEvent(pn_event_t *ce, pn_event_type_t t, Container &c);
-    MessagingEvent(MessagingEventType_t t, ProtonEvent *parent, Container &c);
+    MessagingEvent(MessagingEventType_t t, ProtonEvent &parent);
     ~MessagingEvent();
     virtual PROTON_CPP_EXTERN void dispatch(Handler &h);
     virtual PROTON_CPP_EXTERN Connection &getConnection();

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/648f7b36/proton-c/bindings/cpp/include/proton/cpp/MessagingHandler.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/MessagingHandler.h b/proton-c/bindings/cpp/include/proton/cpp/MessagingHandler.h
index 875af43..51f679a 100644
--- a/proton-c/bindings/cpp/include/proton/cpp/MessagingHandler.h
+++ b/proton-c/bindings/cpp/include/proton/cpp/MessagingHandler.h
@@ -34,20 +34,23 @@ class PROTON_CPP_EXTERN MessagingHandler : public ProtonHandler
 {
   public:
     PROTON_CPP_EXTERN MessagingHandler();
+//ZZZ    PROTON_CPP_EXTERN MessagingHandler(int prefetch=10, bool autoAccept=true, autoSettle=true, peerCloseIsError=false);
     virtual ~MessagingHandler();
 
     virtual void onAbort(Event &e);
     virtual void onAccepted(Event &e);
     virtual void onCommit(Event &e);
-    virtual void onConnectionClose(Event &e);
     virtual void onConnectionClosed(Event &e);
     virtual void onConnectionClosing(Event &e);
-    virtual void onConnectionOpen(Event &e);
+    virtual void onConnectionError(Event &e);
+    virtual void onConnectionOpening(Event &e);
     virtual void onConnectionOpened(Event &e);
     virtual void onDisconnected(Event &e);
     virtual void onFetch(Event &e);
     virtual void onIdLoaded(Event &e);
+    virtual void onLinkClosed(Event &e);
     virtual void onLinkClosing(Event &e);
+    virtual void onLinkError(Event &e);
     virtual void onLinkOpened(Event &e);
     virtual void onLinkOpening(Event &e);
     virtual void onMessage(Event &e);
@@ -59,12 +62,18 @@ class PROTON_CPP_EXTERN MessagingHandler : public ProtonHandler
     virtual void onRequest(Event &e);
     virtual void onResponse(Event &e);
     virtual void onSendable(Event &e);
+    virtual void onSessionClosed(Event &e);
+    virtual void onSessionClosing(Event &e);
+    virtual void onSessionError(Event &e);
+    virtual void onSessionOpened(Event &e);
+    virtual void onSessionOpening(Event &e);
     virtual void onSettled(Event &e);
     virtual void onStart(Event &e);
     virtual void onTimer(Event &e);
     virtual void onTransactionAborted(Event &e);
     virtual void onTransactionCommitted(Event &e);
     virtual void onTransactionDeclared(Event &e);
+    virtual void onTransportClosed(Event &e);
 };
 
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/648f7b36/proton-c/bindings/cpp/include/proton/cpp/Session.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Session.h b/proton-c/bindings/cpp/include/proton/cpp/Session.h
index e556cde..68f5e40 100644
--- a/proton-c/bindings/cpp/include/proton/cpp/Session.h
+++ b/proton-c/bindings/cpp/include/proton/cpp/Session.h
@@ -27,6 +27,7 @@
 
 #include "proton/types.h"
 #include "proton/link.h"
+#include "ProtonImplRef.h"
 #include <string>
 
 struct pn_connection_t;
@@ -38,19 +39,22 @@ class Container;
 class Handler;
 class Transport;
 
-class Session : public Endpoint
+ class Session : public Endpoint, public ProtonHandle<pn_session_t>
 {
   public:
     PROTON_CPP_EXTERN Session(pn_session_t *s);
+    PROTON_CPP_EXTERN Session();
     PROTON_CPP_EXTERN ~Session();
     PROTON_CPP_EXTERN void open();
+    PROTON_CPP_EXTERN Session(const Session&);
+    PROTON_CPP_EXTERN Session& operator=(const Session&);
     PROTON_CPP_EXTERN void close();
     PROTON_CPP_EXTERN pn_session_t *getPnSession();
     virtual PROTON_CPP_EXTERN Connection &getConnection();
     Receiver createReceiver(std::string name);
     Sender createSender(std::string name);
   private:
-    pn_session_t *pnSession;
+    friend class ProtonImplRef<Session>;
 };
 
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/648f7b36/proton-c/bindings/cpp/src/Connection.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Connection.cpp b/proton-c/bindings/cpp/src/Connection.cpp
index e85b323..49d171e 100644
--- a/proton-c/bindings/cpp/src/Connection.cpp
+++ b/proton-c/bindings/cpp/src/Connection.cpp
@@ -35,7 +35,7 @@ namespace reactor {
 template class Handle<ConnectionImpl>;
 typedef PrivateImplRef<Connection> PI;
 
-Connection::Connection() {}
+Connection::Connection() {PI::ctor(*this, 0); }
 Connection::Connection(ConnectionImpl* p) { PI::ctor(*this, p); }
 Connection::Connection(const Connection& c) : Handle<ConnectionImpl>() { PI::copy(*this, c); }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/648f7b36/proton-c/bindings/cpp/src/ConnectionImpl.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/ConnectionImpl.cpp b/proton-c/bindings/cpp/src/ConnectionImpl.cpp
index 2feecb5..be01f8d 100644
--- a/proton-c/bindings/cpp/src/ConnectionImpl.cpp
+++ b/proton-c/bindings/cpp/src/ConnectionImpl.cpp
@@ -22,6 +22,7 @@
 #include "proton/cpp/Handler.h"
 #include "proton/cpp/exceptions.h"
 #include "ConnectionImpl.h"
+#include "proton/cpp/Transport.h"
 #include "Msg.h"
 #include "contexts.h"
 
@@ -47,7 +48,10 @@ ConnectionImpl::ConnectionImpl(Container &c) : container(c), refCount(0), overri
     setConnectionContext(pnConnection, this);
 }
 
-ConnectionImpl::~ConnectionImpl() {}
+ConnectionImpl::~ConnectionImpl() {
+    delete transport;
+    delete override;
+}
 
 Transport &ConnectionImpl::getTransport() {
     if (transport)
@@ -56,7 +60,11 @@ Transport &ConnectionImpl::getTransport() {
 }
 
 Handler* ConnectionImpl::getOverride() { return override; }
-void ConnectionImpl::setOverride(Handler *h) { override = h; }
+void ConnectionImpl::setOverride(Handler *h) {
+    if (override)
+        delete override;
+    override = h;
+}
 
 void ConnectionImpl::open() {
     pn_connection_open(pnConnection);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/648f7b36/proton-c/bindings/cpp/src/Connector.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Connector.cpp b/proton-c/bindings/cpp/src/Connector.cpp
index 6885575..8ebdfb6 100644
--- a/proton-c/bindings/cpp/src/Connector.cpp
+++ b/proton-c/bindings/cpp/src/Connector.cpp
@@ -62,15 +62,14 @@ void Connector::onConnectionRemoteOpen(Event &e) {
 }
 
 void Connector::onConnectionInit(Event &e) {
-
 }
 
 void Connector::onTransportClosed(Event &e) {
     // TODO: prepend with reconnect logic
     PN_CPP_LOG(info, "Disconnected");
-    connection.setOverride(0);  // No more call backs
     pn_connection_release(connection.impl->pnConnection);
-    delete this;
+    // No more interaction, so drop our counted reference.
+    connection = Connection();
 }
 
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/648f7b36/proton-c/bindings/cpp/src/Container.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Container.cpp b/proton-c/bindings/cpp/src/Container.cpp
index 8e79b15..4eccb15 100644
--- a/proton-c/bindings/cpp/src/Container.cpp
+++ b/proton-c/bindings/cpp/src/Container.cpp
@@ -74,6 +74,10 @@ Receiver Container::createReceiver(Connection &connection, std::string &addr) {
     return impl->createReceiver(connection, addr);
 }
 
+Receiver Container::createReceiver(const std::string &url) {
+    return impl->createReceiver(url);
+}
+
 Acceptor Container::listen(const std::string &urlString) {
     return impl->listen(urlString);
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/648f7b36/proton-c/bindings/cpp/src/ContainerImpl.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/ContainerImpl.cpp b/proton-c/bindings/cpp/src/ContainerImpl.cpp
index 7ff9c1d..df8c716 100644
--- a/proton-c/bindings/cpp/src/ContainerImpl.cpp
+++ b/proton-c/bindings/cpp/src/ContainerImpl.cpp
@@ -37,6 +37,7 @@
 
 #include "proton/connection.h"
 #include "proton/session.h"
+#include "proton/handlers.h"
 
 namespace proton {
 namespace reactor {
@@ -64,23 +65,20 @@ class CHandler : public Handler
         pn_decref(pnHandler);
     }
     pn_handler_t *getPnHandler() { return pnHandler; }
+
+    virtual void onUnhandled(Event &e) {
+        ProtonEvent *pne = dynamic_cast<ProtonEvent *>(&e);
+        if (!pne) return;
+        int type = pne->getType();
+        if (!type) return;  // Not from the reactor
+        pn_handler_dispatch(pnHandler, pne->getPnEvent(), (pn_event_type_t) type);
+    }
+
   private:
     pn_handler_t *pnHandler;
 };
 
 
-void dispatch(Handler &h, MessagingEvent &e) {
-    // TODO: also dispatch to add()'ed Handlers
-    CHandler *chandler;
-    int type = e.getType();
-    if (type &&  (chandler = dynamic_cast<CHandler*>(&h))) {
-        // event and handler are both native Proton C
-        pn_handler_dispatch(chandler->getPnHandler(), e.getPnEvent(), (pn_event_type_t) type);
-    }
-    else
-        e.dispatch(h);
-}
-
 // Used to sniff for Connector events before the reactor's global handler sees them.
 class OverrideHandler : public Handler
 {
@@ -109,8 +107,9 @@ class OverrideHandler : public Handler
             ConnectionImpl *connection = getConnectionContext(conn);
             if (connection) {
                 Handler *override = connection->getOverride();
-                if (override)
+                if (override) {
                     e.dispatch(*override);
+                }
             }
         }
 
@@ -127,6 +126,29 @@ class OverrideHandler : public Handler
     }
 };
 
+
+class CFlowController : public ProtonHandler
+{
+  public:
+    pn_handler_t *flowcontroller;
+
+    CFlowController(int window) : flowcontroller(pn_flowcontroller(window)) {}
+    ~CFlowController() {
+        pn_decref(flowcontroller);
+    }
+
+    void redirect(Event &e) {
+        ProtonEvent *pne = dynamic_cast<ProtonEvent *>(&e);
+        pn_handler_dispatch(flowcontroller, pne->getPnEvent(), (pn_event_type_t) pne->getType());
+    }
+
+    virtual void onLinkLocalOpen(Event &e) { redirect(e); }
+    virtual void onLinkRemoteOpen(Event &e) { redirect(e); }
+    virtual void onLinkFlow(Event &e) { redirect(e); }
+    virtual void onDelivery(Event &e) { redirect(e); }
+};
+
+
 namespace {
 
 // TODO: configurable policy.  SessionPerConnection for now.
@@ -162,8 +184,8 @@ Handler &getCppHandler(pn_handler_t *c_handler) {
 
 void cpp_handler_dispatch(pn_handler_t *c_handler, pn_event_t *cevent, pn_event_type_t type)
 {
-    MessagingEvent ev(cevent, type, getContainerRef(c_handler));
-    dispatch(getCppHandler(c_handler), ev);
+    MessagingEvent mevent(cevent, type, getContainerRef(c_handler));
+    mevent.dispatch(getCppHandler(c_handler));
 }
 
 void cpp_handler_cleanup(pn_handler_t *c_handler)
@@ -176,7 +198,7 @@ pn_handler_t *cpp_handler(ContainerImpl *c, Handler *h)
 {
     pn_handler_t *handler = pn_handler_new(cpp_handler_dispatch, sizeof(struct InboundContext), cpp_handler_cleanup);
     struct InboundContext *ctxt = (struct InboundContext *) pn_handler_mem(handler);
-    ctxt->containerRef = Container(c);
+    new (&ctxt->containerRef) Container(c);
     ctxt->containerImpl = c;
     ctxt->cppHandler = h;
     return handler;
@@ -254,6 +276,17 @@ Receiver ContainerImpl::createReceiver(Connection &connection, std::string &addr
     return rcv;
 }
 
+Receiver ContainerImpl::createReceiver(const std::string &urlString) {
+    // TODO: const cleanup of API
+    Connection conn = connect(const_cast<std::string &>(urlString));
+    Session session = getDefaultSession(conn.getPnConnection(), &getImpl(conn)->defaultSession);
+    std::string path = Url(urlString).getPath();
+    Receiver rcv = session.createReceiver(containerId + '-' + path);
+    pn_terminus_set_address(pn_link_source(rcv.getPnLink()), path.c_str());
+    rcv.open();
+    return rcv;
+}
+
 Acceptor ContainerImpl::acceptor(const std::string &host, const std::string &port) {
     pn_acceptor_t *acptr = pn_reactor_acceptor(reactor, host.c_str(), port.c_str(), NULL);
     if (acptr)
@@ -271,11 +304,20 @@ Acceptor ContainerImpl::listen(const std::string &urlString) {
 
 void ContainerImpl::run() {
     reactor = pn_reactor();
+
     // Set our context on the reactor
     setContainerContext(reactor, this);
 
+    int prefetch = 10; // TODO: configurable
+    Handler *flowController = 0;
+
+
     // Set the reactor's main/default handler (see note below)
     MessagingAdapter messagingAdapter(messagingHandler);
+    if (prefetch) {
+        flowController = new CFlowController(prefetch);
+        messagingHandler.addChildHandler(*flowController);
+    }
     messagingHandler.addChildHandler(messagingAdapter);
     pn_handler_t *cppHandler = cpp_handler(this, &messagingHandler);
     pn_reactor_set_handler(reactor, cppHandler);
@@ -287,15 +329,18 @@ void ContainerImpl::run() {
     pn_handler_t *cppGlobalHandler = cpp_handler(this, &overrideHandler);
     pn_reactor_set_global_handler(reactor, cppGlobalHandler);
 
-    // Note: we have just set up the following 4 handlers that see events in this order:
-    // messagingHandler, messagingAdapter, connector override, the reactor's default global
-    // handler (pn_iohandler)
-    // TODO: remove fifth pn_handshaker once messagingAdapter matures
-
+    // Note: we have just set up the following 4/5 handlers that see events in this order:
+    // messagingHandler (Proton C events), pn_flowcontroller (optional), messagingAdapter,
+    // messagingHandler (Messaging events from the messagingAdapter), connector override,
+    // the reactor's default globalhandler (pn_iohandler)
     pn_reactor_run(reactor);
+
+    pn_decref(cppHandler);
+    pn_decref(cppGlobalHandler);
     pn_decref(cGlobalHandler);
     pn_reactor_free(reactor);
     reactor = 0;
+    delete(flowController);
 }
 
 }} // namespace proton::reactor

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/648f7b36/proton-c/bindings/cpp/src/ContainerImpl.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/ContainerImpl.h b/proton-c/bindings/cpp/src/ContainerImpl.h
index a14bf52..8a6faba 100644
--- a/proton-c/bindings/cpp/src/ContainerImpl.h
+++ b/proton-c/bindings/cpp/src/ContainerImpl.h
@@ -49,6 +49,7 @@ class ContainerImpl
     PROTON_CPP_EXTERN Sender createSender(Connection &connection, std::string &addr);
     PROTON_CPP_EXTERN Sender createSender(std::string &url);
     PROTON_CPP_EXTERN Receiver createReceiver(Connection &connection, std::string &addr);
+    PROTON_CPP_EXTERN Receiver createReceiver(const std::string &url); //ZZZ
     PROTON_CPP_EXTERN Acceptor listen(const std::string &url);
     PROTON_CPP_EXTERN std::string getContainerId();
     static void incref(ContainerImpl *);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/648f7b36/proton-c/bindings/cpp/src/Message.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Message.cpp b/proton-c/bindings/cpp/src/Message.cpp
index 840a10b..ead6eb1 100644
--- a/proton-c/bindings/cpp/src/Message.cpp
+++ b/proton-c/bindings/cpp/src/Message.cpp
@@ -22,33 +22,128 @@
 #include "proton/cpp/Message.h"
 #include "proton/cpp/exceptions.h"
 #include "Msg.h"
+#include "ProtonImplRef.h"
+
+#include <cstring>
 
 namespace proton {
 namespace reactor {
 
-Message::Message() : pnMessage(pn_message()){}
+template class ProtonHandle<pn_message_t>;
+typedef ProtonImplRef<Message> PI;
 
-Message::~Message() {
-    pn_decref(pnMessage);
+Message::Message() {
+    PI::ctor(*this, 0);
+}
+Message::Message(pn_message_t *p) {
+    PI::ctor(*this, p);
 }
+Message::Message(const Message& m) : ProtonHandle<pn_message_t>() {
+    PI::copy(*this, m);
+}
+Message& Message::operator=(const Message& m) {
+    return PI::assign(*this, m);
+}
+Message::~Message() { PI::dtor(*this); }
 
-Message::Message(const Message& m) : pnMessage(m.pnMessage) {
-    pn_incref(pnMessage);
+namespace {
+void confirm(pn_message_t *&p) {
+    if (p) return;
+    p = pn_message(); // Correct refcount of 1
+    if (!p)
+        throw ProtonException(MSG("No memory"));
 }
 
-Message& Message::operator=(const Message& m) {
-    pnMessage = m.pnMessage;
-    pn_incref(pnMessage);
-    return *this;
+void getFormatedStringContent(pn_data_t *data, std::string &str) {
+    pn_data_rewind(data);
+    size_t sz = str.capacity();
+    if (sz < 512) sz = 512;
+    while (true) {
+        str.resize(sz);
+        int err = pn_data_format(data, (char *) str.data(), &sz);
+        if (err) {
+            if (err != PN_OVERFLOW)
+                throw ProtonException(MSG("Unexpected message body data error"));
+        }
+        else {
+            str.resize(sz);
+            return;
+        }
+        sz *= 2;
+    }
+}
+
+} // namespace
+
+void Message::setId(uint64_t id) {
+    confirm(impl);
+    pn_data_t *data = pn_message_id(impl);
+    pn_data_clear(data);
+    if (int err = pn_data_put_ulong(data, id))
+        throw ProtonException(MSG("setId error " << err));
+}
+
+uint64_t Message::getId() {
+    confirm(impl);
+    pn_data_t *data = pn_message_id(impl);
+    pn_data_rewind(data);
+    if (pn_data_size(data) == 1 && pn_data_next(data) && pn_data_type(data) == PN_ULONG) {
+        return pn_data_get_ulong(data);
+    }
+    throw ProtonException(MSG("Message ID is not a ULONG"));
+}
+
+pn_type_t Message::getIdType() {
+    confirm(impl);
+    pn_data_t *data = pn_message_id(impl);
+    pn_data_rewind(data);
+    if (pn_data_size(data) == 1 && pn_data_next(data)) {
+        pn_type_t type = pn_data_type(data);
+        switch (type) {
+        case PN_ULONG:
+        case PN_STRING:
+        case PN_BINARY:
+        case PN_UUID:
+            return type;
+            break;
+        default:
+            break;
+        }
+    }
+    return PN_NULL;
 }
 
 void Message::setBody(const std::string &buf) {
-    pn_data_t *body = pn_message_body(pnMessage);
+    confirm(impl);
+    pn_data_t *body = pn_message_body(impl);
+    pn_data_clear(body);
     pn_data_put_string(body, pn_bytes(buf.size(), buf.data()));
 }
 
+void Message::getBody(std::string &str) {
+    // User supplied string/buffer
+    confirm(impl);
+    pn_data_t *body = pn_message_body(impl);
+    pn_data_rewind(body);
+
+    if (pn_data_next(body) && pn_data_type(body) == PN_STRING) {
+        pn_bytes_t bytes= pn_data_get_string(body);
+        if (!pn_data_next(body)) {
+            // String data and nothing else
+            str.resize(bytes.size);
+            memmove((void *) str.data(), bytes.start, bytes.size);
+            return;
+        }
+    }
+
+    getFormatedStringContent(body, str);
+}
+
 std::string Message::getBody() {
-    pn_data_t *body = pn_message_body(pnMessage);
+    confirm(impl);
+    pn_data_t *body = pn_message_body(impl);
+    pn_data_rewind(body);
+
     if (pn_data_next(body) && pn_data_type(body) == PN_STRING) {
         pn_bytes_t bytes= pn_data_get_string(body);
         if (!pn_data_next(body)) {
@@ -57,36 +152,73 @@ std::string Message::getBody() {
         }
     }
 
-    pn_data_rewind(body);
     std::string str;
-    size_t sz = 1024;
-    str.resize(sz);
-    int err = pn_data_format(body, (char *) str.data(), &sz);
-    if (err == PN_OVERFLOW)
-        throw ProtonException(MSG("TODO: sizing loop missing"));
-    if (err) throw ProtonException(MSG("Unexpected data error"));
-    str.resize(sz);
+    getFormatedStringContent(body, str);
     return str;
 }
 
+void Message::setBody(const char *bytes, size_t len) {
+    confirm(impl);
+    pn_data_t *body = pn_message_body(impl);
+    pn_data_clear(body);
+    pn_data_put_binary(body, pn_bytes(len, bytes));
+}
+
+size_t Message::getBody(char *bytes, size_t len) {
+    confirm(impl);
+    pn_data_t *body = pn_message_body(impl);
+    pn_data_rewind(body);
+    if (pn_data_size(body) == 1 && pn_data_next(body) && pn_data_type(body) == PN_BINARY) {
+        pn_bytes_t pnb = pn_data_get_binary(body);
+        if (len >= pnb.size) {
+            memmove(bytes, pnb.start, pnb.size);
+            return pnb.size;
+        }
+        throw ProtonException(MSG("Binary buffer too small"));
+    }
+    throw ProtonException(MSG("Not simple binary data"));
+}
+
+
+
+size_t Message::getBinaryBodySize() {
+    confirm(impl);
+    pn_data_t *body = pn_message_body(impl);
+    pn_data_rewind(body);
+    if (pn_data_size(body) == 1 && pn_data_next(body) && pn_data_type(body) == PN_BINARY) {
+        pn_bytes_t bytes = pn_data_get_binary(body);
+        return bytes.size;
+    }
+    return 0;
+}
+
+
 void Message::encode(std::string &s) {
-    size_t sz = 1024;
-    if (s.capacity() > sz)
-        sz = s.capacity();
-    else
-        s.reserve(sz);
-    s.resize(sz);
-    int err = pn_message_encode(pnMessage, (char *) s.data(), &sz);
-    if (err == PN_OVERFLOW)
-        throw ProtonException(MSG("TODO: fix overflow with dynamic buffer resizing"));
-    if (err) throw ProtonException(MSG("unexpected error"));
-    s.resize(sz);
+    confirm(impl);
+    size_t sz = s.capacity();
+    if (sz < 512) sz = 512;
+    while (true) {
+        s.resize(sz);
+        int err = pn_message_encode(impl, (char *) s.data(), &sz);
+        if (err) {
+            if (err != PN_OVERFLOW)
+                throw ProtonException(MSG("unexpected error"));
+        } else {
+            s.resize(sz);
+            return;
+        }
+        sz *= 2;
+    }
 }
 
 void Message::decode(const std::string &s) {
-    int err = pn_message_decode(pnMessage, s.data(), s.size());
+    confirm(impl);
+    int err = pn_message_decode(impl, s.data(), s.size());
     if (err) throw ProtonException(MSG("unexpected error"));
 }
 
+pn_message_t *Message::getPnMessage() const {
+    return impl;
+}
 
 }} // namespace proton::reactor

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/648f7b36/proton-c/bindings/cpp/src/MessagingAdapter.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/MessagingAdapter.cpp b/proton-c/bindings/cpp/src/MessagingAdapter.cpp
index 9cab2b3..1097305 100644
--- a/proton-c/bindings/cpp/src/MessagingAdapter.cpp
+++ b/proton-c/bindings/cpp/src/MessagingAdapter.cpp
@@ -28,23 +28,26 @@
 #include "proton/handlers.h"
 #include "proton/delivery.h"
 #include "proton/connection.h"
+#include "proton/session.h"
 
 namespace proton {
 namespace reactor {
 
-MessagingAdapter::MessagingAdapter(MessagingHandler &d) : delegate(d), handshaker(pn_handshaker()) {
-    pn_handler_t *flowcontroller = pn_flowcontroller(10);
-    pn_handler_add(handshaker, flowcontroller);
-    pn_decref(flowcontroller);
+MessagingAdapter::MessagingAdapter(MessagingHandler &d) : delegate(d), handshaker(pn_handshaker()),
+                                                          autoSettle(true), autoAccept(true),
+                                                          peerCloseIsError(false) {
 };
 MessagingAdapter::~MessagingAdapter(){
     pn_decref(handshaker);
 };
 
+
 void MessagingAdapter::onReactorInit(Event &e) {
-    // create onStart extended event
-    MessagingEvent mevent(PN_MESSAGING_START, NULL, e.getContainer());
-    mevent.dispatch(delegate);
+    ProtonEvent *pe = dynamic_cast<ProtonEvent*>(&e);
+    if (pe) {
+        MessagingEvent mevent(PN_MESSAGING_START, *pe);
+        delegate.onStart(mevent);
+    }
 }
 
 void MessagingAdapter::onLinkFlow(Event &e) {
@@ -54,8 +57,8 @@ void MessagingAdapter::onLinkFlow(Event &e) {
         pn_link_t *lnk = pn_event_link(pne);
         if (lnk && pn_link_is_sender(lnk) && pn_link_credit(lnk) > 0) {
             // create onMessage extended event
-            MessagingEvent mevent(PN_MESSAGING_SENDABLE, pe, e.getContainer());
-            mevent.dispatch(delegate);
+            MessagingEvent mevent(PN_MESSAGING_SENDABLE, *pe);
+            delegate.onSendable(mevent);;
         }
    }
 }
@@ -85,32 +88,60 @@ void MessagingAdapter::onDelivery(Event &e) {
         if (pn_link_is_receiver(lnk)) {
             if (!pn_delivery_partial(dlv) && pn_delivery_readable(dlv)) {
                 // generate onMessage
-                MessagingEvent mevent(PN_MESSAGING_MESSAGE, pe, pe->getContainer());
+                MessagingEvent mevent(PN_MESSAGING_MESSAGE, *pe);
                 Message m(receiveMessage(lnk, dlv));
                 mevent.setMessage(m);
-                // TODO: check if endpoint closed...
-                mevent.dispatch(delegate);
-                // only do auto accept for now
-                pn_delivery_update(dlv, PN_ACCEPTED);
-                pn_delivery_settle(dlv);
-                // TODO: generate onSettled
+                if (pn_link_state(lnk) & PN_LOCAL_CLOSED) {
+                    if (autoAccept) {
+                        pn_delivery_update(dlv, PN_RELEASED);
+                        pn_delivery_settle(dlv);
+                    }
+                }
+                else {
+                    try {
+                        delegate.onMessage(mevent);
+                        if (autoAccept) {
+                            pn_delivery_update(dlv, PN_ACCEPTED);
+                            pn_delivery_settle(dlv);
+                        }
+                    }
+                    catch (MessageReject &) {
+                        pn_delivery_update(dlv, PN_REJECTED);
+                        pn_delivery_settle(dlv);
+                    }
+                    catch (MessageRelease &) {
+                        pn_delivery_update(dlv, PN_REJECTED);
+                        pn_delivery_settle(dlv);
+                    }
+                }
+            }
+            else if (pn_delivery_updated(dlv) && pn_delivery_settled(dlv)) {
+                MessagingEvent mevent(PN_MESSAGING_SETTLED, *pe);
+                delegate.onSettled(mevent);
             }
         } else {
             // Sender
             if (pn_delivery_updated(dlv)) {
                 uint64_t rstate = pn_delivery_remote_state(dlv);
-                if (rstate == PN_ACCEPTED)
-                    // generate onAccepted
-                    MessagingEvent(PN_MESSAGING_ACCEPTED, pe, pe->getContainer()).dispatch(delegate);
-                else if (rstate = PN_REJECTED)
-                    MessagingEvent(PN_MESSAGING_REJECTED, pe, pe->getContainer()).dispatch(delegate);
-                else if (rstate == PN_RELEASED || rstate == PN_MODIFIED)
-                    MessagingEvent(PN_MESSAGING_RELEASED, pe, pe->getContainer()).dispatch(delegate);
-
-                if (pn_delivery_settled(dlv))
-                    MessagingEvent(PN_MESSAGING_SETTLED, pe, pe->getContainer()).dispatch(delegate);
-
-                pn_delivery_settle(dlv); // TODO: only if auto settled
+                if (rstate == PN_ACCEPTED) {
+                    MessagingEvent mevent(PN_MESSAGING_ACCEPTED, *pe);
+                    delegate.onAccepted(mevent);
+                }
+                else if (rstate = PN_REJECTED) {
+                    MessagingEvent mevent(PN_MESSAGING_REJECTED, *pe);
+                    delegate.onRejected(mevent);
+                }
+                else if (rstate == PN_RELEASED || rstate == PN_MODIFIED) {
+                    MessagingEvent mevent(PN_MESSAGING_RELEASED, *pe);
+                    delegate.onReleased(mevent);
+                }
+
+                if (pn_delivery_settled(dlv)) {
+                    MessagingEvent mevent(PN_MESSAGING_SETTLED, *pe);
+                    delegate.onSettled(mevent);
+                }
+                if (autoSettle)
+                    pn_delivery_settle(dlv);
             }
         }
     }
@@ -140,52 +171,247 @@ bool isRemoteClosed(pn_state_t state) {
 
 } // namespace
 
+void MessagingAdapter::onLinkRemoteClose(Event &e) {
+    ProtonEvent *pe = dynamic_cast<ProtonEvent*>(&e);
+    if (pe) {
+        pn_event_t *cevent = pe->getPnEvent();
+        pn_link_t *lnk = pn_event_link(cevent);
+        pn_state_t state = pn_link_state(lnk);
+        if (pn_condition_is_set(pn_link_remote_condition(lnk))) {
+            MessagingEvent mevent(PN_MESSAGING_LINK_ERROR, *pe);
+            onLinkError(mevent);
+        }
+        else if (isLocalClosed(state)) {
+            MessagingEvent mevent(PN_MESSAGING_LINK_CLOSED, *pe);
+            onLinkClosed(mevent);
+        }
+        else {
+            MessagingEvent mevent(PN_MESSAGING_LINK_CLOSING, *pe);
+            onLinkClosing(mevent);
+        }
+        pn_link_close(lnk);
+    }
+}
+
+void MessagingAdapter::onSessionRemoteClose(Event &e) {
+    ProtonEvent *pe = dynamic_cast<ProtonEvent*>(&e);
+    if (pe) {
+        pn_event_t *cevent = pe->getPnEvent();
+        pn_session_t *session = pn_event_session(cevent);
+        pn_state_t state = pn_session_state(session);
+        if (pn_condition_is_set(pn_session_remote_condition(session))) {
+            MessagingEvent mevent(PN_MESSAGING_SESSION_ERROR, *pe);
+            onSessionError(mevent);
+        }
+        else if (isLocalClosed(state)) {
+            MessagingEvent mevent(PN_MESSAGING_SESSION_CLOSED, *pe);
+            onSessionClosed(mevent);
+        }
+        else {
+            MessagingEvent mevent(PN_MESSAGING_SESSION_CLOSING, *pe);
+            onSessionClosing(mevent);
+        }
+        pn_session_close(session);
+    }
+}
+
 void MessagingAdapter::onConnectionRemoteClose(Event &e) {
     ProtonEvent *pe = dynamic_cast<ProtonEvent*>(&e);
     if (pe) {
         pn_event_t *cevent = pe->getPnEvent();
-        pn_connection_t *conn = pn_event_connection(cevent);
-        // TODO: remote condition -> error
-        if (isLocalClosed(pn_connection_state(conn))) {
-            MessagingEvent(PN_MESSAGING_CONNECTION_CLOSED, pe, pe->getContainer()).dispatch(delegate);
+        pn_connection_t *connection = pn_event_connection(cevent);
+        pn_state_t state = pn_connection_state(connection);
+        if (pn_condition_is_set(pn_connection_remote_condition(connection))) {
+            MessagingEvent mevent(PN_MESSAGING_CONNECTION_ERROR, *pe);
+            onConnectionError(mevent);
+        }
+        else if (isLocalClosed(state)) {
+            MessagingEvent mevent(PN_MESSAGING_CONNECTION_CLOSED, *pe);
+            onConnectionClosed(mevent);
         }
         else {
-            MessagingEvent(PN_MESSAGING_CONNECTION_CLOSING, pe, pe->getContainer()).dispatch(delegate);
+            MessagingEvent mevent(PN_MESSAGING_CONNECTION_CLOSING, *pe);
+            onConnectionClosing(mevent);
+        }
+        pn_connection_close(connection);
+    }
+}
+
+void MessagingAdapter::onConnectionLocalOpen(Event &e) {
+    ProtonEvent *pe = dynamic_cast<ProtonEvent*>(&e);
+    if (pe) {
+        pn_connection_t *connection = pn_event_connection(pe->getPnEvent());
+        if (isRemoteOpen(pn_connection_state(connection))) {
+            MessagingEvent mevent(PN_MESSAGING_CONNECTION_OPENED, *pe);
+            onConnectionOpened(mevent);
+        }
+    }
+}
+
+void MessagingAdapter::onConnectionRemoteOpen(Event &e) {
+    ProtonEvent *pe = dynamic_cast<ProtonEvent*>(&e);
+    if (pe) {
+        pn_connection_t *connection = pn_event_connection(pe->getPnEvent());
+        if (isLocalOpen(pn_connection_state(connection))) {
+            MessagingEvent mevent(PN_MESSAGING_CONNECTION_OPENED, *pe);
+            onConnectionOpened(mevent);
+        }
+        else if (isLocalUnititialised(pn_connection_state(connection))) {
+            MessagingEvent mevent(PN_MESSAGING_CONNECTION_OPENING, *pe);
+            onConnectionOpening(mevent);
+            pn_connection_open(connection);
+        }
+    }
+}
+
+void MessagingAdapter::onSessionLocalOpen(Event &e) {
+    ProtonEvent *pe = dynamic_cast<ProtonEvent*>(&e);
+    if (pe) {
+        pn_session_t *session = pn_event_session(pe->getPnEvent());
+        if (isRemoteOpen(pn_session_state(session))) {
+            MessagingEvent mevent(PN_MESSAGING_SESSION_OPENED, *pe);
+            onSessionOpened(mevent);
+        }
+    }
+}
+
+void MessagingAdapter::onSessionRemoteOpen(Event &e) {
+    ProtonEvent *pe = dynamic_cast<ProtonEvent*>(&e);
+    if (pe) {
+        pn_session_t *session = pn_event_session(pe->getPnEvent());
+        if (isLocalOpen(pn_session_state(session))) {
+            MessagingEvent mevent(PN_MESSAGING_SESSION_OPENED, *pe);
+            onSessionOpened(mevent);
+        }
+        else if (isLocalUnititialised(pn_session_state(session))) {
+            MessagingEvent mevent(PN_MESSAGING_SESSION_OPENING, *pe);
+            onSessionOpening(mevent);
+            pn_session_open(session);
         }
-        pn_connection_close(conn);
     }
 }
 
+void MessagingAdapter::onLinkLocalOpen(Event &e) {
+    ProtonEvent *pe = dynamic_cast<ProtonEvent*>(&e);
+    if (pe) {
+        pn_link_t *link = pn_event_link(pe->getPnEvent());
+        if (isRemoteOpen(pn_link_state(link))) {
+            MessagingEvent mevent(PN_MESSAGING_LINK_OPENED, *pe);
+            onLinkOpened(mevent);
+        }
+    }
+}
 
 void MessagingAdapter::onLinkRemoteOpen(Event &e) {
     ProtonEvent *pe = dynamic_cast<ProtonEvent*>(&e);
     if (pe) {
-        pn_event_t *cevent = pe->getPnEvent();
-        pn_link_t *link = pn_event_link(cevent);
-        // TODO: remote condition -> error
+        pn_link_t *link = pn_event_link(pe->getPnEvent());
         if (isLocalOpen(pn_link_state(link))) {
-            MessagingEvent(PN_MESSAGING_LINK_OPENED, pe, pe->getContainer()).dispatch(delegate);
+            MessagingEvent mevent(PN_MESSAGING_LINK_OPENED, *pe);
+            onLinkOpened(mevent);
         }
         else if (isLocalUnititialised(pn_link_state(link))) {
-            MessagingEvent(PN_MESSAGING_LINK_OPENING, pe, pe->getContainer()).dispatch(delegate);
+            MessagingEvent mevent(PN_MESSAGING_LINK_OPENING, *pe);
+            onLinkOpening(mevent);
             pn_link_open(link);
         }
     }
 }
 
+void MessagingAdapter::onTransportTailClosed(Event &e) {
+    ProtonEvent *pe = dynamic_cast<ProtonEvent*>(&e);
+    if (pe) {
+        pn_connection_t *conn = pn_event_connection(pe->getPnEvent());
+        if (conn && isLocalOpen(pn_connection_state(conn))) {
+            MessagingEvent mevent(PN_MESSAGING_DISCONNECTED, *pe);
+            delegate.onDisconnected(mevent);
+        }
+    }
+}
+
 
-void MessagingAdapter::onUnhandled(Event &e) {
-    // Until this code fleshes out closer to python's, cheat a bit with a pn_handshaker
+void MessagingAdapter::onConnectionOpened(Event &e) {
+    delegate.onConnectionOpened(e);
+}
 
+void MessagingAdapter::onSessionOpened(Event &e) {
+    delegate.onSessionOpened(e);
+}
+
+void MessagingAdapter::onLinkOpened(Event &e) {
+    delegate.onLinkOpened(e);
+}
+
+void MessagingAdapter::onConnectionOpening(Event &e) {
+    delegate.onConnectionOpening(e);
+}
+
+void MessagingAdapter::onSessionOpening(Event &e) {
+    delegate.onSessionOpening(e);
+}
+
+void MessagingAdapter::onLinkOpening(Event &e) {
+    delegate.onLinkOpening(e);
+}
+
+void MessagingAdapter::onConnectionError(Event &e) {
+    delegate.onConnectionError(e);
     ProtonEvent *pe = dynamic_cast<ProtonEvent*>(&e);
     if (pe) {
-        pn_event_type_t type = (pn_event_type_t) pe->getType();
-        if (type != PN_EVENT_NONE) {
-            pn_handler_dispatch(handshaker, pe->getPnEvent(), type);
-        }
+        pn_connection_t *connection = pn_event_connection(pe->getPnEvent());
+        pn_connection_close(connection);
+    }
+}
+
+void MessagingAdapter::onSessionError(Event &e) {
+    delegate.onSessionError(e);
+    ProtonEvent *pe = dynamic_cast<ProtonEvent*>(&e);
+    if (pe) {
+        pn_session_t *session = pn_event_session(pe->getPnEvent());
+        pn_session_close(session);
     }
 }
 
+void MessagingAdapter::onLinkError(Event &e) {
+    delegate.onLinkError(e);
+    ProtonEvent *pe = dynamic_cast<ProtonEvent*>(&e);
+    if (pe) {
+        pn_link_t *link = pn_event_link(pe->getPnEvent());
+        pn_link_close(link);
+    }
+}
+
+void MessagingAdapter::onConnectionClosed(Event &e) {
+    delegate.onConnectionClosed(e);
+}
 
+void MessagingAdapter::onSessionClosed(Event &e) {
+    delegate.onSessionClosed(e);
+}
+
+void MessagingAdapter::onLinkClosed(Event &e) {
+    delegate.onLinkClosed(e);
+}
+
+void MessagingAdapter::onConnectionClosing(Event &e) {
+    delegate.onConnectionClosing(e);
+    if (peerCloseIsError)
+        onConnectionError(e);
+}
+
+void MessagingAdapter::onSessionClosing(Event &e) {
+    delegate.onSessionClosing(e);
+    if (peerCloseIsError)
+        onSessionError(e);
+}
+
+void MessagingAdapter::onLinkClosing(Event &e) {
+    delegate.onLinkClosing(e);
+    if (peerCloseIsError)
+        onLinkError(e);
+}
+
+void MessagingAdapter::onUnhandled(Event &e) {
+}
 
 }} // namespace proton::reactor

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/648f7b36/proton-c/bindings/cpp/src/MessagingEvent.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/MessagingEvent.cpp b/proton-c/bindings/cpp/src/MessagingEvent.cpp
index bcfb721..b8a2f8a 100644
--- a/proton-c/bindings/cpp/src/MessagingEvent.cpp
+++ b/proton-c/bindings/cpp/src/MessagingEvent.cpp
@@ -24,6 +24,7 @@
 #include "proton/link.h"
 
 #include "proton/cpp/MessagingEvent.h"
+#include "proton/cpp/Message.h"
 #include "proton/cpp/ProtonHandler.h"
 #include "proton/cpp/MessagingHandler.h"
 #include "proton/cpp/exceptions.h"
@@ -37,8 +38,8 @@ MessagingEvent::MessagingEvent(pn_event_t *ce, pn_event_type_t t, Container &c)
     ProtonEvent(ce, t, c), messagingType(PN_MESSAGING_PROTON), parentEvent(0), message(0)
 {}
 
-MessagingEvent::MessagingEvent(MessagingEventType_t t, ProtonEvent *p, Container &c) :
-    ProtonEvent(NULL, PN_EVENT_NONE, c), messagingType(t), parentEvent(p), message(0) {
+MessagingEvent::MessagingEvent(MessagingEventType_t t, ProtonEvent &p) :
+    ProtonEvent(NULL, PN_EVENT_NONE, p.getContainer()), messagingType(t), parentEvent(&p), message(0) {
     if (messagingType == PN_MESSAGING_PROTON)
         throw ProtonException(MSG("invalid messaging event type"));
 }
@@ -80,16 +81,18 @@ Link MessagingEvent::getLink() {
 }
 
 Message MessagingEvent::getMessage() {
-    if (message)
-        return *message;
+    if (parentEvent) {
+        pn_message_t *m = getEventContext(parentEvent->getPnEvent());
+        if (m)
+            return Message(m);
+    }
     throw ProtonException(MSG("No message context for event"));
 }
 
 void MessagingEvent::setMessage(Message &m) {
-    if (messagingType != PN_MESSAGING_MESSAGE)
+    if (messagingType != PN_MESSAGING_MESSAGE || !parentEvent)
         throw ProtonException(MSG("Event type does not provide message"));
-    delete message;
-    message = new Message(m);
+    setEventContext(parentEvent->getPnEvent(), m.getPnMessage());
 }
 
 void MessagingEvent::dispatch(Handler &h) {
@@ -112,9 +115,23 @@ void MessagingEvent::dispatch(Handler &h) {
 
         case PN_MESSAGING_CONNECTION_CLOSING:     handler->onConnectionClosing(*this); break;
         case PN_MESSAGING_CONNECTION_CLOSED:      handler->onConnectionClosed(*this); break;
+        case PN_MESSAGING_CONNECTION_ERROR:       handler->onConnectionError(*this); break;
+        case PN_MESSAGING_CONNECTION_OPENING:     handler->onConnectionOpening(*this); break;
+        case PN_MESSAGING_CONNECTION_OPENED:      handler->onConnectionOpened(*this); break;
+
+        case PN_MESSAGING_LINK_CLOSED:            handler->onLinkClosed(*this); break;
+        case PN_MESSAGING_LINK_CLOSING:           handler->onLinkClosing(*this); break;
+        case PN_MESSAGING_LINK_ERROR:             handler->onLinkError(*this); break;
         case PN_MESSAGING_LINK_OPENING:           handler->onLinkOpening(*this); break;
         case PN_MESSAGING_LINK_OPENED:            handler->onLinkOpened(*this); break;
 
+        case PN_MESSAGING_SESSION_CLOSED:         handler->onSessionClosed(*this); break;
+        case PN_MESSAGING_SESSION_CLOSING:        handler->onSessionClosing(*this); break;
+        case PN_MESSAGING_SESSION_ERROR:          handler->onSessionError(*this); break;
+        case PN_MESSAGING_SESSION_OPENING:        handler->onSessionOpening(*this); break;
+        case PN_MESSAGING_SESSION_OPENED:         handler->onSessionOpened(*this); break;
+
+        case PN_MESSAGING_TRANSPORT_CLOSED:       handler->onTransportClosed(*this); break;
         default:
             throw ProtonException(MSG("Unkown messaging event type " << messagingType));
             break;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/648f7b36/proton-c/bindings/cpp/src/MessagingHandler.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/MessagingHandler.cpp b/proton-c/bindings/cpp/src/MessagingHandler.cpp
index 7cb48f6..6066b07 100644
--- a/proton-c/bindings/cpp/src/MessagingHandler.cpp
+++ b/proton-c/bindings/cpp/src/MessagingHandler.cpp
@@ -30,15 +30,17 @@ MessagingHandler::~MessagingHandler(){};
 void MessagingHandler::onAbort(Event &e) { onUnhandled(e); }
 void MessagingHandler::onAccepted(Event &e) { onUnhandled(e); }
 void MessagingHandler::onCommit(Event &e) { onUnhandled(e); }
-void MessagingHandler::onConnectionClose(Event &e) { onUnhandled(e); }
 void MessagingHandler::onConnectionClosed(Event &e) { onUnhandled(e); }
 void MessagingHandler::onConnectionClosing(Event &e) { onUnhandled(e); }
-void MessagingHandler::onConnectionOpen(Event &e) { onUnhandled(e); }
+void MessagingHandler::onConnectionError(Event &e) { onUnhandled(e); }
 void MessagingHandler::onConnectionOpened(Event &e) { onUnhandled(e); }
+void MessagingHandler::onConnectionOpening(Event &e) { onUnhandled(e); }
 void MessagingHandler::onDisconnected(Event &e) { onUnhandled(e); }
 void MessagingHandler::onFetch(Event &e) { onUnhandled(e); }
 void MessagingHandler::onIdLoaded(Event &e) { onUnhandled(e); }
+void MessagingHandler::onLinkClosed(Event &e) { onUnhandled(e); }
 void MessagingHandler::onLinkClosing(Event &e) { onUnhandled(e); }
+void MessagingHandler::onLinkError(Event &e) { onUnhandled(e); }
 void MessagingHandler::onLinkOpened(Event &e) { onUnhandled(e); }
 void MessagingHandler::onLinkOpening(Event &e) { onUnhandled(e); }
 void MessagingHandler::onMessage(Event &e) { onUnhandled(e); }
@@ -50,11 +52,17 @@ void MessagingHandler::onReleased(Event &e) { onUnhandled(e); }
 void MessagingHandler::onRequest(Event &e) { onUnhandled(e); }
 void MessagingHandler::onResponse(Event &e) { onUnhandled(e); }
 void MessagingHandler::onSendable(Event &e) { onUnhandled(e); }
+void MessagingHandler::onSessionClosed(Event &e) { onUnhandled(e); }
+void MessagingHandler::onSessionClosing(Event &e) { onUnhandled(e); }
+void MessagingHandler::onSessionError(Event &e) { onUnhandled(e); }
+void MessagingHandler::onSessionOpened(Event &e) { onUnhandled(e); }
+void MessagingHandler::onSessionOpening(Event &e) { onUnhandled(e); }
 void MessagingHandler::onSettled(Event &e) { onUnhandled(e); }
 void MessagingHandler::onStart(Event &e) { onUnhandled(e); }
 void MessagingHandler::onTimer(Event &e) { onUnhandled(e); }
 void MessagingHandler::onTransactionAborted(Event &e) { onUnhandled(e); }
 void MessagingHandler::onTransactionCommitted(Event &e) { onUnhandled(e); }
 void MessagingHandler::onTransactionDeclared(Event &e) { onUnhandled(e); }
+void MessagingHandler::onTransportClosed(Event &e) { onUnhandled(e); }
 
 }} // namespace proton::reactor

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/648f7b36/proton-c/bindings/cpp/src/Session.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Session.cpp b/proton-c/bindings/cpp/src/Session.cpp
index d2b01dd..4333dcf 100644
--- a/proton-c/bindings/cpp/src/Session.cpp
+++ b/proton-c/bindings/cpp/src/Session.cpp
@@ -30,34 +30,43 @@
 namespace proton {
 namespace reactor {
 
+template class ProtonHandle<pn_session_t>;
+typedef ProtonImplRef<Session> PI;
 
-Session::Session(pn_session_t *s) : pnSession(s)
-{
-    pn_incref(pnSession);
+Session::Session(pn_session_t *p) {
+    PI::ctor(*this, p);
+}
+Session::Session() {
+    PI::ctor(*this, 0);
+}
+Session::Session(const Session& c) : ProtonHandle<pn_session_t>() {
+    PI::copy(*this, c);
+}
+Session& Session::operator=(const Session& c) {
+    return PI::assign(*this, c);
 }
-
 Session::~Session() {
-    pn_decref(pnSession);
+    PI::dtor(*this);
 }
 
-pn_session_t *Session::getPnSession() { return pnSession; }
+pn_session_t *Session::getPnSession() { return impl; }
 
 void Session::open() {
-    pn_session_open(pnSession);
+    pn_session_open(impl);
 }
 
 Connection &Session::getConnection() {
-    pn_connection_t *c = pn_session_connection(pnSession);
+    pn_connection_t *c = pn_session_connection(impl);
     return ConnectionImpl::getReactorReference(c);
 }
 
 Receiver Session::createReceiver(std::string name) {
-    pn_link_t *link = pn_receiver(pnSession, name.c_str());
+    pn_link_t *link = pn_receiver(impl, name.c_str());
     return Receiver(link);
 }
 
 Sender Session::createSender(std::string name) {
-    pn_link_t *link = pn_sender(pnSession, name.c_str());
+    pn_link_t *link = pn_sender(impl, name.c_str());
     return Sender(link);
 }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/648f7b36/proton-c/bindings/cpp/src/contexts.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/contexts.cpp b/proton-c/bindings/cpp/src/contexts.cpp
index b1dec49..56483ff 100644
--- a/proton-c/bindings/cpp/src/contexts.cpp
+++ b/proton-c/bindings/cpp/src/contexts.cpp
@@ -23,13 +23,13 @@
 #include "proton/cpp/exceptions.h"
 #include "Msg.h"
 #include "proton/object.h"
+#include "proton/message.h"
 #include "proton/session.h"
 #include "proton/link.h"
 
 PN_HANDLE(PNI_CPP_CONNECTION_CONTEXT)
-PN_HANDLE(PNI_CPP_SESSION_CONTEXT)
-PN_HANDLE(PNI_CPP_LINK_CONTEXT)
 PN_HANDLE(PNI_CPP_CONTAINER_CONTEXT)
+PN_HANDLE(PNI_CPP_EVENT_CONTEXT)
 
 namespace proton {
 namespace reactor {
@@ -39,7 +39,6 @@ void setConnectionContext(pn_connection_t *pnConnection, ConnectionImpl *connect
     pn_record_def(record, PNI_CPP_CONNECTION_CONTEXT, PN_VOID);
     pn_record_set(record, PNI_CPP_CONNECTION_CONTEXT, connection);
 }
-
 ConnectionImpl *getConnectionContext(pn_connection_t *pnConnection) {
     if (!pnConnection) return NULL;
     pn_record_t *record = pn_connection_attachments(pnConnection);
@@ -48,40 +47,11 @@ ConnectionImpl *getConnectionContext(pn_connection_t *pnConnection) {
 }
 
 
-void setSessionContext(pn_session_t *pnSession, Session *session) {
-    pn_record_t *record = pn_session_attachments(pnSession);
-    pn_record_def(record, PNI_CPP_SESSION_CONTEXT, PN_VOID);
-    pn_record_set(record, PNI_CPP_SESSION_CONTEXT, session);
-}
-
-Session *getSessionContext(pn_session_t *pnSession) {
-    if (!pnSession) return NULL;
-    pn_record_t *record = pn_session_attachments(pnSession);
-    Session *p = (Session *) pn_record_get(record, PNI_CPP_SESSION_CONTEXT);
-    return p;
-}
-
-
-void setLinkContext(pn_link_t *pnLink, Link *link) {
-    pn_record_t *record = pn_link_attachments(pnLink);
-    pn_record_def(record, PNI_CPP_LINK_CONTEXT, PN_VOID);
-    pn_record_set(record, PNI_CPP_LINK_CONTEXT, link);
-}
-
-Link *getLinkContext(pn_link_t *pnLink) {
-    if (!pnLink) return NULL;
-    pn_record_t *record = pn_link_attachments(pnLink);
-    Link *p = (Link *) pn_record_get(record, PNI_CPP_LINK_CONTEXT);
-    return p;
-}
-
-
 void setContainerContext(pn_reactor_t *pnReactor, ContainerImpl *container) {
     pn_record_t *record = pn_reactor_attachments(pnReactor);
     pn_record_def(record, PNI_CPP_CONTAINER_CONTEXT, PN_VOID);
     pn_record_set(record, PNI_CPP_CONTAINER_CONTEXT, container);
 }
-
 ContainerImpl *getContainerContext(pn_reactor_t *pnReactor) {
     pn_record_t *record = pn_reactor_attachments(pnReactor);
     ContainerImpl *p = (ContainerImpl *) pn_record_get(record, PNI_CPP_CONTAINER_CONTEXT);
@@ -89,4 +59,17 @@ ContainerImpl *getContainerContext(pn_reactor_t *pnReactor) {
     return p;
 }
 
+void setEventContext(pn_event_t *pnEvent, pn_message_t *m) {
+    pn_record_t *record = pn_event_attachments(pnEvent);
+    pn_record_def(record, PNI_CPP_EVENT_CONTEXT, PN_OBJECT); // refcount it for life of the event
+    pn_record_set(record, PNI_CPP_EVENT_CONTEXT, m);
+}
+pn_message_t *getEventContext(pn_event_t *pnEvent) {
+    if (!pnEvent) return NULL;
+    pn_record_t *record = pn_event_attachments(pnEvent);
+    pn_message_t *p = (pn_message_t *) pn_record_get(record, PNI_CPP_EVENT_CONTEXT);
+    return p;
+}
+
+
 }} // namespace proton::reactor

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/648f7b36/proton-c/bindings/cpp/src/contexts.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/contexts.h b/proton-c/bindings/cpp/src/contexts.h
index c04a77a..e1b5f24 100644
--- a/proton-c/bindings/cpp/src/contexts.h
+++ b/proton-c/bindings/cpp/src/contexts.h
@@ -23,6 +23,7 @@
  */
 #include "proton/reactor.h"
 #include "proton/connection.h"
+#include "proton/message.h"
 
 namespace proton {
 namespace reactor {
@@ -43,6 +44,9 @@ class ContainerImpl;
 void setContainerContext(pn_reactor_t *pnReactor, ContainerImpl *container);
 ContainerImpl *getContainerContext(pn_reactor_t *pnReactor);
 
+void setEventContext(pn_event_t *pnEvent, pn_message_t *m);
+pn_message_t *getEventContext(pn_event_t *pnEvent);
+
 }} // namespace proton::reactor
 
 #endif  /*!PROTON_CPP_CONTEXTS_H*/


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


[34/50] [abbrv] qpid-proton git commit: PROTON-885: add manifest, move license file into setuputils

Posted by ac...@apache.org.
PROTON-885: add manifest, move license file into setuputils


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/c1f9ed41
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/c1f9ed41
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/c1f9ed41

Branch: refs/heads/cjansen-cpp-client
Commit: c1f9ed41ac144f4cd451af4f3e0d0ba36dd1f203
Parents: d98fa57
Author: Ken Giusti <kg...@apache.org>
Authored: Wed May 20 19:56:29 2015 -0400
Committer: Ken Giusti <kg...@apache.org>
Committed: Wed May 20 19:56:29 2015 -0400

----------------------------------------------------------------------
 LICENSE                                         |  9 +++---
 proton-c/bindings/python/MANIFEST.in            |  2 ++
 proton-c/bindings/python/PYZMQ_LICENSE.BSD      | 32 --------------------
 .../python/setuputils/PYZMQ_LICENSE.BSD         | 32 ++++++++++++++++++++
 4 files changed, 39 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c1f9ed41/LICENSE
----------------------------------------------------------------------
diff --git a/LICENSE b/LICENSE
index 6d1be4d..7d0fda9 100644
--- a/LICENSE
+++ b/LICENSE
@@ -208,7 +208,8 @@ Proton includes freegetopt with a separate BSD license.  Your use
 of the source code for freegetopt is subject to the terms and
 conditions of its license in examples/include/pncompat/internal/LICENSE.
 
-The python bindings includes files derived by PyZMQ an are licensed
-with a separate Modified BSD license.  Use of the source code in these
-files are subject to the terms and conditions in the license:
-proton-c/bindings/python/PYZMQ_LICENSE.BSD.
+The setup scripts for the python bindings include files derived by
+PyZMQ and are licensed with a separate Modified BSD license.  Use of
+the source code in these setup files are subject to the terms and
+conditions in the license:
+proton-c/bindings/python/setuputils/PYZMQ_LICENSE.BSD.

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c1f9ed41/proton-c/bindings/python/MANIFEST.in
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/MANIFEST.in b/proton-c/bindings/python/MANIFEST.in
new file mode 100644
index 0000000..a89a962
--- /dev/null
+++ b/proton-c/bindings/python/MANIFEST.in
@@ -0,0 +1,2 @@
+graft docs
+graft setuputils

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c1f9ed41/proton-c/bindings/python/PYZMQ_LICENSE.BSD
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/PYZMQ_LICENSE.BSD b/proton-c/bindings/python/PYZMQ_LICENSE.BSD
deleted file mode 100644
index a0a3790..0000000
--- a/proton-c/bindings/python/PYZMQ_LICENSE.BSD
+++ /dev/null
@@ -1,32 +0,0 @@
-PyZMQ is licensed under the terms of the Modified BSD License (also known as
-New or Revised BSD), as follows:
-
-Copyright (c) 2009-2012, Brian Granger, Min Ragan-Kelley
-
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-Redistributions of source code must retain the above copyright notice, this
-list of conditions and the following disclaimer.
-
-Redistributions in binary form must reproduce the above copyright notice, this
-list of conditions and the following disclaimer in the documentation and/or
-other materials provided with the distribution.
-
-Neither the name of PyZMQ nor the names of its contributors may be used to
-endorse or promote products derived from this software without specific prior
-written permission.
-
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
-ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
-FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
-SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c1f9ed41/proton-c/bindings/python/setuputils/PYZMQ_LICENSE.BSD
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/setuputils/PYZMQ_LICENSE.BSD b/proton-c/bindings/python/setuputils/PYZMQ_LICENSE.BSD
new file mode 100644
index 0000000..a0a3790
--- /dev/null
+++ b/proton-c/bindings/python/setuputils/PYZMQ_LICENSE.BSD
@@ -0,0 +1,32 @@
+PyZMQ is licensed under the terms of the Modified BSD License (also known as
+New or Revised BSD), as follows:
+
+Copyright (c) 2009-2012, Brian Granger, Min Ragan-Kelley
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this
+list of conditions and the following disclaimer.
+
+Redistributions in binary form must reproduce the above copyright notice, this
+list of conditions and the following disclaimer in the documentation and/or
+other materials provided with the distribution.
+
+Neither the name of PyZMQ nor the names of its contributors may be used to
+endorse or promote products derived from this software without specific prior
+written permission.
+
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


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


[29/50] [abbrv] qpid-proton git commit: PROTON-861: PROTON-887: add dummy impl method to schannel impl

Posted by ac...@apache.org.
PROTON-861: PROTON-887: add dummy impl method to schannel impl


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/ff159e81
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/ff159e81
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/ff159e81

Branch: refs/heads/cjansen-cpp-client
Commit: ff159e815b7d843abd2f0bbf93709a933b5acee8
Parents: 37fc7be
Author: Gordon Sim <gs...@redhat.com>
Authored: Fri May 15 19:56:58 2015 +0100
Committer: Gordon Sim <gs...@redhat.com>
Committed: Fri May 15 19:56:58 2015 +0100

----------------------------------------------------------------------
 proton-c/src/windows/schannel.c | 6 ++++++
 1 file changed, 6 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ff159e81/proton-c/src/windows/schannel.c
----------------------------------------------------------------------
diff --git a/proton-c/src/windows/schannel.c b/proton-c/src/windows/schannel.c
index 57d2256..78d05bf 100644
--- a/proton-c/src/windows/schannel.c
+++ b/proton-c/src/windows/schannel.c
@@ -795,6 +795,12 @@ int pn_ssl_get_peer_hostname( pn_ssl_t *ssl0, char *hostname, size_t *bufsize )
   return 0;
 }
 
+const char* pn_ssl_get_remote_subject(pn_ssl_t *ssl)
+{
+  //TODO: actual implementation
+  return NULL;
+}
+
 
 /** SChannel specific: */
 


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


[42/50] [abbrv] qpid-proton git commit: PROTON-518: add setter and getter for using the sasl hostname field

Posted by ac...@apache.org.
PROTON-518: add setter and getter for using the sasl hostname field


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/485b23d5
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/485b23d5
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/485b23d5

Branch: refs/heads/cjansen-cpp-client
Commit: 485b23d5009302a35988f9d5fc55ca0217db0bf0
Parents: 8c86c6f
Author: Robert Gemmell <ro...@apache.org>
Authored: Fri May 29 17:02:08 2015 +0100
Committer: Robert Gemmell <ro...@apache.org>
Committed: Fri May 29 17:02:45 2015 +0100

----------------------------------------------------------------------
 .../org/apache/qpid/proton/engine/Sasl.java     |  13 +++
 .../qpid/proton/engine/impl/SaslImpl.java       |  22 ++++
 .../qpid/proton/systemtests/SaslTest.java       | 100 +++++++++++++++++++
 3 files changed, 135 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/485b23d5/proton-j/src/main/java/org/apache/qpid/proton/engine/Sasl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/Sasl.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/Sasl.java
index dd63321..16043b9 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/Sasl.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/engine/Sasl.java
@@ -97,6 +97,19 @@ public interface Sasl
     String[] getRemoteMechanisms();
 
     /**
+     * Set the remote hostname to indicate the host being connected to when
+     * sending a SaslInit to the server.
+     */
+    void setRemoteHostname(String hostname);
+
+    /**
+     * Retrieve the hostname indicated by the client when sending its SaslInit.
+     *
+     * @return the hostname indicated by the remote client, or null if none specified.
+     */
+    String getHostname();
+
+    /**
      * Determine the size of the bytes available via recv().
      *
      * Returns the size in bytes available via recv().

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/485b23d5/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/SaslImpl.java
----------------------------------------------------------------------
diff --git a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/SaslImpl.java b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/SaslImpl.java
index ed8891e..053c21f 100644
--- a/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/SaslImpl.java
+++ b/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/SaslImpl.java
@@ -704,4 +704,26 @@ public class SaslImpl implements Sasl, SaslFrameBody.SaslFrameBodyHandler<Void>,
             _underlyingOutput.close_head();
         }
     }
+
+    @Override
+    public String getHostname()
+    {
+        if(_role != null)
+        {
+            checkRole(Role.SERVER);
+        }
+
+        return _hostname;
+    }
+
+    @Override
+    public void setRemoteHostname(String hostname)
+    {
+        if(_role != null)
+        {
+            checkRole(Role.CLIENT);
+        }
+
+        _hostname = hostname;
+    }
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/485b23d5/proton-j/src/test/java/org/apache/qpid/proton/systemtests/SaslTest.java
----------------------------------------------------------------------
diff --git a/proton-j/src/test/java/org/apache/qpid/proton/systemtests/SaslTest.java b/proton-j/src/test/java/org/apache/qpid/proton/systemtests/SaslTest.java
new file mode 100644
index 0000000..2980565
--- /dev/null
+++ b/proton-j/src/test/java/org/apache/qpid/proton/systemtests/SaslTest.java
@@ -0,0 +1,100 @@
+/*
+ * 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.
+ */
+package org.apache.qpid.proton.systemtests;
+
+import static org.apache.qpid.proton.systemtests.TestLoggingHelper.bold;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
+
+import java.util.logging.Logger;
+
+import org.apache.qpid.proton.Proton;
+import org.apache.qpid.proton.engine.Sasl;
+import org.junit.Test;
+
+public class SaslTest extends EngineTestBase
+{
+    private static final Logger LOGGER = Logger.getLogger(SaslTest.class.getName());
+
+    @Test
+    public void testSaslHostnamePropagationAndRetrieval() throws Exception
+    {
+        LOGGER.fine(bold("======== About to create transports"));
+
+        getClient().transport = Proton.transport();
+        ProtocolTracerEnabler.setProtocolTracer(getClient().transport, TestLoggingHelper.CLIENT_PREFIX);
+
+        Sasl clientSasl = getClient().transport.sasl();
+        clientSasl.client();
+
+        // Set the server hostname we are connecting to from the client
+        String hostname = "my-remote-host-123";
+        clientSasl.setRemoteHostname(hostname);
+
+        // Verify we can't get the hostname on the client
+        try
+        {
+            clientSasl.getHostname();
+            fail("should have throw IllegalStateException");
+        }
+        catch (IllegalStateException ise)
+        {
+            // expected
+        }
+
+        getServer().transport = Proton.transport();
+        ProtocolTracerEnabler.setProtocolTracer(getServer().transport, "            " + TestLoggingHelper.SERVER_PREFIX);
+
+        // Configure the server to do ANONYMOUS
+        Sasl serverSasl = getServer().transport.sasl();
+        serverSasl.server();
+        serverSasl.setMechanisms("ANONYMOUS");
+
+        // Verify we can't set the hostname on the server
+        try
+        {
+            serverSasl.setRemoteHostname("some-other-host");
+            fail("should have throw IllegalStateException");
+        }
+        catch (IllegalStateException ise)
+        {
+            // expected
+        }
+
+        assertNull(serverSasl.getHostname());
+        assertArrayEquals(new String[0], clientSasl.getRemoteMechanisms());
+
+        pumpClientToServer();
+        pumpServerToClient();
+
+        // Verify we got the mechs, set the chosen mech, and verify the
+        // server still doesnt know the hostname set/requested by the client
+        assertArrayEquals(new String[] {"ANONYMOUS"} , clientSasl.getRemoteMechanisms());
+        clientSasl.setMechanisms("ANONYMOUS");
+        assertNull(serverSasl.getHostname());
+
+        pumpClientToServer();
+
+        // Verify the server now knows that the client set the hostname field
+        assertEquals(hostname, serverSasl.getHostname());
+    }
+
+}


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


[44/50] [abbrv] qpid-proton git commit: PROTON-865: new cjansen-cpp-client branch for fledgling C++ client code using the event reactor

Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/src/ContainerImpl.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/ContainerImpl.cpp b/proton-c/bindings/cpp/src/ContainerImpl.cpp
new file mode 100644
index 0000000..7ff9c1d
--- /dev/null
+++ b/proton-c/bindings/cpp/src/ContainerImpl.cpp
@@ -0,0 +1,301 @@
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/cpp/Container.h"
+#include "proton/cpp/MessagingEvent.h"
+#include "proton/cpp/Connection.h"
+#include "proton/cpp/Session.h"
+#include "proton/cpp/MessagingAdapter.h"
+#include "proton/cpp/Acceptor.h"
+#include "proton/cpp/exceptions.h"
+#include "LogInternal.h"
+
+#include "ContainerImpl.h"
+#include "ConnectionImpl.h"
+#include "Connector.h"
+#include "contexts.h"
+#include "Url.h"
+#include "platform.h"
+#include "PrivateImplRef.h"
+
+#include "proton/connection.h"
+#include "proton/session.h"
+
+namespace proton {
+namespace reactor {
+
+namespace {
+
+ConnectionImpl *getImpl(const Connection &c) {
+    return PrivateImplRef<Connection>::get(c);
+}
+
+ContainerImpl *getImpl(const Container &c) {
+    return PrivateImplRef<Container>::get(c);
+}
+
+} // namespace
+
+
+class CHandler : public Handler
+{
+  public:
+    CHandler(pn_handler_t *h) : pnHandler(h) {
+        pn_incref(pnHandler);
+    }
+    ~CHandler() {
+        pn_decref(pnHandler);
+    }
+    pn_handler_t *getPnHandler() { return pnHandler; }
+  private:
+    pn_handler_t *pnHandler;
+};
+
+
+void dispatch(Handler &h, MessagingEvent &e) {
+    // TODO: also dispatch to add()'ed Handlers
+    CHandler *chandler;
+    int type = e.getType();
+    if (type &&  (chandler = dynamic_cast<CHandler*>(&h))) {
+        // event and handler are both native Proton C
+        pn_handler_dispatch(chandler->getPnHandler(), e.getPnEvent(), (pn_event_type_t) type);
+    }
+    else
+        e.dispatch(h);
+}
+
+// Used to sniff for Connector events before the reactor's global handler sees them.
+class OverrideHandler : public Handler
+{
+  public:
+    pn_handler_t *baseHandler;
+
+    OverrideHandler(pn_handler_t *h) : baseHandler(h) {
+        pn_incref(baseHandler);
+    }
+    ~OverrideHandler() {
+        pn_decref(baseHandler);
+    }
+
+
+    virtual void onUnhandled(Event &e) {
+        ProtonEvent *pne = dynamic_cast<ProtonEvent *>(&e);
+        // If not a Proton reactor event, nothing to override, nothing to pass along.
+        if (!pne) return;
+        int type = pne->getType();
+        if (!type) return;  // Also not from the reactor
+
+        pn_event_t *cevent = pne->getPnEvent();
+        pn_connection_t *conn = pn_event_connection(cevent);
+        if (conn && type != PN_CONNECTION_INIT) {
+            // send to override handler first
+            ConnectionImpl *connection = getConnectionContext(conn);
+            if (connection) {
+                Handler *override = connection->getOverride();
+                if (override)
+                    e.dispatch(*override);
+            }
+        }
+
+        pn_handler_dispatch(baseHandler, cevent, (pn_event_type_t) type);
+
+        if (conn && type == PN_CONNECTION_FINAL) {
+            //  TODO:  this must be the last acation of the last handler looking at
+            //  connection events. Better: generate a custom FINAL event (or task).  Or move to
+            //  separate event streams per connection as part of multi threading support.
+            ConnectionImpl *cimpl = getConnectionContext(conn);
+            if (cimpl)
+                cimpl->reactorDetach();
+        }
+    }
+};
+
+namespace {
+
+// TODO: configurable policy.  SessionPerConnection for now.
+Session getDefaultSession(pn_connection_t *conn, pn_session_t **ses) {
+    if (!*ses) {
+        *ses = pn_session(conn);
+        pn_session_open(*ses);
+    }
+    return Session(*ses);
+}
+
+
+struct InboundContext {
+    ContainerImpl *containerImpl;
+    Container containerRef;  // create only once for all inbound events
+    Handler *cppHandler;
+};
+
+ContainerImpl *getContainerImpl(pn_handler_t *c_handler) {
+    struct InboundContext *ctxt = (struct InboundContext *) pn_handler_mem(c_handler);
+    return ctxt->containerImpl;
+}
+
+Container &getContainerRef(pn_handler_t *c_handler) {
+    struct InboundContext *ctxt = (struct InboundContext *) pn_handler_mem(c_handler);
+    return ctxt->containerRef;
+}
+
+Handler &getCppHandler(pn_handler_t *c_handler) {
+    struct InboundContext *ctxt = (struct InboundContext *) pn_handler_mem(c_handler);
+    return *ctxt->cppHandler;
+}
+
+void cpp_handler_dispatch(pn_handler_t *c_handler, pn_event_t *cevent, pn_event_type_t type)
+{
+    MessagingEvent ev(cevent, type, getContainerRef(c_handler));
+    dispatch(getCppHandler(c_handler), ev);
+}
+
+void cpp_handler_cleanup(pn_handler_t *c_handler)
+{
+    struct InboundContext *ctxt = (struct InboundContext *) pn_handler_mem(c_handler);
+    ctxt->containerRef.~Container();
+}
+
+pn_handler_t *cpp_handler(ContainerImpl *c, Handler *h)
+{
+    pn_handler_t *handler = pn_handler_new(cpp_handler_dispatch, sizeof(struct InboundContext), cpp_handler_cleanup);
+    struct InboundContext *ctxt = (struct InboundContext *) pn_handler_mem(handler);
+    ctxt->containerRef = Container(c);
+    ctxt->containerImpl = c;
+    ctxt->cppHandler = h;
+    return handler;
+}
+
+
+} // namespace
+
+
+void ContainerImpl::incref(ContainerImpl *impl) {
+    impl->refCount++;
+}
+
+void ContainerImpl::decref(ContainerImpl *impl) {
+    impl->refCount--;
+    if (impl->refCount == 0)
+        delete impl;
+}
+
+ContainerImpl::ContainerImpl(MessagingHandler &mhandler) :
+    reactor(0), globalHandler(0), messagingHandler(mhandler), containerId(generateUuid()),
+    refCount(0)
+{
+}
+
+ContainerImpl::~ContainerImpl() {}
+
+Connection ContainerImpl::connect(std::string &host) {
+    if (!reactor) throw ProtonException(MSG("Container not initialized"));
+    Container cntnr(this);
+    Connection connection(cntnr);
+    Connector *connector = new Connector(connection);
+    // Connector self-deletes depending on reconnect logic
+    connector->setAddress(host);  // TODO: url vector
+    connection.setOverride(connector);
+    connection.open();
+    return connection;
+}
+
+pn_reactor_t *ContainerImpl::getReactor() { return reactor; }
+
+pn_handler_t *ContainerImpl::getGlobalHandler() { return globalHandler; }
+
+std::string ContainerImpl::getContainerId() { return containerId; }
+
+
+Sender ContainerImpl::createSender(Connection &connection, std::string &addr) {
+    Session session = getDefaultSession(connection.getPnConnection(), &getImpl(connection)->defaultSession);
+    Sender snd = session.createSender(containerId  + '-' + addr);
+    pn_terminus_set_address(pn_link_target(snd.getPnLink()), addr.c_str());
+    snd.open();
+
+    ConnectionImpl *connImpl = getImpl(connection);
+    return snd;
+}
+
+Sender ContainerImpl::createSender(std::string &urlString) {
+    Connection conn = connect(urlString);
+    Session session = getDefaultSession(conn.getPnConnection(), &getImpl(conn)->defaultSession);
+    std::string path = Url(urlString).getPath();
+    Sender snd = session.createSender(containerId + '-' + path);
+    pn_terminus_set_address(pn_link_target(snd.getPnLink()), path.c_str());
+    snd.open();
+
+    ConnectionImpl *connImpl = getImpl(conn);
+    return snd;
+}
+
+Receiver ContainerImpl::createReceiver(Connection &connection, std::string &addr) {
+    ConnectionImpl *connImpl = getImpl(connection);
+    Session session = getDefaultSession(connImpl->pnConnection, &connImpl->defaultSession);
+    Receiver rcv = session.createReceiver(containerId + '-' + addr);
+    pn_terminus_set_address(pn_link_source(rcv.getPnLink()), addr.c_str());
+    rcv.open();
+    return rcv;
+}
+
+Acceptor ContainerImpl::acceptor(const std::string &host, const std::string &port) {
+    pn_acceptor_t *acptr = pn_reactor_acceptor(reactor, host.c_str(), port.c_str(), NULL);
+    if (acptr)
+        return Acceptor(acptr);
+    else
+        throw ProtonException(MSG("accept fail: " << pn_error_text(pn_io_error(pn_reactor_io(reactor))) << "(" << host << ":" << port << ")"));
+}
+
+Acceptor ContainerImpl::listen(const std::string &urlString) {
+    Url url(urlString);
+    // TODO: SSL
+    return acceptor(url.getHost(), url.getPort());
+}
+
+
+void ContainerImpl::run() {
+    reactor = pn_reactor();
+    // Set our context on the reactor
+    setContainerContext(reactor, this);
+
+    // Set the reactor's main/default handler (see note below)
+    MessagingAdapter messagingAdapter(messagingHandler);
+    messagingHandler.addChildHandler(messagingAdapter);
+    pn_handler_t *cppHandler = cpp_handler(this, &messagingHandler);
+    pn_reactor_set_handler(reactor, cppHandler);
+
+    // Set our own global handler that "subclasses" the existing one
+    pn_handler_t *cGlobalHandler = pn_reactor_get_global_handler(reactor);
+    pn_incref(cGlobalHandler);
+    OverrideHandler overrideHandler(cGlobalHandler);
+    pn_handler_t *cppGlobalHandler = cpp_handler(this, &overrideHandler);
+    pn_reactor_set_global_handler(reactor, cppGlobalHandler);
+
+    // Note: we have just set up the following 4 handlers that see events in this order:
+    // messagingHandler, messagingAdapter, connector override, the reactor's default global
+    // handler (pn_iohandler)
+    // TODO: remove fifth pn_handshaker once messagingAdapter matures
+
+    pn_reactor_run(reactor);
+    pn_decref(cGlobalHandler);
+    pn_reactor_free(reactor);
+    reactor = 0;
+}
+
+}} // namespace proton::reactor

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/src/ContainerImpl.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/ContainerImpl.h b/proton-c/bindings/cpp/src/ContainerImpl.h
new file mode 100644
index 0000000..a14bf52
--- /dev/null
+++ b/proton-c/bindings/cpp/src/ContainerImpl.h
@@ -0,0 +1,69 @@
+#ifndef PROTON_CPP_CONTAINERIMPL_H
+#define PROTON_CPP_CONTAINERIMPL_H
+
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/cpp/ImportExport.h"
+#include "proton/cpp/MessagingHandler.h"
+#include "proton/cpp/Connection.h"
+#include "proton/cpp/Link.h"
+
+#include "proton/reactor.h"
+
+#include <string>
+namespace proton {
+namespace reactor {
+
+class DispatchHelper;
+class Connection;
+class Connector;
+class Acceptor;
+
+class ContainerImpl
+{
+  public:
+    PROTON_CPP_EXTERN ContainerImpl(MessagingHandler &mhandler);
+    PROTON_CPP_EXTERN ~ContainerImpl();
+    PROTON_CPP_EXTERN Connection connect(std::string &host);
+    PROTON_CPP_EXTERN void run();
+    PROTON_CPP_EXTERN pn_reactor_t *getReactor();
+    PROTON_CPP_EXTERN pn_handler_t *getGlobalHandler();
+    PROTON_CPP_EXTERN Sender createSender(Connection &connection, std::string &addr);
+    PROTON_CPP_EXTERN Sender createSender(std::string &url);
+    PROTON_CPP_EXTERN Receiver createReceiver(Connection &connection, std::string &addr);
+    PROTON_CPP_EXTERN Acceptor listen(const std::string &url);
+    PROTON_CPP_EXTERN std::string getContainerId();
+    static void incref(ContainerImpl *);
+    static void decref(ContainerImpl *);
+  private:
+    void dispatch(pn_event_t *event, pn_event_type_t type);
+    Acceptor acceptor(const std::string &host, const std::string &port);
+    pn_reactor_t *reactor;
+    pn_handler_t *globalHandler;
+    MessagingHandler &messagingHandler;
+    std::string containerId;
+    int refCount;
+};
+
+
+}} // namespace proton::reactor
+
+#endif  /*!PROTON_CPP_CONTAINERIMPL_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/src/Endpoint.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Endpoint.cpp b/proton-c/bindings/cpp/src/Endpoint.cpp
new file mode 100644
index 0000000..868f361
--- /dev/null
+++ b/proton-c/bindings/cpp/src/Endpoint.cpp
@@ -0,0 +1,37 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "proton/cpp/Endpoint.h"
+#include "proton/cpp/Connection.h"
+#include "proton/cpp/Transport.h"
+
+namespace proton {
+namespace reactor {
+
+Endpoint::Endpoint() {}
+
+Endpoint::~Endpoint() {}
+
+Transport &Endpoint::getTransport() {
+    return getConnection().getTransport();
+}
+
+}} // namespace proton::reactor

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/src/Event.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Event.cpp b/proton-c/bindings/cpp/src/Event.cpp
new file mode 100644
index 0000000..531c764
--- /dev/null
+++ b/proton-c/bindings/cpp/src/Event.cpp
@@ -0,0 +1,71 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "proton/reactor.h"
+#include "proton/event.h"
+
+#include "proton/cpp/Event.h"
+#include "proton/cpp/Handler.h"
+#include "proton/cpp/exceptions.h"
+
+#include "Msg.h"
+#include "contexts.h"
+
+namespace proton {
+namespace reactor {
+
+Event::Event() {}
+
+Event::~Event() {}
+
+
+Container &Event::getContainer() {
+    // Subclasses to override as appropriate
+    throw ProtonException(MSG("No container context for event"));
+}
+
+Connection &Event::getConnection() {
+    throw ProtonException(MSG("No connection context for Event"));
+}
+
+Sender Event::getSender() {
+    throw ProtonException(MSG("No Sender context for event"));
+}
+
+Receiver Event::getReceiver() {
+    throw ProtonException(MSG("No Receiver context for event"));
+}
+
+Link Event::getLink() {
+    throw ProtonException(MSG("No Link context for event"));
+}
+
+Message Event::getMessage() {
+    throw ProtonException(MSG("No message associated with event"));
+}
+
+void Event::setMessage(Message &) {
+    throw ProtonException(MSG("Operation not supported for this type of event"));
+}
+
+
+
+}} // namespace proton::reactor

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/src/Handler.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Handler.cpp b/proton-c/bindings/cpp/src/Handler.cpp
new file mode 100644
index 0000000..4d1b581
--- /dev/null
+++ b/proton-c/bindings/cpp/src/Handler.cpp
@@ -0,0 +1,44 @@
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/cpp/Handler.h"
+#include "proton/cpp/Event.h"
+
+namespace proton {
+namespace reactor {
+
+Handler::Handler(){};
+Handler::~Handler(){};
+
+void Handler::onUnhandled(Event &e){};
+
+void Handler::addChildHandler(Handler &e) {
+    childHandlers.push_back(&e);
+}
+
+std::vector<Handler *>::iterator Handler::childHandlersBegin() {
+    return childHandlers.begin();
+}
+
+std::vector<Handler *>::iterator Handler::childHandlersEnd() {
+    return childHandlers.end();
+}
+
+}} // namespace proton::reactor

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/src/Link.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Link.cpp b/proton-c/bindings/cpp/src/Link.cpp
new file mode 100644
index 0000000..3356b38
--- /dev/null
+++ b/proton-c/bindings/cpp/src/Link.cpp
@@ -0,0 +1,99 @@
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/cpp/Link.h"
+#include "proton/cpp/exceptions.h"
+#include "proton/cpp/Connection.h"
+#include "ConnectionImpl.h"
+#include "Msg.h"
+#include "contexts.h"
+#include "ProtonImplRef.h"
+
+#include "proton/connection.h"
+#include "proton/session.h"
+#include "proton/link.h"
+
+namespace proton {
+namespace reactor {
+
+namespace {
+
+static inline void throwIfNull(pn_link_t *l) { if (!l) throw ProtonException(MSG("Disassociated link")); }
+
+}
+
+template class ProtonHandle<pn_link_t>;
+typedef ProtonImplRef<Link> PI;
+
+Link::Link(pn_link_t* p) {
+    verifyType(p);
+    PI::ctor(*this, p);
+    if (p) senderLink = pn_link_is_sender(p);
+}
+Link::Link() {
+    PI::ctor(*this, 0);
+}
+Link::Link(const Link& c) : ProtonHandle<pn_link_t>() {
+    verifyType(impl);
+    PI::copy(*this, c);
+    senderLink = c.senderLink;
+}
+Link& Link::operator=(const Link& c) {
+    verifyType(impl);
+    senderLink = c.senderLink;
+    return PI::assign(*this, c);
+}
+Link::~Link() { PI::dtor(*this); }
+
+void Link::verifyType(pn_link_t *l) {} // Generic link can be sender or receiver
+
+pn_link_t *Link::getPnLink() const { return impl; }
+
+void Link::open() {
+    throwIfNull(impl);
+    pn_link_open(impl);
+}
+
+void Link::close() {
+    throwIfNull(impl);
+    pn_link_close(impl);
+}
+
+bool Link::isSender() {
+    return impl && senderLink;
+}
+
+bool Link::isReceiver() {
+    return impl && !senderLink;
+}
+
+int Link::getCredit() {
+    throwIfNull(impl);
+    return pn_link_credit(impl);
+}
+
+Connection &Link::getConnection() {
+    throwIfNull(impl);
+    pn_session_t *s = pn_link_session(impl);
+    pn_connection_t *c = pn_session_connection(s);
+    return ConnectionImpl::getReactorReference(c);
+}
+
+}} // namespace proton::reactor

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/src/LogInternal.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/LogInternal.h b/proton-c/bindings/cpp/src/LogInternal.h
new file mode 100644
index 0000000..427f90b
--- /dev/null
+++ b/proton-c/bindings/cpp/src/LogInternal.h
@@ -0,0 +1,51 @@
+#ifndef PROTON_CPP_LOG_INTERNAL_H
+#define PROTON_CPP_LOG_INTERNAL_H
+
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "Msg.h"
+
+namespace proton {
+namespace reactor {
+
+enum Level { trace, debug, info, notice, warning, error, critical };
+
+class Logger
+{
+public:
+    // TODO: build out to be ultra configurable as for corresponding QPID class + Statement
+    static void log(Level level, const char* file, int line, const char* function, const std::string& message);
+private:
+    //This class has only one instance so no need to copy
+    Logger();
+    ~Logger();
+
+    Logger(const Logger&);
+    Logger operator=(const Logger&);
+};
+
+// Just do simple logging for now
+#define PN_CPP_LOG(LEVEL, MESSAGE) Logger::log(LEVEL, 0, 0, 0, ::proton::reactor::Msg() << MESSAGE)
+
+}} // namespace proton::reactor
+
+#endif  /*!PROTON_CPP_LOG_INTERNAL_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/src/Logger.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Logger.cpp b/proton-c/bindings/cpp/src/Logger.cpp
new file mode 100644
index 0000000..2671b2e
--- /dev/null
+++ b/proton-c/bindings/cpp/src/Logger.cpp
@@ -0,0 +1,56 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "LogInternal.h"
+#include <cstdlib>
+
+namespace proton {
+namespace reactor {
+
+namespace {
+bool levelSet = false;
+Level logLevel = error;
+Level getLogLevel() {
+    if (!levelSet) {
+        levelSet = true;
+        const char *l = getenv("PROTON_CPP_LOG_LEVEL");
+        if (l && l[0] != 0 && l[1] == 0) {
+            char low = '0' + trace;
+            char high = '0' + critical;
+            if (*l >= low && *l <= high)
+                logLevel = (Level) (*l - '0');
+        }
+    }
+    return logLevel;
+}
+
+} // namespace
+
+
+void Logger::log(Level level, const char* file, int line, const char* function, const std::string& message)
+{
+    if (level >= getLogLevel()) {
+        std::cout << message << std::endl;
+        std::cout.flush();
+    }
+}
+
+}} // namespace proton::reactor

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/src/Message.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Message.cpp b/proton-c/bindings/cpp/src/Message.cpp
new file mode 100644
index 0000000..840a10b
--- /dev/null
+++ b/proton-c/bindings/cpp/src/Message.cpp
@@ -0,0 +1,92 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "proton/cpp/Message.h"
+#include "proton/cpp/exceptions.h"
+#include "Msg.h"
+
+namespace proton {
+namespace reactor {
+
+Message::Message() : pnMessage(pn_message()){}
+
+Message::~Message() {
+    pn_decref(pnMessage);
+}
+
+Message::Message(const Message& m) : pnMessage(m.pnMessage) {
+    pn_incref(pnMessage);
+}
+
+Message& Message::operator=(const Message& m) {
+    pnMessage = m.pnMessage;
+    pn_incref(pnMessage);
+    return *this;
+}
+
+void Message::setBody(const std::string &buf) {
+    pn_data_t *body = pn_message_body(pnMessage);
+    pn_data_put_string(body, pn_bytes(buf.size(), buf.data()));
+}
+
+std::string Message::getBody() {
+    pn_data_t *body = pn_message_body(pnMessage);
+    if (pn_data_next(body) && pn_data_type(body) == PN_STRING) {
+        pn_bytes_t bytes= pn_data_get_string(body);
+        if (!pn_data_next(body)) {
+            // String data and nothing else
+            return std::string(bytes.start, bytes.size);
+        }
+    }
+
+    pn_data_rewind(body);
+    std::string str;
+    size_t sz = 1024;
+    str.resize(sz);
+    int err = pn_data_format(body, (char *) str.data(), &sz);
+    if (err == PN_OVERFLOW)
+        throw ProtonException(MSG("TODO: sizing loop missing"));
+    if (err) throw ProtonException(MSG("Unexpected data error"));
+    str.resize(sz);
+    return str;
+}
+
+void Message::encode(std::string &s) {
+    size_t sz = 1024;
+    if (s.capacity() > sz)
+        sz = s.capacity();
+    else
+        s.reserve(sz);
+    s.resize(sz);
+    int err = pn_message_encode(pnMessage, (char *) s.data(), &sz);
+    if (err == PN_OVERFLOW)
+        throw ProtonException(MSG("TODO: fix overflow with dynamic buffer resizing"));
+    if (err) throw ProtonException(MSG("unexpected error"));
+    s.resize(sz);
+}
+
+void Message::decode(const std::string &s) {
+    int err = pn_message_decode(pnMessage, s.data(), s.size());
+    if (err) throw ProtonException(MSG("unexpected error"));
+}
+
+
+}} // namespace proton::reactor

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/src/MessagingAdapter.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/MessagingAdapter.cpp b/proton-c/bindings/cpp/src/MessagingAdapter.cpp
new file mode 100644
index 0000000..9cab2b3
--- /dev/null
+++ b/proton-c/bindings/cpp/src/MessagingAdapter.cpp
@@ -0,0 +1,191 @@
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/cpp/MessagingAdapter.h"
+#include "proton/cpp/MessagingEvent.h"
+#include "proton/cpp/Sender.h"
+#include "proton/cpp/exceptions.h"
+#include "Msg.h"
+
+#include "proton/link.h"
+#include "proton/handlers.h"
+#include "proton/delivery.h"
+#include "proton/connection.h"
+
+namespace proton {
+namespace reactor {
+
+MessagingAdapter::MessagingAdapter(MessagingHandler &d) : delegate(d), handshaker(pn_handshaker()) {
+    pn_handler_t *flowcontroller = pn_flowcontroller(10);
+    pn_handler_add(handshaker, flowcontroller);
+    pn_decref(flowcontroller);
+};
+MessagingAdapter::~MessagingAdapter(){
+    pn_decref(handshaker);
+};
+
+void MessagingAdapter::onReactorInit(Event &e) {
+    // create onStart extended event
+    MessagingEvent mevent(PN_MESSAGING_START, NULL, e.getContainer());
+    mevent.dispatch(delegate);
+}
+
+void MessagingAdapter::onLinkFlow(Event &e) {
+    ProtonEvent *pe = dynamic_cast<ProtonEvent*>(&e);
+    if (pe) {
+        pn_event_t *pne = pe->getPnEvent();
+        pn_link_t *lnk = pn_event_link(pne);
+        if (lnk && pn_link_is_sender(lnk) && pn_link_credit(lnk) > 0) {
+            // create onMessage extended event
+            MessagingEvent mevent(PN_MESSAGING_SENDABLE, pe, e.getContainer());
+            mevent.dispatch(delegate);
+        }
+   }
+}
+
+namespace {
+Message receiveMessage(pn_link_t *lnk, pn_delivery_t *dlv) {
+    std::string buf;
+    size_t sz = pn_delivery_pending(dlv);
+    buf.resize(sz);
+    ssize_t n = pn_link_recv(lnk, (char *) buf.data(), sz);
+    if (n != (ssize_t) sz)
+        throw ProtonException(MSG("link read failure"));
+    Message m;
+    m. decode(buf);
+    pn_link_advance(lnk);
+    return m;
+}
+} // namespace
+
+void MessagingAdapter::onDelivery(Event &e) {
+    ProtonEvent *pe = dynamic_cast<ProtonEvent*>(&e);
+    if (pe) {
+        pn_event_t *cevent = pe->getPnEvent();
+        pn_link_t *lnk = pn_event_link(cevent);
+        pn_delivery_t *dlv = pn_event_delivery(cevent);
+
+        if (pn_link_is_receiver(lnk)) {
+            if (!pn_delivery_partial(dlv) && pn_delivery_readable(dlv)) {
+                // generate onMessage
+                MessagingEvent mevent(PN_MESSAGING_MESSAGE, pe, pe->getContainer());
+                Message m(receiveMessage(lnk, dlv));
+                mevent.setMessage(m);
+                // TODO: check if endpoint closed...
+                mevent.dispatch(delegate);
+                // only do auto accept for now
+                pn_delivery_update(dlv, PN_ACCEPTED);
+                pn_delivery_settle(dlv);
+                // TODO: generate onSettled
+            }
+        } else {
+            // Sender
+            if (pn_delivery_updated(dlv)) {
+                uint64_t rstate = pn_delivery_remote_state(dlv);
+                if (rstate == PN_ACCEPTED)
+                    // generate onAccepted
+                    MessagingEvent(PN_MESSAGING_ACCEPTED, pe, pe->getContainer()).dispatch(delegate);
+                else if (rstate = PN_REJECTED)
+                    MessagingEvent(PN_MESSAGING_REJECTED, pe, pe->getContainer()).dispatch(delegate);
+                else if (rstate == PN_RELEASED || rstate == PN_MODIFIED)
+                    MessagingEvent(PN_MESSAGING_RELEASED, pe, pe->getContainer()).dispatch(delegate);
+
+                if (pn_delivery_settled(dlv))
+                    MessagingEvent(PN_MESSAGING_SETTLED, pe, pe->getContainer()).dispatch(delegate);
+
+                pn_delivery_settle(dlv); // TODO: only if auto settled
+            }
+        }
+    }
+}
+
+namespace {
+
+bool isLocalOpen(pn_state_t state) {
+    return state & PN_LOCAL_ACTIVE;
+}
+
+bool isLocalUnititialised(pn_state_t state) {
+    return state & PN_LOCAL_UNINIT;
+}
+
+bool isLocalClosed(pn_state_t state) {
+    return state & PN_LOCAL_CLOSED;
+}
+
+bool isRemoteOpen(pn_state_t state) {
+    return state & PN_REMOTE_ACTIVE;
+}
+
+bool isRemoteClosed(pn_state_t state) {
+    return state & PN_REMOTE_CLOSED;
+}
+
+} // namespace
+
+void MessagingAdapter::onConnectionRemoteClose(Event &e) {
+    ProtonEvent *pe = dynamic_cast<ProtonEvent*>(&e);
+    if (pe) {
+        pn_event_t *cevent = pe->getPnEvent();
+        pn_connection_t *conn = pn_event_connection(cevent);
+        // TODO: remote condition -> error
+        if (isLocalClosed(pn_connection_state(conn))) {
+            MessagingEvent(PN_MESSAGING_CONNECTION_CLOSED, pe, pe->getContainer()).dispatch(delegate);
+        }
+        else {
+            MessagingEvent(PN_MESSAGING_CONNECTION_CLOSING, pe, pe->getContainer()).dispatch(delegate);
+        }
+        pn_connection_close(conn);
+    }
+}
+
+
+void MessagingAdapter::onLinkRemoteOpen(Event &e) {
+    ProtonEvent *pe = dynamic_cast<ProtonEvent*>(&e);
+    if (pe) {
+        pn_event_t *cevent = pe->getPnEvent();
+        pn_link_t *link = pn_event_link(cevent);
+        // TODO: remote condition -> error
+        if (isLocalOpen(pn_link_state(link))) {
+            MessagingEvent(PN_MESSAGING_LINK_OPENED, pe, pe->getContainer()).dispatch(delegate);
+        }
+        else if (isLocalUnititialised(pn_link_state(link))) {
+            MessagingEvent(PN_MESSAGING_LINK_OPENING, pe, pe->getContainer()).dispatch(delegate);
+            pn_link_open(link);
+        }
+    }
+}
+
+
+void MessagingAdapter::onUnhandled(Event &e) {
+    // Until this code fleshes out closer to python's, cheat a bit with a pn_handshaker
+
+    ProtonEvent *pe = dynamic_cast<ProtonEvent*>(&e);
+    if (pe) {
+        pn_event_type_t type = (pn_event_type_t) pe->getType();
+        if (type != PN_EVENT_NONE) {
+            pn_handler_dispatch(handshaker, pe->getPnEvent(), type);
+        }
+    }
+}
+
+
+
+}} // namespace proton::reactor

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/src/MessagingEvent.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/MessagingEvent.cpp b/proton-c/bindings/cpp/src/MessagingEvent.cpp
new file mode 100644
index 0000000..bcfb721
--- /dev/null
+++ b/proton-c/bindings/cpp/src/MessagingEvent.cpp
@@ -0,0 +1,133 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "proton/reactor.h"
+#include "proton/event.h"
+#include "proton/link.h"
+
+#include "proton/cpp/MessagingEvent.h"
+#include "proton/cpp/ProtonHandler.h"
+#include "proton/cpp/MessagingHandler.h"
+#include "proton/cpp/exceptions.h"
+#include "Msg.h"
+#include "contexts.h"
+
+namespace proton {
+namespace reactor {
+
+MessagingEvent::MessagingEvent(pn_event_t *ce, pn_event_type_t t, Container &c) :
+    ProtonEvent(ce, t, c), messagingType(PN_MESSAGING_PROTON), parentEvent(0), message(0)
+{}
+
+MessagingEvent::MessagingEvent(MessagingEventType_t t, ProtonEvent *p, Container &c) :
+    ProtonEvent(NULL, PN_EVENT_NONE, c), messagingType(t), parentEvent(p), message(0) {
+    if (messagingType == PN_MESSAGING_PROTON)
+        throw ProtonException(MSG("invalid messaging event type"));
+}
+
+MessagingEvent::~MessagingEvent() {
+    delete message;
+}
+
+Connection &MessagingEvent::getConnection() {
+    if (messagingType == PN_MESSAGING_PROTON)
+        return ProtonEvent::getConnection();
+    if (parentEvent)
+        return parentEvent->getConnection();
+    throw ProtonException(MSG("No connection context for event"));
+}
+
+Sender MessagingEvent::getSender() {
+    if (messagingType == PN_MESSAGING_PROTON)
+        return ProtonEvent::getSender();
+    if (parentEvent)
+        return parentEvent->getSender();
+    throw ProtonException(MSG("No sender context for event"));
+}
+
+Receiver MessagingEvent::getReceiver() {
+    if (messagingType == PN_MESSAGING_PROTON)
+        return ProtonEvent::getReceiver();
+    if (parentEvent)
+        return parentEvent->getReceiver();
+    throw ProtonException(MSG("No receiver context for event"));
+}
+
+Link MessagingEvent::getLink() {
+    if (messagingType == PN_MESSAGING_PROTON)
+        return ProtonEvent::getLink();
+    if (parentEvent)
+        return parentEvent->getLink();
+    throw ProtonException(MSG("No link context for event"));
+}
+
+Message MessagingEvent::getMessage() {
+    if (message)
+        return *message;
+    throw ProtonException(MSG("No message context for event"));
+}
+
+void MessagingEvent::setMessage(Message &m) {
+    if (messagingType != PN_MESSAGING_MESSAGE)
+        throw ProtonException(MSG("Event type does not provide message"));
+    delete message;
+    message = new Message(m);
+}
+
+void MessagingEvent::dispatch(Handler &h) {
+    if (messagingType == PN_MESSAGING_PROTON) {
+        ProtonEvent::dispatch(h);
+        return;
+    }
+
+    MessagingHandler *handler = dynamic_cast<MessagingHandler*>(&h);
+    if (handler) {
+        switch(messagingType) {
+
+        case PN_MESSAGING_START:       handler->onStart(*this); break;
+        case PN_MESSAGING_SENDABLE:    handler->onSendable(*this); break;
+        case PN_MESSAGING_MESSAGE:     handler->onMessage(*this); break;
+        case PN_MESSAGING_ACCEPTED:    handler->onAccepted(*this); break;
+        case PN_MESSAGING_REJECTED:    handler->onRejected(*this); break;
+        case PN_MESSAGING_RELEASED:    handler->onReleased(*this); break;
+        case PN_MESSAGING_SETTLED:     handler->onSettled(*this); break;
+
+        case PN_MESSAGING_CONNECTION_CLOSING:     handler->onConnectionClosing(*this); break;
+        case PN_MESSAGING_CONNECTION_CLOSED:      handler->onConnectionClosed(*this); break;
+        case PN_MESSAGING_LINK_OPENING:           handler->onLinkOpening(*this); break;
+        case PN_MESSAGING_LINK_OPENED:            handler->onLinkOpened(*this); break;
+
+        default:
+            throw ProtonException(MSG("Unkown messaging event type " << messagingType));
+            break;
+        }
+    } else {
+        h.onUnhandled(*this);
+    }
+
+    // recurse through children
+    for (std::vector<Handler *>::iterator child = h.childHandlersBegin();
+         child != h.childHandlersEnd(); ++child) {
+        dispatch(**child);
+    }
+}
+
+}} // namespace proton::reactor

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/src/MessagingHandler.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/MessagingHandler.cpp b/proton-c/bindings/cpp/src/MessagingHandler.cpp
new file mode 100644
index 0000000..7cb48f6
--- /dev/null
+++ b/proton-c/bindings/cpp/src/MessagingHandler.cpp
@@ -0,0 +1,60 @@
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/cpp/MessagingHandler.h"
+#include "proton/cpp/Event.h"
+
+namespace proton {
+namespace reactor {
+
+MessagingHandler::MessagingHandler(){};
+MessagingHandler::~MessagingHandler(){};
+
+void MessagingHandler::onAbort(Event &e) { onUnhandled(e); }
+void MessagingHandler::onAccepted(Event &e) { onUnhandled(e); }
+void MessagingHandler::onCommit(Event &e) { onUnhandled(e); }
+void MessagingHandler::onConnectionClose(Event &e) { onUnhandled(e); }
+void MessagingHandler::onConnectionClosed(Event &e) { onUnhandled(e); }
+void MessagingHandler::onConnectionClosing(Event &e) { onUnhandled(e); }
+void MessagingHandler::onConnectionOpen(Event &e) { onUnhandled(e); }
+void MessagingHandler::onConnectionOpened(Event &e) { onUnhandled(e); }
+void MessagingHandler::onDisconnected(Event &e) { onUnhandled(e); }
+void MessagingHandler::onFetch(Event &e) { onUnhandled(e); }
+void MessagingHandler::onIdLoaded(Event &e) { onUnhandled(e); }
+void MessagingHandler::onLinkClosing(Event &e) { onUnhandled(e); }
+void MessagingHandler::onLinkOpened(Event &e) { onUnhandled(e); }
+void MessagingHandler::onLinkOpening(Event &e) { onUnhandled(e); }
+void MessagingHandler::onMessage(Event &e) { onUnhandled(e); }
+void MessagingHandler::onQuit(Event &e) { onUnhandled(e); }
+void MessagingHandler::onRecordInserted(Event &e) { onUnhandled(e); }
+void MessagingHandler::onRecordsLoaded(Event &e) { onUnhandled(e); }
+void MessagingHandler::onRejected(Event &e) { onUnhandled(e); }
+void MessagingHandler::onReleased(Event &e) { onUnhandled(e); }
+void MessagingHandler::onRequest(Event &e) { onUnhandled(e); }
+void MessagingHandler::onResponse(Event &e) { onUnhandled(e); }
+void MessagingHandler::onSendable(Event &e) { onUnhandled(e); }
+void MessagingHandler::onSettled(Event &e) { onUnhandled(e); }
+void MessagingHandler::onStart(Event &e) { onUnhandled(e); }
+void MessagingHandler::onTimer(Event &e) { onUnhandled(e); }
+void MessagingHandler::onTransactionAborted(Event &e) { onUnhandled(e); }
+void MessagingHandler::onTransactionCommitted(Event &e) { onUnhandled(e); }
+void MessagingHandler::onTransactionDeclared(Event &e) { onUnhandled(e); }
+
+}} // namespace proton::reactor

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/src/Msg.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Msg.h b/proton-c/bindings/cpp/src/Msg.h
new file mode 100644
index 0000000..1168d35
--- /dev/null
+++ b/proton-c/bindings/cpp/src/Msg.h
@@ -0,0 +1,79 @@
+#ifndef PROTON_MSG_H
+#define PROTON_MSG_H
+
+/*
+ *
+ * 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.
+ *
+ */
+
+#include <sstream>
+#include <iostream>
+
+namespace proton {
+namespace reactor {
+
+/** A simple wrapper for std::ostringstream that allows
+ * in place construction of a message and automatic conversion
+ * to string.
+ * E.g.
+ *@code
+ * void foo(const std::string&);
+ * foo(Msg() << "hello " << 32);
+ *@endcode
+ * Will construct the string "hello 32" and pass it to foo()
+ */
+struct Msg {
+    std::ostringstream os;
+    Msg() {}
+    Msg(const Msg& m) : os(m.str()) {}
+    std::string str() const { return os.str(); }
+    operator std::string() const { return str(); }
+
+    Msg& operator<<(long n) { os << n; return *this; }
+    Msg& operator<<(unsigned long n) { os << n; return *this; }
+    Msg& operator<<(bool n) { os << n; return *this; }
+    Msg& operator<<(short n) { os << n; return *this; }
+    Msg& operator<<(unsigned short n) { os << n; return *this; }
+    Msg& operator<<(int n) { os << n; return *this; }
+    Msg& operator<<(unsigned int n) { os << n; return *this; }
+#ifdef _GLIBCXX_USE_LONG_LONG
+    Msg& operator<<(long long n) { os << n; return *this; }
+    Msg& operator<<(unsigned long long n) { os << n; return *this; }
+#endif
+    Msg& operator<<(double n) { os << n; return *this; }
+    Msg& operator<<(float n) { os << n; return *this; }
+    Msg& operator<<(long double n) { os << n; return *this; }
+
+    template <class T> Msg& operator<<(const T& t) { os <<t; return *this; }
+};
+
+
+
+inline std::ostream& operator<<(std::ostream& o, const Msg& m) {
+    return o << m.str();
+}
+
+/** Construct a message using operator << and append (file:line) */
+#define QUOTE_(x) #x
+#define QUOTE(x) QUOTE_(x)
+#define MSG(message) (::proton::reactor::Msg() << message << " (" __FILE__ ":" QUOTE(__LINE__) ")")
+
+}} // namespace proton::reactor
+
+#endif  /*!PROTON_MSG_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/src/PrivateImplRef.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/PrivateImplRef.h b/proton-c/bindings/cpp/src/PrivateImplRef.h
new file mode 100644
index 0000000..a2dccc2
--- /dev/null
+++ b/proton-c/bindings/cpp/src/PrivateImplRef.h
@@ -0,0 +1,97 @@
+#ifndef PROTON_CPP_PRIVATEIMPL_H
+#define PROTON_CPP_PRIVATEIMPL_H
+
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "proton/cpp/ImportExport.h"
+
+namespace proton {
+namespace reactor {
+
+// Modified from qpid::messaging version to work without
+// boost::intrusive_ptr but integrate with Proton's pn_class_t
+// reference counting.  Thread safety currently absent but fluid in
+// intention...
+
+
+/**
+ * Helper class to implement a class with a private, reference counted
+ * implementation and reference semantics.
+ *
+ * Such classes are used in the public API to hide implementation, they
+ * should. Example of use:
+ *
+ * === Foo.h
+ *
+ * template <class T> PrivateImplRef;
+ * class FooImpl;
+ *
+ * Foo : public Handle<FooImpl> {
+ *  public:
+ *   Foo(FooImpl* = 0);
+ *   Foo(const Foo&);
+ *   ~Foo();
+ *   Foo& operator=(const Foo&);
+ *
+ *   int fooDo();              //  and other Foo functions...
+ *
+ *  private:
+ *   typedef FooImpl Impl;
+ *   Impl* impl;
+ *   friend class PrivateImplRef<Foo>;
+ *
+ * === Foo.cpp
+ *
+ * typedef PrivateImplRef<Foo> PI;
+ * Foo::Foo(FooImpl* p) { PI::ctor(*this, p); }
+ * Foo::Foo(const Foo& c) : Handle<FooImpl>() { PI::copy(*this, c); }
+ * Foo::~Foo() { PI::dtor(*this); }
+ * Foo& Foo::operator=(const Foo& c) { return PI::assign(*this, c); }
+ *
+ * int foo::fooDo() { return impl->fooDo(); }
+ *
+ */
+template <class T> class PrivateImplRef {
+  public:
+    typedef typename T::Impl Impl;
+
+    /** Get the implementation pointer from a handle */
+    static Impl* get(const T& t) { return t.impl; }
+
+    /** Set the implementation pointer in a handle */
+    static void set(T& t, const Impl* p) {
+        if (t.impl == p) return;
+        if (t.impl) Impl::decref(t.impl);
+        t.impl = const_cast<Impl *>(p);
+        if (t.impl) Impl::incref(t.impl);
+    }
+
+    // Helper functions to implement the ctor, dtor, copy, assign
+    static void ctor(T& t, Impl* p) { t.impl = p; if (p) Impl::incref(p); }
+    static void copy(T& t, const T& x) { if (&t == &x) return; t.impl = 0; assign(t, x); }
+    static void dtor(T& t) { if(t.impl) Impl::decref(t.impl); }
+    static T& assign(T& t, const T& x) { set(t, get(x)); return t;}
+};
+
+}} // namespace proton::reactor
+
+#endif  /*!PROTON_CPP_PRIVATEIMPL_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/src/ProtonEvent.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/ProtonEvent.cpp b/proton-c/bindings/cpp/src/ProtonEvent.cpp
new file mode 100644
index 0000000..16b92b6
--- /dev/null
+++ b/proton-c/bindings/cpp/src/ProtonEvent.cpp
@@ -0,0 +1,152 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "proton/reactor.h"
+#include "proton/event.h"
+#include "proton/link.h"
+
+#include "proton/cpp/ProtonEvent.h"
+#include "proton/cpp/ProtonHandler.h"
+#include "proton/cpp/exceptions.h"
+#include "proton/cpp/Container.h"
+
+#include "ConnectionImpl.h"
+#include "Msg.h"
+#include "contexts.h"
+
+namespace proton {
+namespace reactor {
+
+ProtonEvent::ProtonEvent(pn_event_t *ce, pn_event_type_t t, Container &c) :
+        pnEvent(ce),
+        type((int) t),
+        container(c)
+{}
+
+int ProtonEvent::getType() { return type; }
+
+pn_event_t *ProtonEvent::getPnEvent() { return pnEvent; }
+
+Container &ProtonEvent::getContainer() { return container; }
+
+Connection &ProtonEvent::getConnection() {
+    pn_connection_t *conn = pn_event_connection(getPnEvent());
+    if (!conn)
+        throw ProtonException(MSG("No connection context for this event"));
+    return ConnectionImpl::getReactorReference(conn);
+}
+
+Sender ProtonEvent::getSender() {
+    pn_link_t *lnk = pn_event_link(getPnEvent());
+    if (lnk && pn_link_is_sender(lnk))
+        return Sender(lnk);
+    throw ProtonException(MSG("No sender context for this event"));
+}
+
+Receiver ProtonEvent::getReceiver() {
+    pn_link_t *lnk = pn_event_link(getPnEvent());
+    if (lnk && pn_link_is_receiver(lnk))
+        return Receiver(lnk);
+    throw ProtonException(MSG("No receiver context for this event"));
+}
+
+Link ProtonEvent::getLink() {
+    pn_link_t *lnk = pn_event_link(getPnEvent());
+    if (lnk)
+        if (pn_link_is_sender(lnk))
+            return Sender(lnk);
+        else
+            return Receiver(lnk);
+    throw ProtonException(MSG("No link context for this event"));
+}
+
+
+
+
+void ProtonEvent::dispatch(Handler &h) {
+    ProtonHandler *handler = dynamic_cast<ProtonHandler*>(&h);
+
+    if (handler) {
+        switch(type) {
+
+        case PN_REACTOR_INIT: handler->onReactorInit(*this); break;
+        case PN_REACTOR_QUIESCED: handler->onReactorQuiesced(*this); break;
+        case PN_REACTOR_FINAL: handler->onReactorFinal(*this); break;
+
+        case PN_TIMER_TASK: handler->onTimerTask(*this); break;
+
+        case PN_CONNECTION_INIT: handler->onConnectionInit(*this); break;
+        case PN_CONNECTION_BOUND: handler->onConnectionBound(*this); break;
+        case PN_CONNECTION_UNBOUND: handler->onConnectionUnbound(*this); break;
+        case PN_CONNECTION_LOCAL_OPEN: handler->onConnectionLocalOpen(*this); break;
+        case PN_CONNECTION_LOCAL_CLOSE: handler->onConnectionLocalClose(*this); break;
+        case PN_CONNECTION_REMOTE_OPEN: handler->onConnectionRemoteOpen(*this); break;
+        case PN_CONNECTION_REMOTE_CLOSE: handler->onConnectionRemoteClose(*this); break;
+        case PN_CONNECTION_FINAL: handler->onConnectionFinal(*this); break;
+
+        case PN_SESSION_INIT: handler->onSessionInit(*this); break;
+        case PN_SESSION_LOCAL_OPEN: handler->onSessionLocalOpen(*this); break;
+        case PN_SESSION_LOCAL_CLOSE: handler->onSessionLocalClose(*this); break;
+        case PN_SESSION_REMOTE_OPEN: handler->onSessionRemoteOpen(*this); break;
+        case PN_SESSION_REMOTE_CLOSE: handler->onSessionRemoteClose(*this); break;
+        case PN_SESSION_FINAL: handler->onSessionFinal(*this); break;
+
+        case PN_LINK_INIT: handler->onLinkInit(*this); break;
+        case PN_LINK_LOCAL_OPEN: handler->onLinkLocalOpen(*this); break;
+        case PN_LINK_LOCAL_CLOSE: handler->onLinkLocalClose(*this); break;
+        case PN_LINK_LOCAL_DETACH: handler->onLinkLocalDetach(*this); break;
+        case PN_LINK_REMOTE_OPEN: handler->onLinkRemoteOpen(*this); break;
+        case PN_LINK_REMOTE_CLOSE: handler->onLinkRemoteClose(*this); break;
+        case PN_LINK_REMOTE_DETACH: handler->onLinkRemoteDetach(*this); break;
+        case PN_LINK_FLOW: handler->onLinkFlow(*this); break;
+        case PN_LINK_FINAL: handler->onLinkFinal(*this); break;
+
+        case PN_DELIVERY: handler->onDelivery(*this); break;
+
+        case PN_TRANSPORT: handler->onTransport(*this); break;
+        case PN_TRANSPORT_ERROR: handler->onTransportError(*this); break;
+        case PN_TRANSPORT_HEAD_CLOSED: handler->onTransportHeadClosed(*this); break;
+        case PN_TRANSPORT_TAIL_CLOSED: handler->onTransportTailClosed(*this); break;
+        case PN_TRANSPORT_CLOSED: handler->onTransportClosed(*this); break;
+
+        case PN_SELECTABLE_INIT: handler->onSelectableInit(*this); break;
+        case PN_SELECTABLE_UPDATED: handler->onSelectableUpdated(*this); break;
+        case PN_SELECTABLE_READABLE: handler->onSelectableReadable(*this); break;
+        case PN_SELECTABLE_WRITABLE: handler->onSelectableWritable(*this); break;
+        case PN_SELECTABLE_EXPIRED: handler->onSelectableExpired(*this); break;
+        case PN_SELECTABLE_ERROR: handler->onSelectableError(*this); break;
+        case PN_SELECTABLE_FINAL: handler->onSelectableFinal(*this); break;
+        default:
+            throw ProtonException(MSG("Invalid Proton event type " << type));
+            break;
+        }
+    } else {
+        h.onUnhandled(*this);
+    }
+
+    // recurse through children
+    for (std::vector<Handler *>::iterator child = h.childHandlersBegin();
+         child != h.childHandlersEnd(); ++child) {
+        dispatch(**child);
+    }
+}
+
+}} // namespace proton::reactor

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/src/ProtonHandler.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/ProtonHandler.cpp b/proton-c/bindings/cpp/src/ProtonHandler.cpp
new file mode 100644
index 0000000..83d9087
--- /dev/null
+++ b/proton-c/bindings/cpp/src/ProtonHandler.cpp
@@ -0,0 +1,74 @@
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/cpp/ProtonHandler.h"
+#include "proton/cpp/ProtonEvent.h"
+
+namespace proton {
+namespace reactor {
+
+ProtonHandler::ProtonHandler(){};
+
+// Everything goes to onUnhandled() unless overriden by subclass
+
+void ProtonHandler::onReactorInit(Event &e) { onUnhandled(e); }
+void ProtonHandler::onReactorQuiesced(Event &e) { onUnhandled(e); }
+void ProtonHandler::onReactorFinal(Event &e) { onUnhandled(e); }
+void ProtonHandler::onTimerTask(Event &e) { onUnhandled(e); }
+void ProtonHandler::onConnectionInit(Event &e) { onUnhandled(e); }
+void ProtonHandler::onConnectionBound(Event &e) { onUnhandled(e); }
+void ProtonHandler::onConnectionUnbound(Event &e) { onUnhandled(e); }
+void ProtonHandler::onConnectionLocalOpen(Event &e) { onUnhandled(e); }
+void ProtonHandler::onConnectionLocalClose(Event &e) { onUnhandled(e); }
+void ProtonHandler::onConnectionRemoteOpen(Event &e) { onUnhandled(e); }
+void ProtonHandler::onConnectionRemoteClose(Event &e) { onUnhandled(e); }
+void ProtonHandler::onConnectionFinal(Event &e) { onUnhandled(e); }
+void ProtonHandler::onSessionInit(Event &e) { onUnhandled(e); }
+void ProtonHandler::onSessionLocalOpen(Event &e) { onUnhandled(e); }
+void ProtonHandler::onSessionLocalClose(Event &e) { onUnhandled(e); }
+void ProtonHandler::onSessionRemoteOpen(Event &e) { onUnhandled(e); }
+void ProtonHandler::onSessionRemoteClose(Event &e) { onUnhandled(e); }
+void ProtonHandler::onSessionFinal(Event &e) { onUnhandled(e); }
+void ProtonHandler::onLinkInit(Event &e) { onUnhandled(e); }
+void ProtonHandler::onLinkLocalOpen(Event &e) { onUnhandled(e); }
+void ProtonHandler::onLinkLocalClose(Event &e) { onUnhandled(e); }
+void ProtonHandler::onLinkLocalDetach(Event &e) { onUnhandled(e); }
+void ProtonHandler::onLinkRemoteOpen(Event &e) { onUnhandled(e); }
+void ProtonHandler::onLinkRemoteClose(Event &e) { onUnhandled(e); }
+void ProtonHandler::onLinkRemoteDetach(Event &e) { onUnhandled(e); }
+void ProtonHandler::onLinkFlow(Event &e) { onUnhandled(e); }
+void ProtonHandler::onLinkFinal(Event &e) { onUnhandled(e); }
+void ProtonHandler::onDelivery(Event &e) { onUnhandled(e); }
+void ProtonHandler::onTransport(Event &e) { onUnhandled(e); }
+void ProtonHandler::onTransportError(Event &e) { onUnhandled(e); }
+void ProtonHandler::onTransportHeadClosed(Event &e) { onUnhandled(e); }
+void ProtonHandler::onTransportTailClosed(Event &e) { onUnhandled(e); }
+void ProtonHandler::onTransportClosed(Event &e) { onUnhandled(e); }
+void ProtonHandler::onSelectableInit(Event &e) { onUnhandled(e); }
+void ProtonHandler::onSelectableUpdated(Event &e) { onUnhandled(e); }
+void ProtonHandler::onSelectableReadable(Event &e) { onUnhandled(e); }
+void ProtonHandler::onSelectableWritable(Event &e) { onUnhandled(e); }
+void ProtonHandler::onSelectableExpired(Event &e) { onUnhandled(e); }
+void ProtonHandler::onSelectableError(Event &e) { onUnhandled(e); }
+void ProtonHandler::onSelectableFinal(Event &e) { onUnhandled(e); }
+
+void ProtonHandler::onUnhandled(Event &e) {}
+
+}} // namespace proton::reactor

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/src/ProtonImplRef.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/ProtonImplRef.h b/proton-c/bindings/cpp/src/ProtonImplRef.h
new file mode 100644
index 0000000..8f9f360
--- /dev/null
+++ b/proton-c/bindings/cpp/src/ProtonImplRef.h
@@ -0,0 +1,66 @@
+#ifndef PROTON_CPP_PROTONIMPL_H
+#define PROTON_CPP_PROTONIMPL_H
+
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "proton/cpp/ImportExport.h"
+#include "proton/object.h"
+
+namespace proton {
+namespace reactor {
+
+// Modified from qpid::messaging version to work without
+// boost::intrusive_ptr but integrate with Proton's pn_class_t
+// reference counting.  Thread safety currently absent but fluid in
+// intention...
+
+
+/**
+ * See PrivateImplRef.h  This is for lightly wrapped Proton pn_object_t targets.
+ * class Foo : ProtonHandle<pn_foo_t> {...}
+ */
+
+template <class T> class ProtonImplRef {
+  public:
+    typedef typename T::Impl Impl;
+
+    /** Get the implementation pointer from a handle */
+    static Impl* get(const T& t) { return t.impl; }
+
+    /** Set the implementation pointer in a handle */
+    static void set(T& t, const Impl* p) {
+        if (t.impl == p) return;
+        if (t.impl) pn_decref(t.impl);
+        t.impl = const_cast<Impl *>(p);
+        if (t.impl) pn_incref(t.impl);
+    }
+
+    // Helper functions to implement the ctor, dtor, copy, assign
+    static void ctor(T& t, Impl* p) { t.impl = p; if (p) pn_incref(p); }
+    static void copy(T& t, const T& x) { if (&t == &x) return; t.impl = 0; assign(t, x); }
+    static void dtor(T& t) { if(t.impl) pn_decref(t.impl); }
+    static T& assign(T& t, const T& x) { set(t, get(x)); return t;}
+};
+
+}} // namespace proton::reactor
+
+#endif  /*!PROTON_CPP_PROTONIMPL_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/src/Receiver.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Receiver.cpp b/proton-c/bindings/cpp/src/Receiver.cpp
new file mode 100644
index 0000000..557e736
--- /dev/null
+++ b/proton-c/bindings/cpp/src/Receiver.cpp
@@ -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.
+ *
+ */
+#include "proton/cpp/Link.h"
+#include "proton/cpp/Receiver.h"
+#include "proton/cpp/exceptions.h"
+#include "Msg.h"
+
+#include "proton/connection.h"
+#include "proton/session.h"
+#include "proton/link.h"
+
+namespace proton {
+namespace reactor {
+
+
+Receiver::Receiver(pn_link_t *lnk) : Link(lnk) {}
+Receiver::Receiver() : Link(0) {}
+
+void Receiver::verifyType(pn_link_t *lnk) {
+    if (lnk && pn_link_is_sender(lnk))
+        throw ProtonException(MSG("Creating receiver with sender context"));
+}
+
+
+}} // namespace proton::reactor

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/src/Sender.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Sender.cpp b/proton-c/bindings/cpp/src/Sender.cpp
new file mode 100644
index 0000000..74d4b0f
--- /dev/null
+++ b/proton-c/bindings/cpp/src/Sender.cpp
@@ -0,0 +1,69 @@
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/cpp/Link.h"
+#include "proton/cpp/Sender.h"
+#include "proton/cpp/exceptions.h"
+#include "Msg.h"
+#include "contexts.h"
+
+#include "proton/connection.h"
+#include "proton/session.h"
+#include "proton/link.h"
+#include "proton/types.h"
+#include "proton/codec.h"
+#include "proton/message.h"
+#include "proton/delivery.h"
+#include <stdlib.h>
+#include <string.h>
+
+namespace proton {
+namespace reactor {
+
+
+Sender::Sender(pn_link_t *lnk = 0) : Link(lnk) {}
+Sender::Sender() : Link(0) {}
+
+void Sender::verifyType(pn_link_t *lnk) {
+    if (lnk && pn_link_is_receiver(lnk))
+        throw ProtonException(MSG("Creating sender with receiver context"));
+}
+
+namespace{
+// revisit if thread safety required
+uint64_t tagCounter = 0;
+}
+
+void Sender::send(Message &message) {
+    char tag[8];
+    void *ptr = &tag;
+    uint64_t id = ++tagCounter;
+    *((uint64_t *) ptr) = id;
+    pn_delivery_t *dlv = pn_delivery(getPnLink(), pn_dtag(tag, 8));
+    std::string buf;
+    message.encode(buf);
+    pn_link_t *link = getPnLink();
+    pn_link_send(link, buf.data(), buf.size());
+    pn_link_advance(link);
+    if (pn_link_snd_settle_mode(link) == PN_SND_SETTLED)
+        pn_delivery_settle(dlv);
+}
+
+}} // namespace proton::reactor

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/src/Session.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Session.cpp b/proton-c/bindings/cpp/src/Session.cpp
new file mode 100644
index 0000000..d2b01dd
--- /dev/null
+++ b/proton-c/bindings/cpp/src/Session.cpp
@@ -0,0 +1,64 @@
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/cpp/Session.h"
+#include "contexts.h"
+
+#include "proton/connection.h"
+#include "proton/session.h"
+#include "proton/cpp/Session.h"
+#include "proton/cpp/Connection.h"
+#include "ConnectionImpl.h"
+
+namespace proton {
+namespace reactor {
+
+
+Session::Session(pn_session_t *s) : pnSession(s)
+{
+    pn_incref(pnSession);
+}
+
+Session::~Session() {
+    pn_decref(pnSession);
+}
+
+pn_session_t *Session::getPnSession() { return pnSession; }
+
+void Session::open() {
+    pn_session_open(pnSession);
+}
+
+Connection &Session::getConnection() {
+    pn_connection_t *c = pn_session_connection(pnSession);
+    return ConnectionImpl::getReactorReference(c);
+}
+
+Receiver Session::createReceiver(std::string name) {
+    pn_link_t *link = pn_receiver(pnSession, name.c_str());
+    return Receiver(link);
+}
+
+Sender Session::createSender(std::string name) {
+    pn_link_t *link = pn_sender(pnSession, name.c_str());
+    return Sender(link);
+}
+
+}} // namespace proton::reactor

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/src/Transport.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Transport.cpp b/proton-c/bindings/cpp/src/Transport.cpp
new file mode 100644
index 0000000..7f22b84
--- /dev/null
+++ b/proton-c/bindings/cpp/src/Transport.cpp
@@ -0,0 +1,39 @@
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/cpp/Transport.h"
+#include "proton/cpp/Connection.h"
+
+#include "proton/transport.h"
+
+namespace proton {
+namespace reactor {
+
+
+Transport::Transport() : connection(0), pnTransport(pn_transport()) {} ;
+
+Transport::~Transport() { pn_decref(pnTransport); }
+
+void Transport::bind(Connection &c) {
+    connection = &c;
+    pn_transport_bind(pnTransport, c.getPnConnection());
+}
+
+}} // namespace proton::reactor

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/src/Url.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Url.cpp b/proton-c/bindings/cpp/src/Url.cpp
new file mode 100644
index 0000000..058bd2f
--- /dev/null
+++ b/proton-c/bindings/cpp/src/Url.cpp
@@ -0,0 +1,77 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "proton/cpp/exceptions.h"
+#include "Url.h"
+#include "ProtonImplRef.h"
+#include "Msg.h"
+
+namespace proton {
+namespace reactor {
+
+template class ProtonHandle<pn_url_t>;
+typedef ProtonImplRef<Url> PI;
+
+
+Url::Url(const std::string &url) {
+    pn_url_t *up = pn_url_parse(url.c_str());
+    // refcount is 1, no need to incref
+    if (!up)
+        throw ProtonException(MSG("invalid URL: " << url));
+    impl = up;
+}
+
+Url::~Url() { PI::dtor(*this); }
+
+Url::Url(const Url& c) : ProtonHandle<pn_url_t>() {
+    PI::copy(*this, c);
+}
+
+Url& Url::operator=(const Url& c) {
+    return PI::assign(*this, c);
+}
+
+std::string Url::getPort() {
+    const char *p = pn_url_get_port(impl);
+    if (!p)
+        return std::string("5672");
+    else
+        return std::string(p);
+}
+
+std::string Url::getHost() {
+    const char *p = pn_url_get_host(impl);
+    if (!p)
+        return std::string("0.0.0.0");
+    else
+        return std::string(p);
+}
+
+std::string Url::getPath() {
+    const char *p = pn_url_get_path(impl);
+    if (!p)
+        return std::string("");
+    else
+        return std::string(p);
+}
+
+
+}} // namespace proton::reactor

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/src/Url.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Url.h b/proton-c/bindings/cpp/src/Url.h
new file mode 100644
index 0000000..042ab45
--- /dev/null
+++ b/proton-c/bindings/cpp/src/Url.h
@@ -0,0 +1,49 @@
+#ifndef PROTON_CPP_URL_H
+#define PROTON_CPP_URL_H
+
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/cpp/ImportExport.h"
+#include "proton/cpp/ProtonHandle.h"
+#include "proton/url.h"
+#include <string>
+
+namespace proton {
+namespace reactor {
+
+class Url : public ProtonHandle<pn_url_t>
+{
+  public:
+    PROTON_CPP_EXTERN Url(const std::string &url);
+    PROTON_CPP_EXTERN ~Url();
+    PROTON_CPP_EXTERN Url(const Url&);
+    PROTON_CPP_EXTERN Url& operator=(const Url&);
+    PROTON_CPP_EXTERN std::string getHost();
+    PROTON_CPP_EXTERN std::string getPort();
+    PROTON_CPP_EXTERN std::string getPath();
+  private:
+    friend class ProtonImplRef<Url>;
+};
+
+
+}} // namespace proton::reactor
+
+#endif  /*!PROTON_CPP_URL_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/src/contexts.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/contexts.cpp b/proton-c/bindings/cpp/src/contexts.cpp
new file mode 100644
index 0000000..b1dec49
--- /dev/null
+++ b/proton-c/bindings/cpp/src/contexts.cpp
@@ -0,0 +1,92 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "contexts.h"
+#include "proton/cpp/exceptions.h"
+#include "Msg.h"
+#include "proton/object.h"
+#include "proton/session.h"
+#include "proton/link.h"
+
+PN_HANDLE(PNI_CPP_CONNECTION_CONTEXT)
+PN_HANDLE(PNI_CPP_SESSION_CONTEXT)
+PN_HANDLE(PNI_CPP_LINK_CONTEXT)
+PN_HANDLE(PNI_CPP_CONTAINER_CONTEXT)
+
+namespace proton {
+namespace reactor {
+
+void setConnectionContext(pn_connection_t *pnConnection, ConnectionImpl *connection) {
+    pn_record_t *record = pn_connection_attachments(pnConnection);
+    pn_record_def(record, PNI_CPP_CONNECTION_CONTEXT, PN_VOID);
+    pn_record_set(record, PNI_CPP_CONNECTION_CONTEXT, connection);
+}
+
+ConnectionImpl *getConnectionContext(pn_connection_t *pnConnection) {
+    if (!pnConnection) return NULL;
+    pn_record_t *record = pn_connection_attachments(pnConnection);
+    ConnectionImpl *p = (ConnectionImpl *) pn_record_get(record, PNI_CPP_CONNECTION_CONTEXT);
+    return p;
+}
+
+
+void setSessionContext(pn_session_t *pnSession, Session *session) {
+    pn_record_t *record = pn_session_attachments(pnSession);
+    pn_record_def(record, PNI_CPP_SESSION_CONTEXT, PN_VOID);
+    pn_record_set(record, PNI_CPP_SESSION_CONTEXT, session);
+}
+
+Session *getSessionContext(pn_session_t *pnSession) {
+    if (!pnSession) return NULL;
+    pn_record_t *record = pn_session_attachments(pnSession);
+    Session *p = (Session *) pn_record_get(record, PNI_CPP_SESSION_CONTEXT);
+    return p;
+}
+
+
+void setLinkContext(pn_link_t *pnLink, Link *link) {
+    pn_record_t *record = pn_link_attachments(pnLink);
+    pn_record_def(record, PNI_CPP_LINK_CONTEXT, PN_VOID);
+    pn_record_set(record, PNI_CPP_LINK_CONTEXT, link);
+}
+
+Link *getLinkContext(pn_link_t *pnLink) {
+    if (!pnLink) return NULL;
+    pn_record_t *record = pn_link_attachments(pnLink);
+    Link *p = (Link *) pn_record_get(record, PNI_CPP_LINK_CONTEXT);
+    return p;
+}
+
+
+void setContainerContext(pn_reactor_t *pnReactor, ContainerImpl *container) {
+    pn_record_t *record = pn_reactor_attachments(pnReactor);
+    pn_record_def(record, PNI_CPP_CONTAINER_CONTEXT, PN_VOID);
+    pn_record_set(record, PNI_CPP_CONTAINER_CONTEXT, container);
+}
+
+ContainerImpl *getContainerContext(pn_reactor_t *pnReactor) {
+    pn_record_t *record = pn_reactor_attachments(pnReactor);
+    ContainerImpl *p = (ContainerImpl *) pn_record_get(record, PNI_CPP_CONTAINER_CONTEXT);
+    if (!p) throw ProtonException(MSG("Reactor has no C++ container context"));
+    return p;
+}
+
+}} // namespace proton::reactor

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/src/contexts.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/contexts.h b/proton-c/bindings/cpp/src/contexts.h
new file mode 100644
index 0000000..c04a77a
--- /dev/null
+++ b/proton-c/bindings/cpp/src/contexts.h
@@ -0,0 +1,48 @@
+#ifndef PROTON_CPP_CONTEXTS_H
+#define PROTON_CPP_CONTEXTS_H
+
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/reactor.h"
+#include "proton/connection.h"
+
+namespace proton {
+namespace reactor {
+
+class ConnectionImpl;
+void setConnectionContext(pn_connection_t *pnConnection, ConnectionImpl *connection);
+ConnectionImpl *getConnectionContext(pn_connection_t *pnConnection);
+
+class Session;
+void setSessionContext(pn_session_t *pnSession, Session *session);
+Session *getSessionContext(pn_session_t *pnSession);
+
+class Link;
+void setLinkContext(pn_link_t *pnLink, Link *link);
+Link *getLinkContext(pn_link_t *pnLink);
+
+class ContainerImpl;
+void setContainerContext(pn_reactor_t *pnReactor, ContainerImpl *container);
+ContainerImpl *getContainerContext(pn_reactor_t *pnReactor);
+
+}} // namespace proton::reactor
+
+#endif  /*!PROTON_CPP_CONTEXTS_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/src/exceptions.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/exceptions.cpp b/proton-c/bindings/cpp/src/exceptions.cpp
new file mode 100644
index 0000000..c19e61d
--- /dev/null
+++ b/proton-c/bindings/cpp/src/exceptions.cpp
@@ -0,0 +1,33 @@
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/cpp/exceptions.h"
+
+namespace proton {
+namespace reactor {
+
+ProtonException::ProtonException(const std::string& msg) throw() : message(msg) {}
+ProtonException::~ProtonException() throw() {}
+const char* ProtonException::what() const throw() { return message.c_str(); }
+
+MessageReject::MessageReject(const std::string& msg) throw() : ProtonException(msg) {}
+MessageRelease::MessageRelease(const std::string& msg) throw() : ProtonException(msg) {}
+
+}} // namespace proton::reactor

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/src/platform.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/platform.cpp b/proton-c/bindings/cpp/src/platform.cpp
new file mode 100644
index 0000000..4eac408
--- /dev/null
+++ b/proton-c/bindings/cpp/src/platform.cpp
@@ -0,0 +1,79 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "platform.h"
+#include <string>
+
+// Copy neccesary platform neutral functionality from Proton-C
+// TODO: make this sensibly maintainable (even though it is mostly static)
+
+#ifdef USE_UUID_GENERATE
+#include <uuid/uuid.h>
+#include <stdlib.h>
+char* pn_i_genuuid(void) {
+    char *generated = (char *) malloc(37*sizeof(char));
+    uuid_t uuid;
+    uuid_generate(uuid);
+    uuid_unparse(uuid, generated);
+    return generated;
+}
+#elif USE_UUID_CREATE
+#include <uuid.h>
+char* pn_i_genuuid(void) {
+    char *generated;
+    uuid_t uuid;
+    uint32_t rc;
+    uuid_create(&uuid, &rc);
+    // Under FreeBSD the returned string is newly allocated from the heap
+    uuid_to_string(&uuid, &generated, &rc);
+    return generated;
+}
+#elif USE_WIN_UUID
+#include <rpc.h>
+char* pn_i_genuuid(void) {
+    unsigned char *generated;
+    UUID uuid;
+    UuidCreate(&uuid);
+    UuidToString(&uuid, &generated);
+    char* r = pn_strdup((const char*)generated);
+    RpcStringFree(&generated);
+    return r;
+}
+#else
+#error "Don't know how to generate uuid strings on this platform"
+#endif
+
+
+
+namespace proton {
+namespace reactor {
+
+// include Proton-c platform routines into a local namespace
+
+
+std::string generateUuid() {
+    char *s = pn_i_genuuid();
+    std::string url(s);
+    free(s);
+    return url;
+}
+
+}} // namespace proton::reactor

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/src/platform.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/platform.h b/proton-c/bindings/cpp/src/platform.h
new file mode 100644
index 0000000..5e5b726
--- /dev/null
+++ b/proton-c/bindings/cpp/src/platform.h
@@ -0,0 +1,39 @@
+#ifndef PROTON_CPP_PLATFORM_H
+#define PROTON_CPP_PLATFORM_H
+
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "proton/cpp/ProtonHandler.h"
+#include "proton/event.h"
+#include "proton/reactor.h"
+#include <string>
+
+
+namespace proton {
+namespace reactor {
+
+std::string generateUuid();
+// Todo: TimeNow();
+
+}} // namespace proton::reactor
+
+#endif  /*!PROTON_CPP_PLATFORM_H*/


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


[39/50] [abbrv] qpid-proton git commit: NO-JIRA: integrate tutorial generation with the docs target from the main build

Posted by ac...@apache.org.
NO-JIRA: integrate tutorial generation with the docs target from the main build


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/26a0622c
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/26a0622c
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/26a0622c

Branch: refs/heads/cjansen-cpp-client
Commit: 26a0622c0b2977f2c02d5acbccc06e0cf5c3d089
Parents: 0b7718c
Author: Gordon Sim <gs...@redhat.com>
Authored: Wed May 27 11:38:53 2015 +0100
Committer: Gordon Sim <gs...@redhat.com>
Committed: Wed May 27 11:39:46 2015 +0100

----------------------------------------------------------------------
 proton-c/bindings/python/CMakeLists.txt         |  12 +
 proton-c/bindings/python/docs/Makefile          | 153 ----------
 proton-c/bindings/python/docs/README            |   5 -
 proton-c/bindings/python/docs/conf.py           | 242 +++++++++++++++
 proton-c/bindings/python/docs/index.rst         |  11 +
 proton-c/bindings/python/docs/make.bat          | 190 ------------
 proton-c/bindings/python/docs/overview.rst      | 160 ++++++++++
 proton-c/bindings/python/docs/source/conf.py    | 242 ---------------
 proton-c/bindings/python/docs/source/index.rst  |  24 --
 .../bindings/python/docs/source/overview.rst    | 161 ----------
 .../bindings/python/docs/source/reference.rst   |  44 ---
 .../bindings/python/docs/source/tutorial.rst    | 301 -------------------
 proton-c/bindings/python/docs/tutorial.rst      | 301 +++++++++++++++++++
 13 files changed, 726 insertions(+), 1120 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/26a0622c/proton-c/bindings/python/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/CMakeLists.txt b/proton-c/bindings/python/CMakeLists.txt
index 2886326..4f15aac 100644
--- a/proton-c/bindings/python/CMakeLists.txt
+++ b/proton-c/bindings/python/CMakeLists.txt
@@ -94,6 +94,18 @@ if (EPYDOC_EXE)
            ${OPTIONAL_ARG})
 endif (EPYDOC_EXE)
 
+find_program(SPHINX_EXE sphinx-build)
+mark_as_advanced (SPHINX_EXE)
+if (SPHINX_EXE)
+   add_custom_target(tutorial-py COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/../../env.py --
+     PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}:${CMAKE_CURRENT_SOURCE_DIR}
+     ${SPHINX_EXE} -b html ${CMAKE_CURRENT_SOURCE_DIR}/docs ${CMAKE_CURRENT_BINARY_DIR}/tutorial)
+   add_dependencies(docs tutorial-py)
+   install(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/tutorial/"
+           DESTINATION "${PROTON_SHARE}/docs/tutorial-py"
+           COMPONENT documentation)
+endif (SPHINX_EXE)
+
 install(FILES ${CPROTON_ARTIFACTS}
         DESTINATION ${PYTHON_SITEARCH_PACKAGES}
         COMPONENT Python)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/26a0622c/proton-c/bindings/python/docs/Makefile
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/docs/Makefile b/proton-c/bindings/python/docs/Makefile
deleted file mode 100644
index d6c6886..0000000
--- a/proton-c/bindings/python/docs/Makefile
+++ /dev/null
@@ -1,153 +0,0 @@
-# Makefile for Sphinx documentation
-#
-
-# You can set these variables from the command line.
-SPHINXOPTS    =
-SPHINXBUILD   = sphinx-build
-PAPER         =
-BUILDDIR      = build
-
-# Internal variables.
-PAPEROPT_a4     = -D latex_paper_size=a4
-PAPEROPT_letter = -D latex_paper_size=letter
-ALLSPHINXOPTS   = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
-# the i18n builder cannot share the environment and doctrees with the others
-I18NSPHINXOPTS  = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
-
-.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
-
-help:
-	@echo "Please use \`make <target>' where <target> is one of"
-	@echo "  html       to make standalone HTML files"
-	@echo "  dirhtml    to make HTML files named index.html in directories"
-	@echo "  singlehtml to make a single large HTML file"
-	@echo "  pickle     to make pickle files"
-	@echo "  json       to make JSON files"
-	@echo "  htmlhelp   to make HTML files and a HTML help project"
-	@echo "  qthelp     to make HTML files and a qthelp project"
-	@echo "  devhelp    to make HTML files and a Devhelp project"
-	@echo "  epub       to make an epub"
-	@echo "  latex      to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
-	@echo "  latexpdf   to make LaTeX files and run them through pdflatex"
-	@echo "  text       to make text files"
-	@echo "  man        to make manual pages"
-	@echo "  texinfo    to make Texinfo files"
-	@echo "  info       to make Texinfo files and run them through makeinfo"
-	@echo "  gettext    to make PO message catalogs"
-	@echo "  changes    to make an overview of all changed/added/deprecated items"
-	@echo "  linkcheck  to check all external links for integrity"
-	@echo "  doctest    to run all doctests embedded in the documentation (if enabled)"
-
-clean:
-	-rm -rf $(BUILDDIR)/*
-
-html:
-	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
-	@echo
-	@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
-
-dirhtml:
-	$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
-	@echo
-	@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
-
-singlehtml:
-	$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
-	@echo
-	@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
-
-pickle:
-	$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
-	@echo
-	@echo "Build finished; now you can process the pickle files."
-
-json:
-	$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
-	@echo
-	@echo "Build finished; now you can process the JSON files."
-
-htmlhelp:
-	$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
-	@echo
-	@echo "Build finished; now you can run HTML Help Workshop with the" \
-	      ".hhp project file in $(BUILDDIR)/htmlhelp."
-
-qthelp:
-	$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
-	@echo
-	@echo "Build finished; now you can run "qcollectiongenerator" with the" \
-	      ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
-	@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/ApacheQpidProton.qhcp"
-	@echo "To view the help file:"
-	@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/ApacheQpidProton.qhc"
-
-devhelp:
-	$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
-	@echo
-	@echo "Build finished."
-	@echo "To view the help file:"
-	@echo "# mkdir -p $$HOME/.local/share/devhelp/ApacheQpidProton"
-	@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/ApacheQpidProton"
-	@echo "# devhelp"
-
-epub:
-	$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
-	@echo
-	@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
-
-latex:
-	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
-	@echo
-	@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
-	@echo "Run \`make' in that directory to run these through (pdf)latex" \
-	      "(use \`make latexpdf' here to do that automatically)."
-
-latexpdf:
-	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
-	@echo "Running LaTeX files through pdflatex..."
-	$(MAKE) -C $(BUILDDIR)/latex all-pdf
-	@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
-
-text:
-	$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
-	@echo
-	@echo "Build finished. The text files are in $(BUILDDIR)/text."
-
-man:
-	$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
-	@echo
-	@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
-
-texinfo:
-	$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
-	@echo
-	@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
-	@echo "Run \`make' in that directory to run these through makeinfo" \
-	      "(use \`make info' here to do that automatically)."
-
-info:
-	$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
-	@echo "Running Texinfo files through makeinfo..."
-	make -C $(BUILDDIR)/texinfo info
-	@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
-
-gettext:
-	$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
-	@echo
-	@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
-
-changes:
-	$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
-	@echo
-	@echo "The overview file is in $(BUILDDIR)/changes."
-
-linkcheck:
-	$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
-	@echo
-	@echo "Link check complete; look for any errors in the above output " \
-	      "or in $(BUILDDIR)/linkcheck/output.txt."
-
-doctest:
-	$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
-	@echo "Testing of doctests in the sources finished, look at the " \
-	      "results in $(BUILDDIR)/doctest/output.txt."

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/26a0622c/proton-c/bindings/python/docs/README
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/docs/README b/proton-c/bindings/python/docs/README
deleted file mode 100644
index a8eeeec..0000000
--- a/proton-c/bindings/python/docs/README
+++ /dev/null
@@ -1,5 +0,0 @@
-Note: The generation of the documentation is not yet hooked into the
-overall build. The docs are based on shpinx which you will need to
-have installed. To build the docs you also need to have the proton lib
-on your PYTHONPATH. Then simply run `make html` and the html files are
-generated under build here.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/26a0622c/proton-c/bindings/python/docs/conf.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/docs/conf.py b/proton-c/bindings/python/docs/conf.py
new file mode 100644
index 0000000..4c76753
--- /dev/null
+++ b/proton-c/bindings/python/docs/conf.py
@@ -0,0 +1,242 @@
+# -*- coding: utf-8 -*-
+#
+# Apache Qpid Proton documentation build configuration file, created by
+# sphinx-quickstart on Mon Feb 16 14:13:09 2015.
+#
+# This file is execfile()d with the current directory set to its containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+import sys, os
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+#sys.path.insert(0, os.path.abspath('.'))
+
+# -- General configuration -----------------------------------------------------
+
+# If your documentation needs a minimal Sphinx version, state it here.
+#needs_sphinx = '1.0'
+
+# Add any Sphinx extension module names here, as strings. They can be extensions
+# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
+extensions = ['sphinx.ext.autodoc', 'sphinx.ext.todo']
+
+# Add any paths that contain templates here, relative to this directory.
+#templates_path = ['_templates']
+
+# The suffix of source filenames.
+source_suffix = '.rst'
+
+# The encoding of source files.
+#source_encoding = 'utf-8-sig'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = u'Apache Qpid Proton'
+copyright = u'2015, Apache Qpid'
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The short X.Y version.
+version = '0.10'
+# The full version, including alpha/beta/rc tags.
+release = '0.10'
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+#today_fmt = '%B %d, %Y'
+
+# List of patterns, relative to source directory, that match files and
+# directories to ignore when looking for source files.
+exclude_patterns = []
+
+# The reST default role (used for this markup: `text`) to use for all documents.
+#default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+#add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# A list of ignored prefixes for module index sorting.
+#modindex_common_prefix = []
+
+
+# -- Options for HTML output ---------------------------------------------------
+
+# The theme to use for HTML and HTML Help pages.  See the documentation for
+# a list of builtin themes.
+html_theme = 'sphinxdoc'
+
+# Theme options are theme-specific and customize the look and feel of a theme
+# further.  For a list of options available for each theme, see the
+# documentation.
+#html_theme_options = {}
+
+# Add any paths that contain custom themes here, relative to this directory.
+#html_theme_path = []
+
+# The name for this set of Sphinx documents.  If None, it defaults to
+# "<project> v<release> documentation".
+#html_title = None
+
+# A shorter title for the navigation bar.  Default is the same as html_title.
+#html_short_title = None
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+#html_logo = None
+
+# The name of an image file (within the static path) to use as favicon of the
+# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+#html_favicon = None
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+#html_static_path = ['_static']
+
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+# using the given strftime format.
+#html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+#html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#html_sidebars = {}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+#html_additional_pages = {}
+
+# If false, no module index is generated.
+#html_domain_indices = True
+
+# If false, no index is generated.
+#html_use_index = True
+
+# If true, the index is split into individual pages for each letter.
+#html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+#html_show_sourcelink = True
+
+# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
+#html_show_sphinx = True
+
+# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
+#html_show_copyright = True
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a <link> tag referring to it.  The value of this option must be the
+# base URL from which the finished HTML is served.
+#html_use_opensearch = ''
+
+# This is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = None
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'ApacheQpidProtondoc'
+
+
+# -- Options for LaTeX output --------------------------------------------------
+
+latex_elements = {
+# The paper size ('letterpaper' or 'a4paper').
+#'papersize': 'letterpaper',
+
+# The font size ('10pt', '11pt' or '12pt').
+#'pointsize': '10pt',
+
+# Additional stuff for the LaTeX preamble.
+#'preamble': '',
+}
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title, author, documentclass [howto/manual]).
+latex_documents = [
+  ('index', 'ApacheQpidProton.tex', u'Apache Qpid Proton Documentation',
+   u'The Apache Qpid Community', 'manual'),
+]
+
+# The name of an image file (relative to this directory) to place at the top of
+# the title page.
+#latex_logo = None
+
+# For "manual" documents, if this is true, then toplevel headings are parts,
+# not chapters.
+#latex_use_parts = False
+
+# If true, show page references after internal links.
+#latex_show_pagerefs = False
+
+# If true, show URL addresses after external links.
+#latex_show_urls = False
+
+# Documents to append as an appendix to all manuals.
+#latex_appendices = []
+
+# If false, no module index is generated.
+#latex_domain_indices = True
+
+
+# -- Options for manual page output --------------------------------------------
+
+# One entry per manual page. List of tuples
+# (source start file, name, description, authors, manual section).
+man_pages = [
+    ('index', 'apacheqpidproton', u'Apache Qpid Proton Documentation',
+     [u'The Apache Qpid Community'], 1)
+]
+
+# If true, show URL addresses after external links.
+#man_show_urls = False
+
+
+# -- Options for Texinfo output ------------------------------------------------
+
+# Grouping the document tree into Texinfo files. List of tuples
+# (source start file, target name, title, author,
+#  dir menu entry, description, category)
+texinfo_documents = [
+  ('index', 'ApacheQpidProton', u'Apache Qpid Proton Documentation',
+   u'The Apache Qpid Community', 'ApacheQpidProton', 'One line description of project.',
+   'Miscellaneous'),
+]
+
+# Documents to append as an appendix to all manuals.
+#texinfo_appendices = []
+
+# If false, no module index is generated.
+#texinfo_domain_indices = True
+
+# How to display URL addresses: 'footnote', 'no', or 'inline'.
+#texinfo_show_urls = 'footnote'

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/26a0622c/proton-c/bindings/python/docs/index.rst
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/docs/index.rst b/proton-c/bindings/python/docs/index.rst
new file mode 100644
index 0000000..927762b
--- /dev/null
+++ b/proton-c/bindings/python/docs/index.rst
@@ -0,0 +1,11 @@
+Apache Qpid Proton: python documentation
+========================================
+
+Contents:
+
+.. toctree::
+   :maxdepth: 2
+
+   tutorial
+   overview
+

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/26a0622c/proton-c/bindings/python/docs/make.bat
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/docs/make.bat b/proton-c/bindings/python/docs/make.bat
deleted file mode 100644
index e3c7209..0000000
--- a/proton-c/bindings/python/docs/make.bat
+++ /dev/null
@@ -1,190 +0,0 @@
-@ECHO OFF
-
-REM Command file for Sphinx documentation
-
-if "%SPHINXBUILD%" == "" (
-	set SPHINXBUILD=sphinx-build
-)
-set BUILDDIR=build
-set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% source
-set I18NSPHINXOPTS=%SPHINXOPTS% source
-if NOT "%PAPER%" == "" (
-	set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
-	set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS%
-)
-
-if "%1" == "" goto help
-
-if "%1" == "help" (
-	:help
-	echo.Please use `make ^<target^>` where ^<target^> is one of
-	echo.  html       to make standalone HTML files
-	echo.  dirhtml    to make HTML files named index.html in directories
-	echo.  singlehtml to make a single large HTML file
-	echo.  pickle     to make pickle files
-	echo.  json       to make JSON files
-	echo.  htmlhelp   to make HTML files and a HTML help project
-	echo.  qthelp     to make HTML files and a qthelp project
-	echo.  devhelp    to make HTML files and a Devhelp project
-	echo.  epub       to make an epub
-	echo.  latex      to make LaTeX files, you can set PAPER=a4 or PAPER=letter
-	echo.  text       to make text files
-	echo.  man        to make manual pages
-	echo.  texinfo    to make Texinfo files
-	echo.  gettext    to make PO message catalogs
-	echo.  changes    to make an overview over all changed/added/deprecated items
-	echo.  linkcheck  to check all external links for integrity
-	echo.  doctest    to run all doctests embedded in the documentation if enabled
-	goto end
-)
-
-if "%1" == "clean" (
-	for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
-	del /q /s %BUILDDIR%\*
-	goto end
-)
-
-if "%1" == "html" (
-	%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
-	if errorlevel 1 exit /b 1
-	echo.
-	echo.Build finished. The HTML pages are in %BUILDDIR%/html.
-	goto end
-)
-
-if "%1" == "dirhtml" (
-	%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
-	if errorlevel 1 exit /b 1
-	echo.
-	echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
-	goto end
-)
-
-if "%1" == "singlehtml" (
-	%SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml
-	if errorlevel 1 exit /b 1
-	echo.
-	echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml.
-	goto end
-)
-
-if "%1" == "pickle" (
-	%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
-	if errorlevel 1 exit /b 1
-	echo.
-	echo.Build finished; now you can process the pickle files.
-	goto end
-)
-
-if "%1" == "json" (
-	%SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
-	if errorlevel 1 exit /b 1
-	echo.
-	echo.Build finished; now you can process the JSON files.
-	goto end
-)
-
-if "%1" == "htmlhelp" (
-	%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
-	if errorlevel 1 exit /b 1
-	echo.
-	echo.Build finished; now you can run HTML Help Workshop with the ^
-.hhp project file in %BUILDDIR%/htmlhelp.
-	goto end
-)
-
-if "%1" == "qthelp" (
-	%SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
-	if errorlevel 1 exit /b 1
-	echo.
-	echo.Build finished; now you can run "qcollectiongenerator" with the ^
-.qhcp project file in %BUILDDIR%/qthelp, like this:
-	echo.^> qcollectiongenerator %BUILDDIR%\qthelp\ApacheQpidProton.qhcp
-	echo.To view the help file:
-	echo.^> assistant -collectionFile %BUILDDIR%\qthelp\ApacheQpidProton.ghc
-	goto end
-)
-
-if "%1" == "devhelp" (
-	%SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp
-	if errorlevel 1 exit /b 1
-	echo.
-	echo.Build finished.
-	goto end
-)
-
-if "%1" == "epub" (
-	%SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub
-	if errorlevel 1 exit /b 1
-	echo.
-	echo.Build finished. The epub file is in %BUILDDIR%/epub.
-	goto end
-)
-
-if "%1" == "latex" (
-	%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
-	if errorlevel 1 exit /b 1
-	echo.
-	echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
-	goto end
-)
-
-if "%1" == "text" (
-	%SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text
-	if errorlevel 1 exit /b 1
-	echo.
-	echo.Build finished. The text files are in %BUILDDIR%/text.
-	goto end
-)
-
-if "%1" == "man" (
-	%SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man
-	if errorlevel 1 exit /b 1
-	echo.
-	echo.Build finished. The manual pages are in %BUILDDIR%/man.
-	goto end
-)
-
-if "%1" == "texinfo" (
-	%SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo
-	if errorlevel 1 exit /b 1
-	echo.
-	echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo.
-	goto end
-)
-
-if "%1" == "gettext" (
-	%SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale
-	if errorlevel 1 exit /b 1
-	echo.
-	echo.Build finished. The message catalogs are in %BUILDDIR%/locale.
-	goto end
-)
-
-if "%1" == "changes" (
-	%SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
-	if errorlevel 1 exit /b 1
-	echo.
-	echo.The overview file is in %BUILDDIR%/changes.
-	goto end
-)
-
-if "%1" == "linkcheck" (
-	%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
-	if errorlevel 1 exit /b 1
-	echo.
-	echo.Link check complete; look for any errors in the above output ^
-or in %BUILDDIR%/linkcheck/output.txt.
-	goto end
-)
-
-if "%1" == "doctest" (
-	%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
-	if errorlevel 1 exit /b 1
-	echo.
-	echo.Testing of doctests in the sources finished, look at the ^
-results in %BUILDDIR%/doctest/output.txt.
-	goto end
-)
-
-:end

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/26a0622c/proton-c/bindings/python/docs/overview.rst
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/docs/overview.rst b/proton-c/bindings/python/docs/overview.rst
new file mode 100644
index 0000000..f82deb2
--- /dev/null
+++ b/proton-c/bindings/python/docs/overview.rst
@@ -0,0 +1,160 @@
+############
+API Overview
+############
+
+=========================
+An overview of the model
+=========================
+
+Messages are transferred between connected peers over 'links'. At the
+sending peer the link is called a sender. At the receiving peer it is
+called a receiver. Messages are sent by senders and received by
+receivers. Links may have named 'source' and 'target' addresses (for
+example to identify the queue from which message were to be received
+or to which they were to be sent).
+
+Links are established over sessions. Sessions are established over
+connections. Connections are (generally) established between two
+uniquely identified containers. Though a connection can have multiple
+sessions, often this is not needed. The container API allows you to
+ignore sessions unless you actually require them.
+
+The sending of a message over a link is called a delivery. The message
+is the content sent, including all meta-data such as headers and
+annotations. The delivery is the protocol exchange associated with the
+transfer of that content.
+
+To indicate that a delivery is complete, either the sender or the
+receiver 'settles' it. When the other side learns that it has been
+settled, they will no longer communicate about that delivery. The
+receiver can also indicate whether they accept or reject the
+message.
+
+Three different delivery levels or 'guarantees' can be achieved:
+at-most-once, at-least-once or exactly-once. See
+:ref:`delivery-guarantees` for more detail.
+
+=======================================================
+A summary of the most commonly used classes and members
+=======================================================
+
+A brief summary of some of the key classes follows.
+
+The :py:class:`~proton.reactor.Container` class is a convenient entry
+point into the API, allowing connections and links to be
+established. Applications are structured as one or more event
+handlers. Handlers can be set at Container, Connection, or Link
+scope. Messages are sent by establishing an approprate sender and
+invoking its :py:meth:`~proton.Sender.send()` method. This is
+typically done when the sender is sendable, a condition indicated by
+the :py:meth:`~proton.handlers.MessagingHandler.on_sendable()` event, to
+avoid execessive build up of messages. Messages can be received by
+establishing an appropriate receiver and handling the
+:py:meth:`~proton.handlers.MessagingHandler.on_message()` event.
+
+.. autoclass:: proton.reactor.Container
+    :show-inheritance: proton.reactor.Reactor
+    :members: connect, create_receiver, create_sender, run, schedule
+    :undoc-members:
+
+    .. py:attribute:: container_id
+
+       The identifier used to identify this container in any
+       connections it establishes. Container names should be
+       unique. By default a UUID will be used.
+
+    The :py:meth:`~proton.reactor.Container.connect()` method returns
+    an instance of :py:class:`~proton.Connection`, the
+    :py:meth:`~proton.reactor.Container.create_receiver()` method
+    returns an instance of :py:class:`~proton.Receiver` and the
+    :py:meth:`~proton.reactor.Container.create_sender()` method
+    returns an instance of :py:class:`~proton.Sender`.
+
+.. autoclass:: proton.Connection
+    :members: open, close, state, session, hostname, container,
+              remote_container, remote_desired_capabilities, remote_hostname, remote_offered_capabilities , remote_properties
+    :undoc-members:
+
+.. autoclass:: proton.Receiver
+    :show-inheritance: proton.Link
+    :members: flow, recv, drain, draining
+    :undoc-members:
+
+.. autoclass:: proton.Sender
+    :show-inheritance: proton.Link
+    :members: offered, send
+    :undoc-members:
+
+.. autoclass:: proton.Link
+    :members: name, state, is_sender, is_receiver,
+              credit, queued, session, connection,
+              source, target, remote_source, remote_target
+    :undoc-members:
+
+    The :py:meth:`~proton.Link.source()`,
+    :py:meth:`~proton.Link.target()`,
+    :py:meth:`~proton.Link.remote_source()` and
+    :py:meth:`~proton.Link.remote_target()` methods all return an
+    instance of :py:class:`~proton.Terminus`.
+
+
+.. autoclass:: proton.Delivery
+    :members: update, settle, settled, remote_state, local_state, partial, readable, writable,
+              link, session, connection
+    :undoc-members:
+
+.. autoclass:: proton.handlers.MessagingHandler
+    :members: on_start, on_reactor_init,
+              on_message,
+              on_accepted,
+              on_rejected,
+              on_settled,
+              on_sendable,
+              on_connection_error,
+              on_link_error,
+              on_session_error,
+              on_disconnected,
+              accept, reject, release, settle
+    :undoc-members:
+
+.. autoclass:: proton.Event
+    :members: delivery, link, receiver, sender, session, connection, reactor, context
+    :undoc-members:
+
+.. autoclass:: proton.Message
+    :members: address, id, priority, subject, ttl, reply_to, correlation_id, durable, user_id,
+              content_type, content_encoding, creation_time, expiry_time, delivery_count, first_acquirer,
+              group_id, group_sequence, reply_to_group_id,
+              send, recv, encode, decode
+    :undoc-members:
+
+.. autoclass:: proton.Terminus
+    :members: address, dynamic, properties, capabilities, filter
+    :undoc-members:
+
+.. _delivery-guarantees:
+
+===================
+Delivery guarantees
+===================
+
+For at-most-once, the sender settles the message as soon as it sends
+it. If the connection is lost before the message is received by the
+receiver, the message will not be delivered.
+
+For at-least-once, the receiver accepts and settles the message on
+receipt. If the connection is lost before the sender is informed of
+the settlement, then the delivery is considered in-doubt and should be
+retried. This will ensure it eventually gets delivered (provided of
+course the connection and link can be reestablished). It may mean that
+it is delivered multiple times though.
+
+Finally, for exactly-once, the receiver accepts the message but
+doesn't settle it. The sender settles once it is aware that the
+receiver accepted it. In this way the receiver retains knowledge of an
+accepted message until it is sure the sender knows it has been
+accepted. If the connection is lost before settlement, the receiver
+informs the sender of all the unsettled deliveries it knows about, and
+from this the sender can deduce which need to be redelivered. The
+sender likewise informs the receiver which deliveries it knows about,
+from which the receiver can deduce which have already been settled.

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/26a0622c/proton-c/bindings/python/docs/source/conf.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/docs/source/conf.py b/proton-c/bindings/python/docs/source/conf.py
deleted file mode 100644
index 206ef89..0000000
--- a/proton-c/bindings/python/docs/source/conf.py
+++ /dev/null
@@ -1,242 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Apache Qpid Proton documentation build configuration file, created by
-# sphinx-quickstart on Mon Feb 16 14:13:09 2015.
-#
-# This file is execfile()d with the current directory set to its containing dir.
-#
-# Note that not all possible configuration values are present in this
-# autogenerated file.
-#
-# All configuration values have a default; values that are commented out
-# serve to show the default.
-
-import sys, os
-
-# If extensions (or modules to document with autodoc) are in another directory,
-# add these directories to sys.path here. If the directory is relative to the
-# documentation root, use os.path.abspath to make it absolute, like shown here.
-#sys.path.insert(0, os.path.abspath('.'))
-
-# -- General configuration -----------------------------------------------------
-
-# If your documentation needs a minimal Sphinx version, state it here.
-#needs_sphinx = '1.0'
-
-# Add any Sphinx extension module names here, as strings. They can be extensions
-# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
-extensions = ['sphinx.ext.autodoc', 'sphinx.ext.todo']
-
-# Add any paths that contain templates here, relative to this directory.
-#templates_path = ['_templates']
-
-# The suffix of source filenames.
-source_suffix = '.rst'
-
-# The encoding of source files.
-#source_encoding = 'utf-8-sig'
-
-# The master toctree document.
-master_doc = 'index'
-
-# General information about the project.
-project = u'Apache Qpid Proton'
-copyright = u'2015, Apache Qpid'
-
-# The version info for the project you're documenting, acts as replacement for
-# |version| and |release|, also used in various other places throughout the
-# built documents.
-#
-# The short X.Y version.
-version = '0.9'
-# The full version, including alpha/beta/rc tags.
-release = '0.9'
-
-# The language for content autogenerated by Sphinx. Refer to documentation
-# for a list of supported languages.
-#language = None
-
-# There are two options for replacing |today|: either, you set today to some
-# non-false value, then it is used:
-#today = ''
-# Else, today_fmt is used as the format for a strftime call.
-#today_fmt = '%B %d, %Y'
-
-# List of patterns, relative to source directory, that match files and
-# directories to ignore when looking for source files.
-exclude_patterns = []
-
-# The reST default role (used for this markup: `text`) to use for all documents.
-#default_role = None
-
-# If true, '()' will be appended to :func: etc. cross-reference text.
-#add_function_parentheses = True
-
-# If true, the current module name will be prepended to all description
-# unit titles (such as .. function::).
-#add_module_names = True
-
-# If true, sectionauthor and moduleauthor directives will be shown in the
-# output. They are ignored by default.
-#show_authors = False
-
-# The name of the Pygments (syntax highlighting) style to use.
-pygments_style = 'sphinx'
-
-# A list of ignored prefixes for module index sorting.
-#modindex_common_prefix = []
-
-
-# -- Options for HTML output ---------------------------------------------------
-
-# The theme to use for HTML and HTML Help pages.  See the documentation for
-# a list of builtin themes.
-html_theme = 'sphinxdoc'
-
-# Theme options are theme-specific and customize the look and feel of a theme
-# further.  For a list of options available for each theme, see the
-# documentation.
-#html_theme_options = {}
-
-# Add any paths that contain custom themes here, relative to this directory.
-#html_theme_path = []
-
-# The name for this set of Sphinx documents.  If None, it defaults to
-# "<project> v<release> documentation".
-#html_title = None
-
-# A shorter title for the navigation bar.  Default is the same as html_title.
-#html_short_title = None
-
-# The name of an image file (relative to this directory) to place at the top
-# of the sidebar.
-#html_logo = None
-
-# The name of an image file (within the static path) to use as favicon of the
-# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
-# pixels large.
-#html_favicon = None
-
-# Add any paths that contain custom static files (such as style sheets) here,
-# relative to this directory. They are copied after the builtin static files,
-# so a file named "default.css" will overwrite the builtin "default.css".
-#html_static_path = ['_static']
-
-# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
-# using the given strftime format.
-#html_last_updated_fmt = '%b %d, %Y'
-
-# If true, SmartyPants will be used to convert quotes and dashes to
-# typographically correct entities.
-#html_use_smartypants = True
-
-# Custom sidebar templates, maps document names to template names.
-#html_sidebars = {}
-
-# Additional templates that should be rendered to pages, maps page names to
-# template names.
-#html_additional_pages = {}
-
-# If false, no module index is generated.
-#html_domain_indices = True
-
-# If false, no index is generated.
-#html_use_index = True
-
-# If true, the index is split into individual pages for each letter.
-#html_split_index = False
-
-# If true, links to the reST sources are added to the pages.
-#html_show_sourcelink = True
-
-# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
-#html_show_sphinx = True
-
-# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
-#html_show_copyright = True
-
-# If true, an OpenSearch description file will be output, and all pages will
-# contain a <link> tag referring to it.  The value of this option must be the
-# base URL from which the finished HTML is served.
-#html_use_opensearch = ''
-
-# This is the file name suffix for HTML files (e.g. ".xhtml").
-#html_file_suffix = None
-
-# Output file base name for HTML help builder.
-htmlhelp_basename = 'ApacheQpidProtondoc'
-
-
-# -- Options for LaTeX output --------------------------------------------------
-
-latex_elements = {
-# The paper size ('letterpaper' or 'a4paper').
-#'papersize': 'letterpaper',
-
-# The font size ('10pt', '11pt' or '12pt').
-#'pointsize': '10pt',
-
-# Additional stuff for the LaTeX preamble.
-#'preamble': '',
-}
-
-# Grouping the document tree into LaTeX files. List of tuples
-# (source start file, target name, title, author, documentclass [howto/manual]).
-latex_documents = [
-  ('index', 'ApacheQpidProton.tex', u'Apache Qpid Proton Documentation',
-   u'The Apache Qpid Community', 'manual'),
-]
-
-# The name of an image file (relative to this directory) to place at the top of
-# the title page.
-#latex_logo = None
-
-# For "manual" documents, if this is true, then toplevel headings are parts,
-# not chapters.
-#latex_use_parts = False
-
-# If true, show page references after internal links.
-#latex_show_pagerefs = False
-
-# If true, show URL addresses after external links.
-#latex_show_urls = False
-
-# Documents to append as an appendix to all manuals.
-#latex_appendices = []
-
-# If false, no module index is generated.
-#latex_domain_indices = True
-
-
-# -- Options for manual page output --------------------------------------------
-
-# One entry per manual page. List of tuples
-# (source start file, name, description, authors, manual section).
-man_pages = [
-    ('index', 'apacheqpidproton', u'Apache Qpid Proton Documentation',
-     [u'The Apache Qpid Community'], 1)
-]
-
-# If true, show URL addresses after external links.
-#man_show_urls = False
-
-
-# -- Options for Texinfo output ------------------------------------------------
-
-# Grouping the document tree into Texinfo files. List of tuples
-# (source start file, target name, title, author,
-#  dir menu entry, description, category)
-texinfo_documents = [
-  ('index', 'ApacheQpidProton', u'Apache Qpid Proton Documentation',
-   u'The Apache Qpid Community', 'ApacheQpidProton', 'One line description of project.',
-   'Miscellaneous'),
-]
-
-# Documents to append as an appendix to all manuals.
-#texinfo_appendices = []
-
-# If false, no module index is generated.
-#texinfo_domain_indices = True
-
-# How to display URL addresses: 'footnote', 'no', or 'inline'.
-#texinfo_show_urls = 'footnote'

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/26a0622c/proton-c/bindings/python/docs/source/index.rst
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/docs/source/index.rst b/proton-c/bindings/python/docs/source/index.rst
deleted file mode 100644
index 2e78cd3..0000000
--- a/proton-c/bindings/python/docs/source/index.rst
+++ /dev/null
@@ -1,24 +0,0 @@
-.. Apache Qpid Proton documentation master file, created by
-   sphinx-quickstart on Mon Feb 16 14:13:09 2015.
-   You can adapt this file completely to your liking, but it should at least
-   contain the root `toctree` directive.
-
-Welcome to Apache Qpid Proton's documentation!
-==============================================
-
-Contents:
-
-.. toctree::
-   :maxdepth: 2
-
-   tutorial
-   overview
-   reference
-
-Indices and tables
-==================
-
-* :ref:`genindex`
-* :ref:`modindex`
-* :ref:`search`
-

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/26a0622c/proton-c/bindings/python/docs/source/overview.rst
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/docs/source/overview.rst b/proton-c/bindings/python/docs/source/overview.rst
deleted file mode 100644
index d589c0b..0000000
--- a/proton-c/bindings/python/docs/source/overview.rst
+++ /dev/null
@@ -1,161 +0,0 @@
-############
-API Overview
-############
-
-=========================
-An overview of the model
-=========================
-
-Messages are transferred between connected peers over 'links'. At the
-sending peer the link is called a sender. At the receiving peer it is
-called a receiver. Messages are sent by senders and received by
-receivers. Links may have named 'source' and 'target' addresses (for
-example to identify the queue from which message were to be received
-or to which they were to be sent).
-
-Links are established over sessions. Sessions are established over
-connections. Connections are (generally) established between two
-uniquely identified containers. Though a connection can have multiple
-sessions, often this is not needed. The container API allows you to
-ignore sessions unless you actually require them.
-
-The sending of a message over a link is called a delivery. The message
-is the content sent, including all meta-data such as headers and
-annotations. The delivery is the protocol exchange associated with the
-transfer of that content.
-
-To indicate that a delivery is complete, either the sender or the
-receiver 'settles' it. When the other side learns that it has been
-settled, they will no longer communicate about that delivery. The
-receiver can also indicate whether they accept or reject the
-message.
-
-Three different delivery levels or 'guarantees' can be achieved:
-at-most-once, at-least-once or exactly-once. See
-:ref:`delivery-guarantees` for more detail.
-
-=======================================================
-A summary of the most commonly used classes and members
-=======================================================
-
-A brief summary of some of the key classes follows. A more complete
-reference is available in :doc:`reference`.
-
-The :py:class:`~proton.reactor.Container` class is a convenient entry
-point into the API, allowing connections and links to be
-established. Applications are structured as one or more event
-handlers. Handlers can be set at Container, Connection, or Link
-scope. Messages are sent by establishing an approprate sender and
-invoking its :py:meth:`~proton.Sender.send()` method. This is
-typically done when the sender is sendable, a condition indicated by
-the :py:meth:`~proton.handlers.MessagingHandler.on_sendable()` event, to
-avoid execessive build up of messages. Messages can be received by
-establishing an appropriate receiver and handling the
-:py:meth:`~proton.handlers.MessagingHandler.on_message()` event.
-
-.. autoclass:: proton.reactor.Container
-    :show-inheritance: proton.reactor.Reactor
-    :members: connect, create_receiver, create_sender, run, schedule
-    :undoc-members:
-
-    .. py:attribute:: container_id
-
-       The identifier used to identify this container in any
-       connections it establishes. Container names should be
-       unique. By default a UUID will be used.
-
-    The :py:meth:`~proton.reactor.Container.connect()` method returns
-    an instance of :py:class:`~proton.Connection`, the
-    :py:meth:`~proton.reactor.Container.create_receiver()` method
-    returns an instance of :py:class:`~proton.Receiver` and the
-    :py:meth:`~proton.reactor.Container.create_sender()` method
-    returns an instance of :py:class:`~proton.Sender`.
-
-.. autoclass:: proton.Connection
-    :members: open, close, state, session, hostname, container,
-              remote_container, remote_desired_capabilities, remote_hostname, remote_offered_capabilities , remote_properties
-    :undoc-members:
-
-.. autoclass:: proton.Receiver
-    :show-inheritance: proton.Link
-    :members: flow, recv, drain, draining
-    :undoc-members:
-
-.. autoclass:: proton.Sender
-    :show-inheritance: proton.Link
-    :members: offered, send
-    :undoc-members:
-
-.. autoclass:: proton.Link
-    :members: name, state, is_sender, is_receiver,
-              credit, queued, session, connection,
-              source, target, remote_source, remote_target
-    :undoc-members:
-
-    The :py:meth:`~proton.Link.source()`,
-    :py:meth:`~proton.Link.target()`,
-    :py:meth:`~proton.Link.remote_source()` and
-    :py:meth:`~proton.Link.remote_target()` methods all return an
-    instance of :py:class:`~proton.Terminus`.
-
-
-.. autoclass:: proton.Delivery
-    :members: update, settle, settled, remote_state, local_state, partial, readable, writable,
-              link, session, connection
-    :undoc-members:
-
-.. autoclass:: proton.handlers.MessagingHandler
-    :members: on_start, on_reactor_init,
-              on_message,
-              on_accepted,
-              on_rejected,
-              on_settled,
-              on_sendable,
-              on_connection_error,
-              on_link_error,
-              on_session_error,
-              on_disconnected,
-              accept, reject, release, settle
-    :undoc-members:
-
-.. autoclass:: proton.Event
-    :members: delivery, link, receiver, sender, session, connection, reactor, context
-    :undoc-members:
-
-.. autoclass:: proton.Message
-    :members: address, id, priority, subject, ttl, reply_to, correlation_id, durable, user_id,
-              content_type, content_encoding, creation_time, expiry_time, delivery_count, first_acquirer,
-              group_id, group_sequence, reply_to_group_id,
-              send, recv, encode, decode
-    :undoc-members:
-
-.. autoclass:: proton.Terminus
-    :members: address, dynamic, properties, capabilities, filter
-    :undoc-members:
-
-.. _delivery-guarantees:
-
-===================
-Delivery guarantees
-===================
-
-For at-most-once, the sender settles the message as soon as it sends
-it. If the connection is lost before the message is received by the
-receiver, the message will not be delivered.
-
-For at-least-once, the receiver accepts and settles the message on
-receipt. If the connection is lost before the sender is informed of
-the settlement, then the delivery is considered in-doubt and should be
-retried. This will ensure it eventually gets delivered (provided of
-course the connection and link can be reestablished). It may mean that
-it is delivered multiple times though.
-
-Finally, for exactly-once, the receiver accepts the message but
-doesn't settle it. The sender settles once it is aware that the
-receiver accepted it. In this way the receiver retains knowledge of an
-accepted message until it is sure the sender knows it has been
-accepted. If the connection is lost before settlement, the receiver
-informs the sender of all the unsettled deliveries it knows about, and
-from this the sender can deduce which need to be redelivered. The
-sender likewise informs the receiver which deliveries it knows about,
-from which the receiver can deduce which have already been settled.

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/26a0622c/proton-c/bindings/python/docs/source/reference.rst
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/docs/source/reference.rst b/proton-c/bindings/python/docs/source/reference.rst
deleted file mode 100644
index 06f6b30..0000000
--- a/proton-c/bindings/python/docs/source/reference.rst
+++ /dev/null
@@ -1,44 +0,0 @@
-#############
-API Reference
-#############
-
-proton Package
-==============
-
-:mod:`proton` Package
----------------------
-
-.. automodule:: proton.__init__
-    :noindex:
-    :members:
-    :undoc-members:
-    :show-inheritance:
-    :exclude-members: Messenger, Url
-
-:mod:`reactor` Module
----------------------
-
-.. automodule:: proton.reactor
-    :noindex:
-    :members:
-    :undoc-members:
-    :show-inheritance:
-
-:mod:`handlers` Module
-----------------------
-
-.. automodule:: proton.handlers
-    :noindex:
-    :members:
-    :undoc-members:
-    :show-inheritance:
-
-:mod:`utils` Module
--------------------
-
-.. automodule:: proton.utils
-    :noindex:
-    :members:
-    :undoc-members:
-    :show-inheritance:
-

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/26a0622c/proton-c/bindings/python/docs/source/tutorial.rst
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/docs/source/tutorial.rst b/proton-c/bindings/python/docs/source/tutorial.rst
deleted file mode 100644
index 6f7550c..0000000
--- a/proton-c/bindings/python/docs/source/tutorial.rst
+++ /dev/null
@@ -1,301 +0,0 @@
-########
-Tutorial
-########
-
-============
-Hello World!
-============
-
-Tradition dictates that we start with hello world! However rather than
-simply striving for the shortest program possible, we'll aim for a
-more illustrative example while still restricting the functionality to
-sending and receiving a single message.
-
-.. literalinclude:: ../../../../../examples/python/helloworld.py
-   :lines: 21-
-   :linenos:
-
-You can see the import of :py:class:`~proton.reactor.Container` from ``proton.reactor`` on the
-second line. This is a class that makes programming with proton a
-little easier for the common cases. It includes within it an event
-loop, and programs written using this utility are generally structured
-to react to various events. This reactive style is particularly suited
-to messaging applications.
-
-To be notified of a particular event, you define a class with the
-appropriately name method on it. That method is then called by the
-event loop when the event occurs.
-
-We define a class here, ``HelloWorld``, which handles the key events of
-interest in sending and receiving a message.
-
-The ``on_start()`` method is called when the event loop first
-starts. We handle that by establishing our connection (line 12), a
-sender over which to send the message (line 13) and a receiver over
-which to receive it back again (line 14).
-
-The ``on_sendable()`` method is called when message can be transferred
-over the associated sender link to the remote peer. We send out our
-``Hello World!`` message (line 17), then close the sender (line 18) as
-we only want to send one message. The closing of the sender will
-prevent further calls to ``on_sendable()``.
-
-The ``on_message()`` method is called when a message is
-received. Within that we simply print the body of the message (line
-21) and then close the connection (line 22).
-
-Now that we have defined the logic for handling these events, we
-create an instance of a :py:class:`~proton.reactor.Container`, pass it
-our handler and then enter the event loop by calling
-:py:meth:`~proton.reactor.Container.run()`. At this point control
-passes to the container instance, which will make the appropriate
-callbacks to any defined handlers.
-
-To run the example you will need to have a broker (or similar)
-accepting connections on that url either with a queue (or topic)
-matching the given address or else configured to create such a queue
-(or topic) dynamically. There is a simple broker.py script included
-alongside the examples that can be used for this purpose if
-desired. (It is also written using the API described here, and as such
-gives an example of a slightly more involved application).
-
-====================
-Hello World, Direct!
-====================
-
-Though often used in conjunction with a broker, AMQP does not
-*require* this. It also allows senders and receivers can communicate
-directly if desired.
-
-Let's modify our example to demonstrate this.
-
-.. literalinclude:: ../../../../../examples/python/helloworld_direct.py
-   :lines: 21-
-   :emphasize-lines: 11,21-22,24-25
-   :linenos:
-
-The first difference, on line 11, is that rather than creating a
-receiver on the same connection as our sender, we listen for incoming
-connections by invoking the
-:py:meth:`~proton.reactor.Container.listen()` method on the
-container.
-
-As we only need then to initiate one link, the sender, we can do that
-by passing in a url rather than an existing connection, and the
-connection will also be automatically established for us.
-
-We send the message in response to the ``on_sendable()`` callback and
-print the message out in response to the ``on_message()`` callback
-exactly as before.
-
-However we also handle two new events. We now close the connection
-from the senders side once the message has been accepted (line
-22). The acceptance of the message is an indication of successful
-transfer to the peer. We are notified of that event through the
-``on_accepted()`` callback. Then, once the connection has been closed,
-of which we are notified through the ``on_closed()`` callback, we stop
-accepting incoming connections (line 25) at which point there is no
-work to be done and the event loop exits, and the run() method will
-return.
-
-So now we have our example working without a broker involved!
-
-=============================
-Asynchronous Send and Receive
-=============================
-
-Of course, these ``HelloWorld!`` examples are very artificial,
-communicating as they do over a network connection but with the same
-process. A more realistic example involves communication between
-separate processes (which could indeed be running on completely
-separate machines).
-
-Let's separate the sender from the receiver, and let's transfer more than
-a single message between them.
-
-We'll start with a simple sender.
-
-.. literalinclude:: ../../../../../examples/python/simple_send.py
-   :lines: 21-
-   :linenos:
-
-As with the previous example, we define the application logic in a
-class that handles various events. As before, we use the
-``on_start()`` event to establish our sender link over which we will
-transfer messages and the ``on_sendable()`` event to know when we can
-transfer our messages.
-
-Because we are transferring more than one message, we need to keep
-track of how many we have sent. We'll use a ``sent`` member variable
-for that. The ``total`` member variable will hold the number of
-messages we want to send.
-
-AMQP defines a credit-based flow control mechanism. Flow control
-allows the receiver to control how many messages it is prepared to
-receive at a given time and thus prevents any component being
-overwhelmed by the number of messages it is sent.
-
-In the ``on_sendable()`` callback, we check that our sender has credit
-before sending messages. We also check that we haven't already sent
-the required number of messages.
-
-The ``send()`` call on line 20 is of course asynchronous. When it
-returns the message has not yet actually been transferred across the
-network to the receiver. By handling the ``on_accepted()`` event, we
-can get notified when the receiver has received and accepted the
-message. In our example we use this event to track the confirmation of
-the messages we have sent. We only close the connection and exit when
-the receiver has received all the messages we wanted to send.
-
-If we are disconnected after a message is sent and before it has been
-confirmed by the receiver, it is said to be ``in doubt``. We don't
-know whether or not it was received. In this example, we will handle
-that by resending any in-doubt messages. This is known as an
-'at-least-once' guarantee, since each message should eventually be
-received at least once, though a given message may be received more
-than once (i.e. duplicates are possible). In the ``on_disconnected()``
-callback, we reset the sent count to reflect only those that have been
-confirmed. The library will automatically try to reconnect for us, and
-when our sender is sendable again, we can restart from the point we
-know the receiver got to.
-
-Now let's look at the corresponding receiver:
-
-.. literalinclude:: ../../../../../examples/python/simple_recv.py
-   :lines: 21-
-   :linenos:
-
-Here we handle the ``on_start()`` by creating our receiver, much like
-we did for the sender. We also handle the ``on_message()`` event for
-received messages and print the message out as in the ``Hello World!``
-examples. However we add some logic to allow the receiver to wait for
-a given number of messages, then to close the connection and exit. We
-also add some logic to check for and ignore duplicates, using a simple
-sequential id scheme.
-
-Again, though sending between these two examples requires some sort of
-intermediary process (e.g. a broker), AMQP allows us to send messages
-directly between two processes without this if we so wish. In that
-case one or other of the processes needs to accept incoming socket
-connections. Let's create a modified version of the receiving example
-that does this:
-
-.. literalinclude:: ../../../../../examples/python/direct_recv.py
-   :lines: 21-
-   :emphasize-lines: 13,25
-   :linenos:
-
-There are only two differences here. On line 13, instead of initiating
-a link (and implicitly a connection), we listen for incoming
-connections. On line 25, when we have received all the expected
-messages, we then stop listening for incoming connections by closing
-the acceptor object.
-
-You can use the original send example now to send to this receiver
-directly. (Note: you will need to stop any broker that is listening on
-the 5672 port, or else change the port used by specifying a different
-address to each example via the -a command line switch).
-
-We could equally well modify the original sender to allow the original
-receiver to connect to it. Again that just requires two modifications:
-
-.. literalinclude:: ../../../../../examples/python/direct_send.py
-   :lines: 21-
-   :emphasize-lines: 15,28
-   :linenos:
-
-As with the modified receiver, instead of initiating establishment of
-a link, we listen for incoming connections on line 15 and then on line
-28, when we have received confirmation of all the messages we sent, we
-can close the acceptor in order to exit. The symmetry in the
-underlying AMQP that enables this is quite unique and elegant, and in
-reflecting this the proton API provides a flexible toolkit for
-implementing all sorts of interesting intermediaries (the broker.py
-script provided as a simple broker for testing purposes provides an
-example of this).
-
-To try this modified sender, run the original receiver against it.
-
-================
-Request/Response
-================
-
-A common pattern is to send a request message and expect a response
-message in return. AMQP has special support for this pattern. Let's
-have a look at a simple example. We'll start with the 'server',
-i.e. the program that will process the request and send the
-response. Note that we are still using a broker in this example.
-
-Our server will provide a very simple service: it will respond with
-the body of the request converted to uppercase.
-
-.. literalinclude:: ../../../../../examples/python/server.py
-   :lines: 21-
-   :linenos:
-
-The code here is not too different from the simple receiver
-example. When we receive a request however, we look at the
-:py:attr:`~proton.Message.reply_to` address on the
-:py:class:`~proton.Message` and create a sender for that over which to
-send the response. We'll cache the senders incase we get further
-requests with the same reply_to.
-
-Now let's create a simple client to test this service out.
-
-.. literalinclude:: ../../../../../examples/python/client.py
-   :lines: 21-
-   :linenos:
-
-As well as sending requests, we need to be able to get back the
-responses. We create a receiver for that (see line 14), but we don't
-specify an address, we set the dynamic option which tells the broker
-we are connected to to create a temporary address over which we can
-receive our responses.
-
-We need to use the address allocated by the broker as the reply_to
-address of our requests, so we can't send them until the broker has
-confirmed our receiving link has been set up (at which point we will
-have our allocated address). To do that, we add an
-``on_link_opened()`` method to our handler class, and if the link
-associated with event is the receiver, we use that as the trigger to
-send our first request.
-
-Again, we could avoid having any intermediary process here if we
-wished. The following code implementas a server to which the client
-above could connect directly without any need for a broker or similar.
-
-.. literalinclude:: ../../../../../examples/python/server_direct.py
-   :lines: 21-
-   :linenos:
-
-Though this requires some more extensive changes than the simple
-sending and receiving examples, the essence of the program is still
-the same. Here though, rather than the server establishing a link for
-the response, it relies on the link that the client established, since
-that now comes in directly to the server process.
-
-Miscellaneous
-=============
-
-Many brokers offer the ability to consume messages based on a
-'selector' that defines which messages are of interest based on
-particular values of the headers. The following example shows how that
-can be achieved:
-
-.. literalinclude:: ../../../../../examples/python/selected_recv.py
-   :lines: 21-
-   :emphasize-lines: 10
-   :linenos:
-
-When creating the receiver, we specify a Selector object as an
-option. The options argument can take a single object or a
-list. Another option that is sometimes of interest when using a broker
-is the ability to 'browse' the messages on a queue, rather than
-consumig them. This is done in AMQP by specifying a distribution mode
-of 'copy' (instead of 'move' which is the expected default for
-queues). An example of that is shown next:
-
-.. literalinclude:: ../../../../../examples/python/queue_browser.py
-   :lines: 21-
-   :emphasize-lines: 10
-   :linenos:

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/26a0622c/proton-c/bindings/python/docs/tutorial.rst
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/docs/tutorial.rst b/proton-c/bindings/python/docs/tutorial.rst
new file mode 100644
index 0000000..6f7550c
--- /dev/null
+++ b/proton-c/bindings/python/docs/tutorial.rst
@@ -0,0 +1,301 @@
+########
+Tutorial
+########
+
+============
+Hello World!
+============
+
+Tradition dictates that we start with hello world! However rather than
+simply striving for the shortest program possible, we'll aim for a
+more illustrative example while still restricting the functionality to
+sending and receiving a single message.
+
+.. literalinclude:: ../../../../../examples/python/helloworld.py
+   :lines: 21-
+   :linenos:
+
+You can see the import of :py:class:`~proton.reactor.Container` from ``proton.reactor`` on the
+second line. This is a class that makes programming with proton a
+little easier for the common cases. It includes within it an event
+loop, and programs written using this utility are generally structured
+to react to various events. This reactive style is particularly suited
+to messaging applications.
+
+To be notified of a particular event, you define a class with the
+appropriately name method on it. That method is then called by the
+event loop when the event occurs.
+
+We define a class here, ``HelloWorld``, which handles the key events of
+interest in sending and receiving a message.
+
+The ``on_start()`` method is called when the event loop first
+starts. We handle that by establishing our connection (line 12), a
+sender over which to send the message (line 13) and a receiver over
+which to receive it back again (line 14).
+
+The ``on_sendable()`` method is called when message can be transferred
+over the associated sender link to the remote peer. We send out our
+``Hello World!`` message (line 17), then close the sender (line 18) as
+we only want to send one message. The closing of the sender will
+prevent further calls to ``on_sendable()``.
+
+The ``on_message()`` method is called when a message is
+received. Within that we simply print the body of the message (line
+21) and then close the connection (line 22).
+
+Now that we have defined the logic for handling these events, we
+create an instance of a :py:class:`~proton.reactor.Container`, pass it
+our handler and then enter the event loop by calling
+:py:meth:`~proton.reactor.Container.run()`. At this point control
+passes to the container instance, which will make the appropriate
+callbacks to any defined handlers.
+
+To run the example you will need to have a broker (or similar)
+accepting connections on that url either with a queue (or topic)
+matching the given address or else configured to create such a queue
+(or topic) dynamically. There is a simple broker.py script included
+alongside the examples that can be used for this purpose if
+desired. (It is also written using the API described here, and as such
+gives an example of a slightly more involved application).
+
+====================
+Hello World, Direct!
+====================
+
+Though often used in conjunction with a broker, AMQP does not
+*require* this. It also allows senders and receivers can communicate
+directly if desired.
+
+Let's modify our example to demonstrate this.
+
+.. literalinclude:: ../../../../../examples/python/helloworld_direct.py
+   :lines: 21-
+   :emphasize-lines: 11,21-22,24-25
+   :linenos:
+
+The first difference, on line 11, is that rather than creating a
+receiver on the same connection as our sender, we listen for incoming
+connections by invoking the
+:py:meth:`~proton.reactor.Container.listen()` method on the
+container.
+
+As we only need then to initiate one link, the sender, we can do that
+by passing in a url rather than an existing connection, and the
+connection will also be automatically established for us.
+
+We send the message in response to the ``on_sendable()`` callback and
+print the message out in response to the ``on_message()`` callback
+exactly as before.
+
+However we also handle two new events. We now close the connection
+from the senders side once the message has been accepted (line
+22). The acceptance of the message is an indication of successful
+transfer to the peer. We are notified of that event through the
+``on_accepted()`` callback. Then, once the connection has been closed,
+of which we are notified through the ``on_closed()`` callback, we stop
+accepting incoming connections (line 25) at which point there is no
+work to be done and the event loop exits, and the run() method will
+return.
+
+So now we have our example working without a broker involved!
+
+=============================
+Asynchronous Send and Receive
+=============================
+
+Of course, these ``HelloWorld!`` examples are very artificial,
+communicating as they do over a network connection but with the same
+process. A more realistic example involves communication between
+separate processes (which could indeed be running on completely
+separate machines).
+
+Let's separate the sender from the receiver, and let's transfer more than
+a single message between them.
+
+We'll start with a simple sender.
+
+.. literalinclude:: ../../../../../examples/python/simple_send.py
+   :lines: 21-
+   :linenos:
+
+As with the previous example, we define the application logic in a
+class that handles various events. As before, we use the
+``on_start()`` event to establish our sender link over which we will
+transfer messages and the ``on_sendable()`` event to know when we can
+transfer our messages.
+
+Because we are transferring more than one message, we need to keep
+track of how many we have sent. We'll use a ``sent`` member variable
+for that. The ``total`` member variable will hold the number of
+messages we want to send.
+
+AMQP defines a credit-based flow control mechanism. Flow control
+allows the receiver to control how many messages it is prepared to
+receive at a given time and thus prevents any component being
+overwhelmed by the number of messages it is sent.
+
+In the ``on_sendable()`` callback, we check that our sender has credit
+before sending messages. We also check that we haven't already sent
+the required number of messages.
+
+The ``send()`` call on line 20 is of course asynchronous. When it
+returns the message has not yet actually been transferred across the
+network to the receiver. By handling the ``on_accepted()`` event, we
+can get notified when the receiver has received and accepted the
+message. In our example we use this event to track the confirmation of
+the messages we have sent. We only close the connection and exit when
+the receiver has received all the messages we wanted to send.
+
+If we are disconnected after a message is sent and before it has been
+confirmed by the receiver, it is said to be ``in doubt``. We don't
+know whether or not it was received. In this example, we will handle
+that by resending any in-doubt messages. This is known as an
+'at-least-once' guarantee, since each message should eventually be
+received at least once, though a given message may be received more
+than once (i.e. duplicates are possible). In the ``on_disconnected()``
+callback, we reset the sent count to reflect only those that have been
+confirmed. The library will automatically try to reconnect for us, and
+when our sender is sendable again, we can restart from the point we
+know the receiver got to.
+
+Now let's look at the corresponding receiver:
+
+.. literalinclude:: ../../../../../examples/python/simple_recv.py
+   :lines: 21-
+   :linenos:
+
+Here we handle the ``on_start()`` by creating our receiver, much like
+we did for the sender. We also handle the ``on_message()`` event for
+received messages and print the message out as in the ``Hello World!``
+examples. However we add some logic to allow the receiver to wait for
+a given number of messages, then to close the connection and exit. We
+also add some logic to check for and ignore duplicates, using a simple
+sequential id scheme.
+
+Again, though sending between these two examples requires some sort of
+intermediary process (e.g. a broker), AMQP allows us to send messages
+directly between two processes without this if we so wish. In that
+case one or other of the processes needs to accept incoming socket
+connections. Let's create a modified version of the receiving example
+that does this:
+
+.. literalinclude:: ../../../../../examples/python/direct_recv.py
+   :lines: 21-
+   :emphasize-lines: 13,25
+   :linenos:
+
+There are only two differences here. On line 13, instead of initiating
+a link (and implicitly a connection), we listen for incoming
+connections. On line 25, when we have received all the expected
+messages, we then stop listening for incoming connections by closing
+the acceptor object.
+
+You can use the original send example now to send to this receiver
+directly. (Note: you will need to stop any broker that is listening on
+the 5672 port, or else change the port used by specifying a different
+address to each example via the -a command line switch).
+
+We could equally well modify the original sender to allow the original
+receiver to connect to it. Again that just requires two modifications:
+
+.. literalinclude:: ../../../../../examples/python/direct_send.py
+   :lines: 21-
+   :emphasize-lines: 15,28
+   :linenos:
+
+As with the modified receiver, instead of initiating establishment of
+a link, we listen for incoming connections on line 15 and then on line
+28, when we have received confirmation of all the messages we sent, we
+can close the acceptor in order to exit. The symmetry in the
+underlying AMQP that enables this is quite unique and elegant, and in
+reflecting this the proton API provides a flexible toolkit for
+implementing all sorts of interesting intermediaries (the broker.py
+script provided as a simple broker for testing purposes provides an
+example of this).
+
+To try this modified sender, run the original receiver against it.
+
+================
+Request/Response
+================
+
+A common pattern is to send a request message and expect a response
+message in return. AMQP has special support for this pattern. Let's
+have a look at a simple example. We'll start with the 'server',
+i.e. the program that will process the request and send the
+response. Note that we are still using a broker in this example.
+
+Our server will provide a very simple service: it will respond with
+the body of the request converted to uppercase.
+
+.. literalinclude:: ../../../../../examples/python/server.py
+   :lines: 21-
+   :linenos:
+
+The code here is not too different from the simple receiver
+example. When we receive a request however, we look at the
+:py:attr:`~proton.Message.reply_to` address on the
+:py:class:`~proton.Message` and create a sender for that over which to
+send the response. We'll cache the senders incase we get further
+requests with the same reply_to.
+
+Now let's create a simple client to test this service out.
+
+.. literalinclude:: ../../../../../examples/python/client.py
+   :lines: 21-
+   :linenos:
+
+As well as sending requests, we need to be able to get back the
+responses. We create a receiver for that (see line 14), but we don't
+specify an address, we set the dynamic option which tells the broker
+we are connected to to create a temporary address over which we can
+receive our responses.
+
+We need to use the address allocated by the broker as the reply_to
+address of our requests, so we can't send them until the broker has
+confirmed our receiving link has been set up (at which point we will
+have our allocated address). To do that, we add an
+``on_link_opened()`` method to our handler class, and if the link
+associated with event is the receiver, we use that as the trigger to
+send our first request.
+
+Again, we could avoid having any intermediary process here if we
+wished. The following code implementas a server to which the client
+above could connect directly without any need for a broker or similar.
+
+.. literalinclude:: ../../../../../examples/python/server_direct.py
+   :lines: 21-
+   :linenos:
+
+Though this requires some more extensive changes than the simple
+sending and receiving examples, the essence of the program is still
+the same. Here though, rather than the server establishing a link for
+the response, it relies on the link that the client established, since
+that now comes in directly to the server process.
+
+Miscellaneous
+=============
+
+Many brokers offer the ability to consume messages based on a
+'selector' that defines which messages are of interest based on
+particular values of the headers. The following example shows how that
+can be achieved:
+
+.. literalinclude:: ../../../../../examples/python/selected_recv.py
+   :lines: 21-
+   :emphasize-lines: 10
+   :linenos:
+
+When creating the receiver, we specify a Selector object as an
+option. The options argument can take a single object or a
+list. Another option that is sometimes of interest when using a broker
+is the ability to 'browse' the messages on a queue, rather than
+consumig them. This is done in AMQP by specifying a distribution mode
+of 'copy' (instead of 'move' which is the expected default for
+queues). An example of that is shown next:
+
+.. literalinclude:: ../../../../../examples/python/queue_browser.py
+   :lines: 21-
+   :emphasize-lines: 10
+   :linenos:


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


[16/50] [abbrv] qpid-proton git commit: Add valgrind to travis yml

Posted by ac...@apache.org.
Add valgrind to travis yml


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/c476cdb9
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/c476cdb9
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/c476cdb9

Branch: refs/heads/cjansen-cpp-client
Commit: c476cdb98a27b8332dfe45d10352dfd6c34f3343
Parents: 96fdc65
Author: Dominic Evans <do...@uk.ibm.com>
Authored: Wed May 13 13:58:14 2015 +0100
Committer: Dominic Evans <do...@uk.ibm.com>
Committed: Wed May 13 13:58:14 2015 +0100

----------------------------------------------------------------------
 .travis.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c476cdb9/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index 8104aa9..8d12bc4 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,6 @@
 language: c
 install:
   - sudo apt-get update -qq
-  - sudo apt-get install -y -qq bash cmake libssl-dev maven ruby python php5 openjdk-7-jdk swig uuid-dev
+  - sudo apt-get install -y -qq bash cmake libssl-dev maven ruby python php5 openjdk-7-jdk swig uuid-dev valgrind
 script:
   - bin/jenkins-proton-c-build.sh


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


[41/50] [abbrv] qpid-proton git commit: NO-JIRA: Fix bindings/CMakeLists.txt to work with newer and older cmake.

Posted by ac...@apache.org.
NO-JIRA: Fix bindings/CMakeLists.txt to work with newer and older cmake.

Newer cmake no longer wants quoting of variables in if() statements.


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/8c86c6f3
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/8c86c6f3
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/8c86c6f3

Branch: refs/heads/cjansen-cpp-client
Commit: 8c86c6f3685a580f820875835c131c3b447a9c44
Parents: a21bd42
Author: Alan Conway <ac...@redhat.com>
Authored: Thu May 28 15:58:16 2015 -0400
Committer: Alan Conway <ac...@redhat.com>
Committed: Thu May 28 16:30:14 2015 -0400

----------------------------------------------------------------------
 proton-c/bindings/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8c86c6f3/proton-c/bindings/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/bindings/CMakeLists.txt b/proton-c/bindings/CMakeLists.txt
index 657e71c..5df4682 100644
--- a/proton-c/bindings/CMakeLists.txt
+++ b/proton-c/bindings/CMakeLists.txt
@@ -117,7 +117,7 @@ foreach(BINDING ${BINDINGS})
     set ("DEFAULT_${UBINDING}" OFF)
   endif ()
   option("BUILD_${UBINDING}" "Build ${BINDING} language binding" ${DEFAULT_${UBINDING}})
-  if ("BUILD_${UBINDING}")
+  if (BUILD_${UBINDING})
     add_subdirectory(${BINDING})
   endif ()
 endforeach(BINDING)


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


[50/50] [abbrv] qpid-proton git commit: PROTON-865: Example and cmake cleanup, minor code cleanup.

Posted by ac...@apache.org.
PROTON-865: Example and cmake cleanup, minor code cleanup.

- Optionally enable C++ in top level cmake for examplesb. Still works without a C++ compiler.
- Move cpp examples to the /examples dir, renamed for consistent exe naming conventions.
- Integrate example build & auto-test with cmake
- Improved exception handling
- Simplified exception handling.
- Removed nascent logging code, logging should be handled centrally in C library.


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/8074793b
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/8074793b
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/8074793b

Branch: refs/heads/cjansen-cpp-client
Commit: 8074793b84a6402b01f3639e8cf8fed6b5ba54cc
Parents: d56c5d7
Author: Alan Conway <ac...@redhat.com>
Authored: Mon Jun 1 18:03:36 2015 -0400
Committer: Alan Conway <ac...@redhat.com>
Committed: Wed Jun 3 11:43:31 2015 -0400

----------------------------------------------------------------------
 CMakeLists.txt                                  |   8 +-
 examples/CMakeLists.txt                         |   3 +
 examples/cpp/CMakeLists.txt                     |  32 +++
 examples/cpp/README.md                          |  43 +++
 examples/cpp/broker.cpp                         | 201 +++++++++++++
 examples/cpp/example_test.py                    | 105 +++++++
 examples/cpp/helloworld.cpp                     |  69 +++++
 examples/cpp/helloworld_blocking.cpp            |  70 +++++
 examples/cpp/helloworld_direct.cpp              |  76 +++++
 examples/cpp/simple_recv.cpp                    | 115 ++++++++
 examples/cpp/simple_send.cpp                    | 122 ++++++++
 examples/go/CMakeLists.txt                      |  29 ++
 examples/go/example_test.go                     | 284 +++++++++++++++++++
 proton-c/CMakeLists.txt                         |   3 -
 proton-c/bindings/CMakeLists.txt                |   8 +-
 proton-c/bindings/cpp/CMakeLists.txt            |  26 --
 proton-c/bindings/cpp/README.md                 |  24 ++
 proton-c/bindings/cpp/examples/Broker.cpp       | 193 -------------
 proton-c/bindings/cpp/examples/HelloWorld.cpp   |  62 ----
 .../cpp/examples/HelloWorldBlocking.cpp         |  65 -----
 .../bindings/cpp/examples/HelloWorldDirect.cpp  |  70 -----
 proton-c/bindings/cpp/examples/SimpleRecv.cpp   | 109 -------
 proton-c/bindings/cpp/examples/SimpleSend.cpp   | 117 --------
 .../bindings/cpp/include/proton/cpp/Delivery.h  |   2 -
 .../bindings/cpp/include/proton/cpp/Handle.h    |   1 +
 .../cpp/include/proton/cpp/exceptions.h         |  17 +-
 proton-c/bindings/cpp/src/Connector.cpp         |   7 +-
 proton-c/bindings/cpp/src/Container.cpp         |   1 -
 proton-c/bindings/cpp/src/ContainerImpl.cpp     |   2 +-
 proton-c/bindings/cpp/src/Delivery.cpp          |   1 +
 proton-c/bindings/cpp/src/LogInternal.h         |  51 ----
 proton-c/bindings/cpp/src/Logger.cpp            |  56 ----
 proton-c/bindings/cpp/src/exceptions.cpp        |  33 ---
 33 files changed, 1190 insertions(+), 815 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8074793b/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2df2dfb..261fdc0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -20,16 +20,15 @@ cmake_minimum_required (VERSION 2.6)
 
 project (Proton C)
 
+# Enable C++ now for examples and bindings subdirectories, but make it optional.
+enable_language(CXX OPTIONAL)
+
 if (MSVC)
   # No C99 capability, use C++
   set(DEFAULT_BUILD_WITH_CXX ON)
 endif (MSVC)
 option(BUILD_WITH_CXX "Compile Proton using C++" ${DEFAULT_BUILD_WITH_CXX})
 
-if (BUILD_WITH_CXX)
-  project (Proton C CXX)
-endif (BUILD_WITH_CXX)
-
 if (CMAKE_CONFIGURATION_TYPES)
   # There is no single "build type"...
   message(STATUS "Build types are ${CMAKE_CONFIGURATION_TYPES}")
@@ -141,6 +140,7 @@ if (BUILD_JAVA)
 endif()
 
 add_subdirectory(proton-c)
+add_subdirectory(examples)
 
 install (FILES LICENSE README.md TODO
          DESTINATION ${PROTON_SHARE})

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8074793b/examples/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index feac758..5724e59 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -21,3 +21,6 @@ set (Proton_DIR ${CMAKE_CURRENT_SOURCE_DIR})
 
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
 add_subdirectory(c/messenger)
+if (BUILD_CPP)
+  add_subdirectory(cpp)
+endif()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8074793b/examples/cpp/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/cpp/CMakeLists.txt b/examples/cpp/CMakeLists.txt
new file mode 100644
index 0000000..2ce548b
--- /dev/null
+++ b/examples/cpp/CMakeLists.txt
@@ -0,0 +1,32 @@
+#
+# 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.
+#
+
+include_directories ("${CMAKE_SOURCE_DIR}/proton-c/bindings/cpp/include")
+
+foreach(example broker helloworld helloworld_blocking helloworld_direct simple_recv simple_send)
+  add_executable(${example} ${example}.cpp)
+  target_link_libraries(${example} qpid-proton-cpp)
+endforeach()
+
+add_test(
+  NAME cpp_example_test
+  COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/example_test.py -v
+  WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
+
+

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8074793b/examples/cpp/README.md
----------------------------------------------------------------------
diff --git a/examples/cpp/README.md b/examples/cpp/README.md
new file mode 100644
index 0000000..2aaf2ef
--- /dev/null
+++ b/examples/cpp/README.md
@@ -0,0 +1,43 @@
+# C++ examples
+
+## broker.cpp
+
+A very simple "mini broker". You can use this to run other examples that reqiure
+an intermediary, or you can use a real AMQP 1.0 broker. It creates queues
+automatically when a client tries to send to or subscribe from a node.
+
+## helloworld.cpp
+
+Basic example that connects to an intermediary on localhost:5672,
+establishes a subscription from the 'examples' node on that
+intermediary, then creates a sending link to the same node and sends
+one message. On receving the message back via the subcription, the
+connection is closed.
+
+## helloworld_blocking.cpp
+
+The same as the basic helloworld.cpp, but using a
+synchronous/sequential style wrapper on top of the
+asynchronous/reactive API. The purpose of this example is just to show
+how different functionality can be easily layered should it be
+desired.
+
+## helloworld_direct.cpp
+
+A variant of the basic helloworld example, that does not use an
+intermediary, but listens for incoming connections itself. It
+establishes a connection to itself with a link over which a single
+message is sent. This demonstrates the ease with which a simple daemon
+can be built using the API.
+
+## simple_send.cpp
+
+An example of sending a fixed number of messages and tracking their
+(asynchronous) acknowledgement. Messages are sent through the 'examples' node on
+an intermediary accessible on port 5672 on localhost.
+
+# simple_recv.cpp
+
+Subscribes to the 'examples' node on an intermediary accessible on port 5672 on
+localhost. Simply prints out the body of received messages.
+

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8074793b/examples/cpp/broker.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/broker.cpp b/examples/cpp/broker.cpp
new file mode 100644
index 0000000..01160a7
--- /dev/null
+++ b/examples/cpp/broker.cpp
@@ -0,0 +1,201 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "proton/cpp/Container.h"
+#include "proton/cpp/MessagingHandler.h"
+
+#include <iostream>
+#include <deque>
+#include <map>
+#include <list>
+#include <stdlib.h>
+#include <string.h>
+
+using namespace proton::reactor;
+
+std::string generateUuid(){
+    throw "TODO: platform neutral uuid";
+}
+
+class Queue {
+  public:
+    bool dynamic;
+    typedef std::deque<Message> MsgQ;
+    typedef std::list<Sender> List;
+    MsgQ queue;
+    List consumers;
+
+    Queue(bool dyn = false) : dynamic(dyn), queue(MsgQ()), consumers(List()) {}
+
+    void subscribe(Sender &c) {
+        consumers.push_back(c);
+    }
+
+    bool unsubscribe(Sender &c) {
+        consumers.remove(c);
+        return (consumers.size() == 0 && (dynamic || queue.size() == 0));
+    }
+
+    void publish(Message &m) {
+        queue.push_back(m);
+        dispatch(0);
+    }
+
+    void dispatch(Sender *s) {
+        while (deliverTo(s)) {
+        }
+    }
+
+    bool deliverTo(Sender *consumer) {
+        // deliver to single consumer if supplied, else all consumers
+        int count = consumer ? 1 : consumers.size();
+        if (!count) return false;
+        bool result = false;
+        List::iterator it = consumers.begin();
+        if (!consumer && count) consumer = &*it;
+
+        while (queue.size()) {
+            if (consumer->getCredit()) {
+                consumer->send(queue.front());
+                queue.pop_front();
+                result = true;
+            }
+            if (--count)
+                it++;
+            else
+                return result;
+        }
+        return false;
+    }
+};
+
+class Broker : public MessagingHandler {
+  private:
+    std::string url;
+    typedef std::map<std::string, Queue *> QMap;
+    QMap queues;
+  public:
+
+    Broker(const std::string &s) : url(s), queues(QMap()) {}
+
+    void onStart(Event &e) {
+        e.getContainer().listen(url);
+        std::cout << "broker listening on " << url << std::endl;
+    }
+
+    Queue &queue(std::string &address) {
+        QMap::iterator it = queues.find(address);
+        if (it == queues.end()) {
+            queues[address] = new Queue();
+            return *queues[address];
+        }
+        else {
+            return *it->second;
+        }
+    }
+
+    void onLinkOpening(Event &e) {
+        Link lnk = e.getLink();
+        if (lnk.isSender()) {
+            Sender sender(lnk);
+            Terminus remoteSource(lnk.getRemoteSource());
+            if (remoteSource.isDynamic()) {
+                std::string address = generateUuid();
+                lnk.getSource().setAddress(address);
+                Queue *q = new Queue(true);
+                queues[address] = q;
+                q->subscribe(sender);
+            }
+            else {
+                std::string address = remoteSource.getAddress();
+                if (!address.empty()) {
+                    lnk.getSource().setAddress(address);
+                    queue(address).subscribe(sender);
+                }
+            }
+        }
+        else {
+            std::string address = lnk.getRemoteTarget().getAddress();
+            if (!address.empty())
+                lnk.getTarget().setAddress(address);
+        }
+    }
+
+    void unsubscribe (Sender &lnk) {
+        std::string address = lnk.getSource().getAddress();
+        QMap::iterator it = queues.find(address);
+        if (it != queues.end() && it->second->unsubscribe(lnk)) {
+            delete it->second;
+            queues.erase(it);
+        }
+    }
+
+    void onLinkClosing(Event &e) {
+        Link lnk = e.getLink();
+        if (lnk.isSender()) {
+            Sender s(lnk);
+            unsubscribe(s);
+        }
+    }
+
+    void onConnectionClosing(Event &e) {
+        removeStaleConsumers(e.getConnection());
+    }
+
+    void onDisconnected(Event &e) {
+        removeStaleConsumers(e.getConnection());
+    }
+
+    void removeStaleConsumers(Connection &connection) {
+        Link l = connection.getLinkHead(Endpoint::REMOTE_ACTIVE);
+        while (l) {
+            if (l.isSender()) {
+                Sender s(l);
+                unsubscribe(s);
+            }
+            l = l.getNext(Endpoint::REMOTE_ACTIVE);
+        }
+    }
+
+    void onSendable(Event &e) {
+        Link lnk = e.getLink();
+        Sender sender(lnk);
+        std::string addr = lnk.getSource().getAddress();
+        queue(addr).dispatch(&sender);
+    }
+
+    void onMessage(Event &e) {
+        std::string addr = e.getLink().getTarget().getAddress();
+        Message msg = e.getMessage();
+        queue(addr).publish(msg);
+    }
+};
+
+int main(int argc, char **argv) {
+    std::string url = argc > 1 ? argv[1] : ":5672";
+    Broker broker(url);
+    try {
+        Container(broker).run();
+    } catch (const std::exception& e) {
+        std::cerr << e.what() << std::endl;
+        return 1;
+    }
+}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8074793b/examples/cpp/example_test.py
----------------------------------------------------------------------
diff --git a/examples/cpp/example_test.py b/examples/cpp/example_test.py
new file mode 100644
index 0000000..9a8ac67
--- /dev/null
+++ b/examples/cpp/example_test.py
@@ -0,0 +1,105 @@
+#
+# 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 unittest
+import os, sys, socket, time
+from  random import randrange
+from subprocess import Popen, check_output, PIPE
+
+NULL = open(os.devnull, 'w')
+
+class Broker(object):
+    """Run the test broker"""
+
+    @classmethod
+    def get(cls):
+        if not hasattr(cls, "_broker"):
+            cls._broker = Broker()
+        return cls._broker
+
+    @classmethod
+    def stop(cls):
+        if cls._broker and cls._broker.process:
+            cls._broker.process.kill()
+            cls._broker = None
+
+    def __init__(self):
+        self.port = randrange(10000, 20000)
+        self.addr = ":%s" % self.port
+        self.process = Popen(["./broker", self.addr], stdout=NULL, stderr=NULL)
+        # Wait 10 secs for broker to listen
+        deadline = time.time() + 10
+        c = None
+        while time.time() < deadline:
+            try:
+                c = socket.create_connection(("127.0.0.1", self.port), deadline - time.time())
+                break
+            except socket.error as e:
+                time.sleep(0.01)
+        if c is None:
+            raise Exception("Timed out waiting for broker")
+        c.close()
+
+
+class ExampleTest(unittest.TestCase):
+    """Test examples"""
+
+    @classmethod
+    def tearDownClass(self):
+        Broker.stop()
+
+    def test_helloworld(self):
+        b = Broker.get()
+        hw = check_output(["./helloworld", b.addr])
+        self.assertEqual("Hello World!\n", hw)
+
+    def test_helloworld_blocking(self):
+        b = Broker.get()
+        hw = check_output(["./helloworld_blocking", b.addr])
+        self.assertEqual("Hello World!\n", hw)
+
+    def test_helloworld_direct(self):
+        url = ":%s/examples" % randrange(10000, 20000)
+        hw = check_output(["./helloworld_direct", url])
+        self.assertEqual("Hello World!\n", hw)
+
+    def test_simple_send_recv(self):
+        b = Broker.get()
+        n = 5
+        send = check_output(["./simple_send", "-a", b.addr, "-m", str(n)])
+        self.assertEqual("all messages confirmed\n", send)
+        recv = check_output(["./simple_recv", "-a", b.addr, "-m", str(n)])
+        recv_expect = "simple_recv listening on %s\n" % (b.addr)
+        recv_expect += "".join(['[%d]: b"some arbitrary binary data"\n' % (i+1) for i in range(n)])
+        self.assertEqual(recv_expect, recv)
+
+    def FIXME_test_simple_recv_send(self):
+        """Start receiver first, then run sender"""
+        b = Broker.get()
+        n = 5
+        recv = Popen(["./simple_recv", "-a", b.addr, "-m", str(n)], stdout=PIPE)
+        self.assertEqual("simple_recv listening on %s\n" % (b.addr), recv.stdout.readline())
+        send = check_output(["./simple_send", "-a", b.addr, "-m", str(n)])
+        self.assertEqual("all messages confirmed\n", send)
+        recv_expect = "".join(['[%d]: b"some arbitrary binary data"\n' % (i+1) for i in range(n)])
+        out, err = recv.communicate()
+        self.assertEqual(recv_expect, out)
+
+if __name__ == "__main__":
+    unittest.main()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8074793b/examples/cpp/helloworld.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/helloworld.cpp b/examples/cpp/helloworld.cpp
new file mode 100644
index 0000000..6b58eb7
--- /dev/null
+++ b/examples/cpp/helloworld.cpp
@@ -0,0 +1,69 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "proton/cpp/Container.h"
+#include "proton/cpp/MessagingHandler.h"
+
+#include <iostream>
+
+
+using namespace proton::reactor;
+
+class HelloWorld : public MessagingHandler {
+  private:
+    std::string server;
+    std::string address;
+  public:
+
+    HelloWorld(const std::string &s, const std::string &addr) : server(s), address(addr) {}
+
+    void onStart(Event &e) {
+        Connection conn = e.getContainer().connect(server);
+        e.getContainer().createReceiver(conn, address);
+        e.getContainer().createSender(conn, address);
+    }
+
+    void onSendable(Event &e) {
+        Message m;
+        m.setBody("Hello World!");
+        e.getSender().send(m);
+        e.getSender().close();
+    }
+
+    void onMessage(Event &e) {
+        std::string body = e.getMessage().getBody();
+        std::cout << body << std::endl;
+        e.getConnection().close();
+    }
+
+};
+
+int main(int argc, char **argv) {
+    try {
+        std::string server = argc > 1 ? argv[1] : ":5672";
+        std::string addr = argc > 2 ? argv[2] : "examples";
+        HelloWorld hw(server, addr);
+        Container(hw).run();
+    } catch (const std::exception& e) {
+        std::cerr << e.what() << std::endl;
+        return 1;
+    }
+}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8074793b/examples/cpp/helloworld_blocking.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/helloworld_blocking.cpp b/examples/cpp/helloworld_blocking.cpp
new file mode 100644
index 0000000..5f443b6
--- /dev/null
+++ b/examples/cpp/helloworld_blocking.cpp
@@ -0,0 +1,70 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "proton/cpp/Container.h"
+#include "proton/cpp/MessagingHandler.h"
+#include "proton/cpp/BlockingSender.h"
+
+#include <iostream>
+
+
+using namespace proton::reactor;
+
+class HelloWorldBlocking : public MessagingHandler {
+  private:
+    std::string server;
+    std::string address;
+  public:
+
+    HelloWorldBlocking(const std::string &s, const std::string &addr) : server(s), address(addr) {}
+
+    void onStart(Event &e) {
+        Connection conn = e.getContainer().connect(server);
+        e.getContainer().createReceiver(conn, address);
+    }
+
+    void onMessage(Event &e) {
+        std::string body = e.getMessage().getBody();
+        std::cout << body << std::endl;
+        e.getConnection().close();
+    }
+
+};
+
+int main(int argc, char **argv) {
+    try {
+        std::string server = argc > 1 ? argv[1] : ":5672";
+        std::string addr = argc > 2 ? argv[2] : "examples";
+        BlockingConnection conn = BlockingConnection(server);
+        BlockingSender sender = conn.createSender(addr);
+        Message m;
+        m.setBody("Hello World!");
+        sender.send(m);
+        conn.close();
+
+        // TODO Temporary hack until blocking receiver available
+        HelloWorldBlocking hw(server, addr);
+        Container(hw).run();
+    } catch (const std::exception& e) {
+        std::cerr << e.what() << std::endl;
+        return 1;
+    }
+}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8074793b/examples/cpp/helloworld_direct.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/helloworld_direct.cpp b/examples/cpp/helloworld_direct.cpp
new file mode 100644
index 0000000..12617cd
--- /dev/null
+++ b/examples/cpp/helloworld_direct.cpp
@@ -0,0 +1,76 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "proton/cpp/MessagingHandler.h"
+#include "proton/cpp/Container.h"
+
+//#include "proton/cpp/Acceptor.h"
+#include <iostream>
+
+
+using namespace proton::reactor;
+
+
+class HelloWorldDirect : public MessagingHandler {
+  private:
+    std::string url;
+    Acceptor acceptor;
+  public:
+
+    HelloWorldDirect(const std::string &u) : url(u) {}
+
+    void onStart(Event &e) {
+        acceptor = e.getContainer().listen(url);
+        e.getContainer().createSender(url);
+    }
+
+    void onSendable(Event &e) {
+        Message m;
+        m.setBody("Hello World!");
+        e.getSender().send(m);
+        e.getSender().close();
+    }
+
+    void onMessage(Event &e) {
+        std::string body = e.getMessage().getBody();
+        std::cout << body << std::endl;
+    }
+
+    void onAccepted(Event &e) {
+        e.getConnection().close();
+    }
+
+    void onConnectionClosed(Event &e) {
+        acceptor.close();
+    }
+
+};
+
+int main(int argc, char **argv) {
+    try {
+        std::string url = argc > 1 ? argv[1] : ":8888/examples";
+        HelloWorldDirect hwd(url);
+        Container(hwd).run();
+    } catch (const std::exception& e) {
+        std::cerr << e.what() << std::endl;
+        return 1;
+    }
+}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8074793b/examples/cpp/simple_recv.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/simple_recv.cpp b/examples/cpp/simple_recv.cpp
new file mode 100644
index 0000000..42c561b
--- /dev/null
+++ b/examples/cpp/simple_recv.cpp
@@ -0,0 +1,115 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "proton/cpp/Container.h"
+#include "proton/cpp/MessagingHandler.h"
+#include "proton/cpp/Link.h"
+
+#include <iostream>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+
+using namespace proton::reactor;
+
+class Recv : public MessagingHandler {
+  private:
+    std::string url;
+    int expected;
+    int received;
+  public:
+
+    Recv(const std::string &s, int c) : url(s), expected(c), received(0) {}
+
+    void onStart(Event &e) {
+        e.getContainer().createReceiver(url);
+        std::cout << "simple_recv listening on " << url << std::endl;
+    }
+
+    void onMessage(Event &e) {
+        uint64_t id = 0;
+        Message msg = e.getMessage();
+        if (msg.getIdType() == PN_ULONG) {
+            id = msg.getId();
+            if (id < received)
+                return; // ignore duplicate
+        }
+        if (expected == 0 || received < expected) {
+            std::cout << '[' << id << "]: " << msg.getBody() << std::endl;
+            received++;
+            if (received == expected) {
+                e.getReceiver().close();
+                e.getConnection().close();
+            }
+        }
+    }
+};
+
+static void parse_options(int argc, char **argv, int &count, std::string &addr);
+
+int main(int argc, char **argv) {
+    try {
+        int messageCount = 100;
+        std::string address("localhost:5672/examples");
+        parse_options(argc, argv, messageCount, address);
+        Recv recv(address, messageCount);
+        Container(recv).run();
+    } catch (const std::exception& e) {
+        std::cerr << e.what() << std::endl;
+        return 1;
+    }
+}
+
+
+static void usage() {
+    std::cout << "Usage: simple_recv -m message_count -a address:" << std::endl;
+    exit (1);
+}
+
+
+static void parse_options(int argc, char **argv, int &count, std::string &addr) {
+    int c, i;
+    for (i = 1; i < argc; i++) {
+        if (strlen(argv[i]) == 2 && argv[i][0] == '-') {
+            c = argv[i][1];
+            const char *nextarg = i < argc ? argv[i+1] : NULL;
+
+            switch (c) {
+            case 'a':
+                if (!nextarg) usage();
+                addr = nextarg;
+                i++;
+                break;
+            case 'm':
+                if (!nextarg) usage();
+                unsigned newc;
+                if (sscanf( nextarg, "%d", &newc) != 1) usage();
+                count = newc;
+                i++;
+                break;
+            default:
+                usage();
+            }
+        }
+        else usage();
+    }
+}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8074793b/examples/cpp/simple_send.cpp
----------------------------------------------------------------------
diff --git a/examples/cpp/simple_send.cpp b/examples/cpp/simple_send.cpp
new file mode 100644
index 0000000..eb87c8a
--- /dev/null
+++ b/examples/cpp/simple_send.cpp
@@ -0,0 +1,122 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "proton/cpp/Container.h"
+#include "proton/cpp/MessagingHandler.h"
+#include "proton/cpp/Connection.h"
+
+#include <iostream>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+
+using namespace proton::reactor;
+
+class Send : public MessagingHandler {
+  private:
+    std::string url;
+    int sent;
+    int confirmed;
+    int total;
+  public:
+
+    Send(const std::string &s, int c) : url(s), sent(0), confirmed(0), total(c) {}
+
+    void onStart(Event &e) {
+        e.getContainer().createSender(url);
+    }
+
+    void onSendable(Event &e) {
+        Sender sender = e.getSender();
+        while (sender.getCredit() && sent < total) {
+            Message msg;
+            msg.setId(sent + 1);
+            // TODO: fancy map body content as in Python example.  Simple binary for now.
+            const char *bin = "some arbitrary binary data";
+            msg.setBody(bin, strlen(bin));
+            sender.send(msg);
+            sent++;
+        }
+    }
+
+    void onAccepted(Event &e) {
+        confirmed++;
+        if (confirmed == total) {
+            std::cout << "all messages confirmed" << std::endl;
+            e.getConnection().close();
+        }
+    }
+
+    void onDisconnected(Event &e) {
+        sent = confirmed;
+    }
+};
+
+static void parse_options(int argc, char **argv, int &count, std::string &addr);
+
+int main(int argc, char **argv) {
+    try {
+        int messageCount = 100;
+        std::string address("localhost:5672/examples");
+        parse_options(argc, argv, messageCount, address);
+        Send send(address, messageCount);
+        Container(send).run();
+    } catch (const std::exception& e) {
+        std::cerr << e.what() << std::endl;
+        return 1;
+    }
+}
+
+
+static void usage() {
+    std::cout << "Usage: simple_send -m message_count -a address:" << std::endl;
+    exit (1);
+}
+
+
+static void parse_options(int argc, char **argv, int &count, std::string &addr) {
+    int c, i;
+    for (i = 1; i < argc; i++) {
+        if (strlen(argv[i]) == 2 && argv[i][0] == '-') {
+            c = argv[i][1];
+            const char *nextarg = i < argc ? argv[i+1] : NULL;
+
+            switch (c) {
+            case 'a':
+                if (!nextarg) usage();
+                addr = nextarg;
+                i++;
+                break;
+            case 'm':
+                if (!nextarg) usage();
+                unsigned newc;
+                if (sscanf( nextarg, "%d", &newc) != 1) usage();
+                count = newc;
+                i++;
+                break;
+            default:
+                usage();
+            }
+        }
+        else usage();
+    }
+}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8074793b/examples/go/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/examples/go/CMakeLists.txt b/examples/go/CMakeLists.txt
new file mode 100644
index 0000000..464ed7c
--- /dev/null
+++ b/examples/go/CMakeLists.txt
@@ -0,0 +1,29 @@
+#
+# 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.
+#
+
+# FIXME aconway 2015-05-20:
+# - use proton build for Go includes & libs.
+# - pre-build go libraries? Respect user GOPATH?
+
+if(BUILD_GO)
+  add_test(
+    NAME go_example_test
+    COMMAND ${GO_TEST} example_test.go -rpath ${CMAKE_BINARY_DIR}/proton-c
+    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
+endif()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8074793b/examples/go/example_test.go
----------------------------------------------------------------------
diff --git a/examples/go/example_test.go b/examples/go/example_test.go
new file mode 100644
index 0000000..8879c38
--- /dev/null
+++ b/examples/go/example_test.go
@@ -0,0 +1,284 @@
+/*
+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.
+*/
+
+// Tests to verify that example code behaves as expected.
+// Run in this directory with `go test example_test.go`
+//
+package main
+
+import (
+	"bufio"
+	"bytes"
+	"flag"
+	"fmt"
+	"io"
+	"io/ioutil"
+	"math/rand"
+	"net"
+	"os"
+	"os/exec"
+	"path"
+	"path/filepath"
+	"reflect"
+	"testing"
+	"time"
+)
+
+func panicIf(err error) {
+	if err != nil {
+		panic(err)
+	}
+}
+
+// A demo broker process
+type broker struct {
+	cmd    *exec.Cmd
+	addr   string
+	runerr chan error
+	err    error
+}
+
+// Try to connect to the broker to verify it is ready, give up after a timeout
+func (b *broker) check() error {
+	dialer := net.Dialer{Deadline: time.Now().Add(time.Second * 10)}
+	for {
+		c, err := dialer.Dial("tcp", b.addr)
+		if err == nil { // Success
+			c.Close()
+			return nil
+		}
+		select {
+		case runerr := <-b.runerr: // Broker exited.
+			return runerr
+		default:
+		}
+		if neterr, ok := err.(net.Error); ok && neterr.Timeout() { // Running but timed out
+			b.stop()
+			return fmt.Errorf("timed out waiting for broker")
+		}
+		time.Sleep(time.Second / 10)
+	}
+}
+
+// Start the demo broker, wait till it is listening on *addr. No-op if already started.
+func (b *broker) start() error {
+	if b.cmd == nil { // Not already started
+		// FIXME aconway 2015-04-30: better way to pick/configure a broker port.
+		b.addr = fmt.Sprintf("127.0.0.1:%d", rand.Intn(10000)+10000)
+		b.cmd = exampleCommand("event_broker", "-addr", b.addr)
+		b.runerr = make(chan error)
+		b.cmd.Stderr, b.cmd.Stdout = os.Stderr, os.Stdout
+		go func() {
+			b.runerr <- b.cmd.Run()
+		}()
+		b.err = b.check()
+	}
+	return b.err
+}
+
+func (b *broker) stop() {
+	if b != nil && b.cmd != nil {
+		b.cmd.Process.Kill()
+		b.cmd.Wait()
+	}
+}
+
+func checkEqual(want interface{}, got interface{}) error {
+	if reflect.DeepEqual(want, got) {
+		return nil
+	}
+	return fmt.Errorf("%#v != %#v", want, got)
+}
+
+// runCommand returns an exec.Cmd to run an example.
+func exampleCommand(prog string, arg ...string) *exec.Cmd {
+	build(prog + ".go")
+	args := []string{}
+	if *debug {
+		args = append(args, "-debug=true")
+	}
+	args = append(args, arg...)
+	cmd := exec.Command(exepath(prog), args...)
+	cmd.Stderr = os.Stderr
+	return cmd
+}
+
+// Run an example Go program, return the combined output as a string.
+func runExample(prog string, arg ...string) (string, error) {
+	cmd := exampleCommand(prog, arg...)
+	out, err := cmd.Output()
+	return string(out), err
+}
+
+func prefix(prefix string, err error) error {
+	if err != nil {
+		return fmt.Errorf("%s: %s", prefix, err)
+	}
+	return nil
+}
+
+func runExampleWant(want string, prog string, args ...string) error {
+	out, err := runExample(prog, args...)
+	if err != nil {
+		return fmt.Errorf("%s failed: %s: %s", prog, err, out)
+	}
+	return prefix(prog, checkEqual(want, out))
+}
+
+func exampleArgs(args ...string) []string {
+	return append(args, testBroker.addr+"/foo", testBroker.addr+"/bar", testBroker.addr+"/baz")
+}
+
+// Send then receive
+func TestExampleSendReceive(t *testing.T) {
+	if testing.Short() {
+		t.Skip("Skip demo tests in short mode")
+	}
+	testBroker.start()
+	err := runExampleWant(
+		"Received all 15 acknowledgements\n",
+		"send",
+		exampleArgs("-count", "5")...)
+	if err != nil {
+		t.Fatal(err)
+	}
+	err = runExampleWant(
+		"Listening on 3 connections\nReceived 15 messages\n",
+		"receive",
+		exampleArgs("-count", "15")...)
+	if err != nil {
+		t.Fatal(err)
+	}
+}
+
+var ready error
+
+func init() { ready = fmt.Errorf("Ready") }
+
+// Run receive in a goroutine.
+// Send ready on errchan when it is listening.
+// Send final error when it is done.
+// Returns the Cmd, caller must Wait()
+func goReceiveWant(errchan chan<- error, want string, arg ...string) *exec.Cmd {
+	cmd := exampleCommand("receive", arg...)
+	go func() {
+		pipe, err := cmd.StdoutPipe()
+		if err != nil {
+			errchan <- err
+			return
+		}
+		out := bufio.NewReader(pipe)
+		cmd.Start()
+		line, err := out.ReadString('\n')
+		if err != nil && err != io.EOF {
+			errchan <- err
+			return
+		}
+		listening := "Listening on 3 connections\n"
+		if line != listening {
+			errchan <- checkEqual(listening, line)
+			return
+		}
+		errchan <- ready
+		buf := bytes.Buffer{}
+		io.Copy(&buf, out) // Collect the rest of the output
+		errchan <- checkEqual(want, buf.String())
+		close(errchan)
+	}()
+	return cmd
+}
+
+// Start receiver first, wait till it is running, then send.
+func TestExampleReceiveSend(t *testing.T) {
+	if testing.Short() {
+		t.Skip("Skip demo tests in short mode")
+	}
+	testBroker.start()
+	recvErr := make(chan error)
+	recvCmd := goReceiveWant(recvErr,
+		"Received 15 messages\n",
+		exampleArgs("-count", "15")...)
+	defer func() {
+		recvCmd.Process.Kill()
+		recvCmd.Wait()
+	}()
+	if err := <-recvErr; err != ready { // Wait for receiver ready
+		t.Fatal(err)
+	}
+	err := runExampleWant(
+		"Received all 15 acknowledgements\n",
+		"send",
+		exampleArgs("-count", "5")...)
+	if err != nil {
+		t.Fatal(err)
+	}
+	if err := <-recvErr; err != nil {
+		t.Fatal(err)
+	}
+}
+
+func exepath(relative string) string {
+	if binDir == "" {
+		panic("bindir not set, cannot run example binaries")
+	}
+	return path.Join(binDir, relative)
+}
+
+var testBroker *broker
+var binDir, exampleDir string
+var built map[string]bool
+
+func init() {
+	built = make(map[string]bool)
+}
+
+func build(prog string) {
+	if !built[prog] {
+		args := []string{"build"}
+		if *rpath != "" {
+			args = append(args, "-ldflags", "-r "+*rpath)
+		}
+		args = append(args, path.Join(exampleDir, prog))
+		build := exec.Command("go", args...)
+		build.Dir = binDir
+		out, err := build.CombinedOutput()
+		if err != nil {
+			panic(fmt.Errorf("%v: %s", err, out))
+		}
+		built[prog] = true
+	}
+}
+
+var rpath = flag.String("rpath", "", "Runtime path for test executables")
+var debug = flag.Bool("debug", false, "Debugging output from examples")
+
+func TestMain(m *testing.M) {
+	rand.Seed(time.Now().UTC().UnixNano())
+	var err error
+	exampleDir, err = filepath.Abs(".")
+	panicIf(err)
+	binDir, err = ioutil.TempDir("", "example_test.go")
+	panicIf(err)
+	defer os.Remove(binDir) // Clean up binaries
+	testBroker = &broker{}  // Broker is started on-demand by tests.
+	testBroker.stop()
+	status := m.Run()
+	testBroker.stop()
+	os.Exit(status)
+}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8074793b/proton-c/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/CMakeLists.txt b/proton-c/CMakeLists.txt
index 1347f16..aaf9a82 100644
--- a/proton-c/CMakeLists.txt
+++ b/proton-c/CMakeLists.txt
@@ -574,6 +574,3 @@ if (BUILD_JAVASCRIPT)
   add_test (javascript-codec ${env_py} node ${pn_test_root}/javascript/codec.js)
   add_test (javascript-message ${env_py} node ${pn_test_root}/javascript/message.js)
 endif (BUILD_JAVASCRIPT)
-
-# build examples to make sure they still work
-add_subdirectory(../examples ../examples)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8074793b/proton-c/bindings/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/bindings/CMakeLists.txt b/proton-c/bindings/CMakeLists.txt
index f426ef3..e976bc7 100644
--- a/proton-c/bindings/CMakeLists.txt
+++ b/proton-c/bindings/CMakeLists.txt
@@ -109,10 +109,10 @@ if (EMSCRIPTEN_FOUND)
   set (DEFAULT_JAVASCRIPT ON)
 endif (EMSCRIPTEN_FOUND)
 
-# C++ client: very experimental.  To try, change this to "ON"
-# or provide -DBUILD_CPP=ON to CMake
-set (DEFAULT_CPP OFF)
-
+# Prerequisites for C++
+if (CMAKE_CXX_COMPILER)
+  set (DEFAULT_CPP ON)
+endif (CMAKE_CXX_COMPILER)
 
 # Shouldn't need to modify below here when adding new language binding
 foreach(BINDING ${BINDINGS})

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8074793b/proton-c/bindings/cpp/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/CMakeLists.txt b/proton-c/bindings/cpp/CMakeLists.txt
index 34123ed..f9e747c 100644
--- a/proton-c/bindings/cpp/CMakeLists.txt
+++ b/proton-c/bindings/cpp/CMakeLists.txt
@@ -17,8 +17,6 @@
 # under the License.
 #
 
-project (Proton C CXX)
-
 include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/src")
 include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/include")
 
@@ -53,21 +51,13 @@ set (qpid-proton-cpp-core
     src/Delivery.cpp
     src/Acking.cpp
     src/Transport.cpp
-    src/Logger.cpp
     src/contexts.cpp
-    src/exceptions.cpp
     src/blocking/BlockingConnection.cpp
     src/blocking/BlockingConnectionImpl.cpp
     src/blocking/BlockingLink.cpp
     src/blocking/BlockingSender.cpp
   )
 
-#set_source_files_properties (
-#  ${qpid-proton-cpp-core}
-#  PROPERTIES
-#  COMPILE_FLAGS "${COMPILE_WARNING_FLAGS} ${COMPILE_LANGUAGE_FLAGS}"
-#  )
-
 set_source_files_properties (${qpid-proton-cpp-platform} PROPERTIES LANGUAGE CXX)
 set_source_files_properties (
   ${qpid-proton-cpp-platform}
@@ -76,8 +66,6 @@ set_source_files_properties (
   COMPILE_DEFINITIONS "${PLATFORM_DEFINITIONS}"
   )
 
-
-
 add_library (
   qpid-proton-cpp SHARED
 
@@ -97,20 +85,6 @@ set_target_properties (
   LINK_FLAGS "${CATCH_UNDEFINED}"
   )
 
-add_executable (HelloWorld examples/HelloWorld.cpp)
-target_link_libraries (HelloWorld qpid-proton-cpp)
-add_executable (HelloWorldDirect examples/HelloWorldDirect.cpp)
-target_link_libraries (HelloWorldDirect qpid-proton-cpp)
-add_executable (SimpleRecv examples/SimpleRecv.cpp)
-target_link_libraries (SimpleRecv qpid-proton-cpp)
-add_executable (SimpleSend examples/SimpleSend.cpp)
-target_link_libraries (SimpleSend qpid-proton-cpp)
-add_executable (Broker examples/Broker.cpp)
-target_link_libraries (Broker qpid-proton-cpp)
-add_executable (HelloWorldBlocking examples/HelloWorldBlocking.cpp)
-target_link_libraries (HelloWorldBlocking qpid-proton-cpp)
-
-
 install (TARGETS qpid-proton-cpp
   EXPORT  proton
   ARCHIVE DESTINATION ${LIB_INSTALL_DIR}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8074793b/proton-c/bindings/cpp/README.md
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/README.md b/proton-c/bindings/cpp/README.md
new file mode 100644
index 0000000..cf16577
--- /dev/null
+++ b/proton-c/bindings/cpp/README.md
@@ -0,0 +1,24 @@
+# C++ binding for proton.
+
+This is a C++ wrapper for the proton reactor API.
+It is very similar to the python wrapper for the same API.
+
+There are [examples](../../../examples/cpp/README.md) and the header files have
+API documentation in doxygen format.
+
+# TO DO
+
+There are a number of things that remain to be done.
+
+- Type mapping between AMQP and C++ types, e.g. encoding std::map as map message.
+
+- Finish blocking API & demos.
+- API documentation, HTML docs on website.
+- FIXME and TODO notes in code, esp. error handling, missing sender/receiver/connection methods.
+
+- Valgrind for automated tests and demos.
+- More automated tests and examples.
+
+- Security: SASL/SSL support.
+- Reconnection
+

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8074793b/proton-c/bindings/cpp/examples/Broker.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/examples/Broker.cpp b/proton-c/bindings/cpp/examples/Broker.cpp
deleted file mode 100644
index 7d5214d..0000000
--- a/proton-c/bindings/cpp/examples/Broker.cpp
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- *
- * 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.
- *
- */
-
-#include "proton/cpp/Container.h"
-#include "proton/cpp/MessagingHandler.h"
-
-#include <iostream>
-#include <deque>
-#include <map>
-#include <list>
-
-
-using namespace proton::reactor;
-
-std::string generateUuid(){
-    throw "TODO: platform neutral uuid";
-}
-
-class Queue {
-  public:
-    bool dynamic;
-    typedef std::deque<Message> MsgQ;
-    typedef std::list<Sender> List;
-    MsgQ queue;
-    List consumers;
-
-    Queue(bool dyn = false) : dynamic(dyn), queue(MsgQ()), consumers(List()) {}
-
-    void subscribe(Sender &c) {
-        consumers.push_back(c);
-    }
-
-    bool unsubscribe(Sender &c) {
-        consumers.remove(c);
-        return (consumers.size() == 0 && (dynamic || queue.size() == 0));
-    }
-
-    void publish(Message &m) {
-        queue.push_back(m);
-        dispatch(0);
-    }
-
-    void dispatch(Sender *s) {
-        while (deliverTo(s)) {
-        }
-    }
-
-    bool deliverTo(Sender *consumer) {
-        // deliver to single consumer if supplied, else all consumers
-        int count = consumer ? 1 : consumers.size();
-        if (!count) return false;
-        bool result = false;
-        List::iterator it = consumers.begin();
-        if (!consumer && count) consumer = &*it;
-
-        while (queue.size()) {
-            if (consumer->getCredit()) {
-                consumer->send(queue.front());
-                queue.pop_front();
-                result = true;
-            }
-            if (--count)
-                it++;
-            else
-                return result;
-        }
-        return false;
-    }
-};
-
-class Broker : public MessagingHandler {
-  private:
-    std::string url;
-    typedef std::map<std::string, Queue *> QMap;
-    QMap queues;
-  public:
-
-    Broker(const std::string &s) : url(s), queues(QMap()) {}
-
-    void onStart(Event &e) {
-        e.getContainer().listen(url);
-    }
-
-    Queue &queue(std::string &address) {
-        QMap::iterator it = queues.find(address);
-        if (it == queues.end()) {
-            queues[address] = new Queue();
-            return *queues[address];
-        }
-        else {
-            return *it->second;
-        }
-    }
-
-    void onLinkOpening(Event &e) {
-        Link lnk = e.getLink();
-        if (lnk.isSender()) {
-            Sender sender(lnk);
-            Terminus remoteSource(lnk.getRemoteSource());
-            if (remoteSource.isDynamic()) {
-                std::string address = generateUuid();
-                lnk.getSource().setAddress(address);
-                Queue *q = new Queue(true);
-                queues[address] = q;
-                q->subscribe(sender);
-            }
-            else {
-                std::string address = remoteSource.getAddress();
-                if (!address.empty()) {
-                    lnk.getSource().setAddress(address);
-                    queue(address).subscribe(sender);
-                }
-            }
-        }
-        else {
-            std::string address = lnk.getRemoteTarget().getAddress();
-            if (!address.empty())
-                lnk.getTarget().setAddress(address);
-        }
-    }
-
-    void unsubscribe (Sender &lnk) {
-        std::string address = lnk.getSource().getAddress();
-        QMap::iterator it = queues.find(address);
-        if (it != queues.end() && it->second->unsubscribe(lnk)) {
-            delete it->second;
-            queues.erase(it);
-        }
-    }
-
-    void onLinkClosing(Event &e) {
-        Link lnk = e.getLink();
-        if (lnk.isSender()) {
-            Sender s(lnk);
-            unsubscribe(s);
-        }
-    }
-
-    void onConnectionClosing(Event &e) {
-        removeStaleConsumers(e.getConnection());
-    }
-
-    void onDisconnected(Event &e) {
-        removeStaleConsumers(e.getConnection());
-    }
-
-    void removeStaleConsumers(Connection &connection) {
-        Link l = connection.getLinkHead(Endpoint::REMOTE_ACTIVE);
-        while (l) {
-            if (l.isSender()) {
-                Sender s(l);
-                unsubscribe(s);
-            }
-            l = l.getNext(Endpoint::REMOTE_ACTIVE);
-        }
-    }
-
-    void onSendable(Event &e) {
-        Link lnk = e.getLink();
-        Sender sender(lnk);
-        std::string addr = lnk.getSource().getAddress();
-        queue(addr).dispatch(&sender);
-    }
-
-    void onMessage(Event &e) {
-        std::string addr = e.getLink().getTarget().getAddress();
-        Message msg = e.getMessage();
-        queue(addr).publish(msg);
-    }
-};
-
-int main(int argc, char **argv) {
-    Broker hw("localhost:5672");
-    Container(hw).run();
-}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8074793b/proton-c/bindings/cpp/examples/HelloWorld.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/examples/HelloWorld.cpp b/proton-c/bindings/cpp/examples/HelloWorld.cpp
deleted file mode 100644
index 1fc124b..0000000
--- a/proton-c/bindings/cpp/examples/HelloWorld.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- *
- * 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.
- *
- */
-
-#include "proton/cpp/Container.h"
-#include "proton/cpp/MessagingHandler.h"
-
-#include <iostream>
-
-
-using namespace proton::reactor;
-
-class HelloWorld : public MessagingHandler {
-  private:
-    std::string server;
-    std::string address;
-  public:
-
-    HelloWorld(const std::string &s, const std::string &addr) : server(s), address(addr) {}
-
-    void onStart(Event &e) {
-        Connection conn = e.getContainer().connect(server);
-        e.getContainer().createReceiver(conn, address);
-        e.getContainer().createSender(conn, address);
-    }
-
-    void onSendable(Event &e) {
-        Message m;
-        m.setBody("Hello World!");
-        e.getSender().send(m);
-        e.getSender().close();
-    }
-
-    void onMessage(Event &e) {
-        std::string body = e.getMessage().getBody();
-        std::cout << body << std::endl;
-        e.getConnection().close();
-    }
-
-};
-
-int main(int argc, char **argv) {
-    HelloWorld hw("localhost:5672", "examples");
-    Container(hw).run();
-}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8074793b/proton-c/bindings/cpp/examples/HelloWorldBlocking.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/examples/HelloWorldBlocking.cpp b/proton-c/bindings/cpp/examples/HelloWorldBlocking.cpp
deleted file mode 100644
index a3f729c..0000000
--- a/proton-c/bindings/cpp/examples/HelloWorldBlocking.cpp
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- *
- * 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.
- *
- */
-
-#include "proton/cpp/Container.h"
-#include "proton/cpp/MessagingHandler.h"
-#include "proton/cpp/BlockingSender.h"
-
-#include <iostream>
-
-
-using namespace proton::reactor;
-
-class HelloWorldBlocking : public MessagingHandler {
-  private:
-    std::string server;
-    std::string address;
-  public:
-
-    HelloWorldBlocking(const std::string &s, const std::string &addr) : server(s), address(addr) {}
-
-    void onStart(Event &e) {
-        Connection conn = e.getContainer().connect(server);
-        e.getContainer().createReceiver(conn, address);
-    }
-
-    void onMessage(Event &e) {
-        std::string body = e.getMessage().getBody();
-        std::cout << body << std::endl;
-        e.getConnection().close();
-    }
-
-};
-
-int main(int argc, char **argv) {
-    std::string url("localhost:5672");
-    std::string addr("examples");
-    BlockingConnection conn = BlockingConnection(url);
-    BlockingSender sender = conn.createSender(addr);
-    Message m;
-    m.setBody("Hello World!");
-    sender.send(m);
-    conn.close();
-
-    // Temporary hack until blocking receiver available
-    HelloWorldBlocking hw("localhost:5672", "examples");
-    Container(hw).run();
-}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8074793b/proton-c/bindings/cpp/examples/HelloWorldDirect.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/examples/HelloWorldDirect.cpp b/proton-c/bindings/cpp/examples/HelloWorldDirect.cpp
deleted file mode 100644
index a695dd0..0000000
--- a/proton-c/bindings/cpp/examples/HelloWorldDirect.cpp
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- *
- * 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.
- *
- */
-
-#include "proton/cpp/MessagingHandler.h"
-#include "proton/cpp/Container.h"
-
-//#include "proton/cpp/Acceptor.h"
-#include <iostream>
-
-
-using namespace proton::reactor;
-
-
-class HelloWorldDirect : public MessagingHandler {
-  private:
-    std::string url;
-    Acceptor acceptor;
-  public:
-
-    HelloWorldDirect(const std::string &u) : url(u) {}
-
-    void onStart(Event &e) {
-        acceptor = e.getContainer().listen(url);
-        e.getContainer().createSender(url);
-    }
-
-    void onSendable(Event &e) {
-        Message m;
-        m.setBody("Hello World!");
-        e.getSender().send(m);
-        e.getSender().close();
-    }
-
-    void onMessage(Event &e) {
-        std::string body = e.getMessage().getBody();
-        std::cout << body << std::endl;
-    }
-
-    void onAccepted(Event &e) {
-        e.getConnection().close();
-    }
-
-    void onConnectionClosed(Event &e) {
-        acceptor.close();
-    }
-
-};
-
-int main(int argc, char **argv) {
-    HelloWorldDirect hwd("localhost:8888/examples");
-    Container(hwd).run();
-}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8074793b/proton-c/bindings/cpp/examples/SimpleRecv.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/examples/SimpleRecv.cpp b/proton-c/bindings/cpp/examples/SimpleRecv.cpp
deleted file mode 100644
index 22778f0..0000000
--- a/proton-c/bindings/cpp/examples/SimpleRecv.cpp
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- *
- * 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.
- *
- */
-
-#include "proton/cpp/Container.h"
-#include "proton/cpp/MessagingHandler.h"
-#include "proton/cpp/Link.h"
-
-#include <iostream>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-
-using namespace proton::reactor;
-
-class Recv : public MessagingHandler {
-  private:
-    std::string url;
-    int expected;
-    int received;
-  public:
-
-    Recv(const std::string &s, int c) : url(s), expected(c), received(0) {}
-
-    void onStart(Event &e) {
-        e.getContainer().createReceiver(url);
-    }
-
-    void onMessage(Event &e) {
-        uint64_t id = 0;
-        Message msg = e.getMessage();
-        if (msg.getIdType() == PN_ULONG) {
-            id = msg.getId();
-            if (id < received)
-                return; // ignore duplicate
-        }
-        if (expected == 0 || received < expected) {
-            std::cout << '[' << id << "]: " << msg.getBody() << std::endl;
-            received++;
-            if (received == expected) {
-                e.getReceiver().close();
-                e.getConnection().close();
-            }
-        }
-    }
-};
-
-static void parse_options(int argc, char **argv, int &count, std::string &addr);
-
-int main(int argc, char **argv) {
-    int messageCount = 100;
-    std::string address("localhost:5672/examples");
-    parse_options(argc, argv, messageCount, address);
-    Recv recv(address, messageCount);
-    Container(recv).run();
-}
-
-
-static void usage() {
-    std::cout << "Usage: SimpleRecv -m message_count -a address:" << std::endl;
-    exit (1);
-}
-
-
-static void parse_options(int argc, char **argv, int &count, std::string &addr) {
-    int c, i;
-    for (i = 1; i < argc; i++) {
-        if (strlen(argv[i]) == 2 && argv[i][0] == '-') {
-            c = argv[i][1];
-            const char *nextarg = i < argc ? argv[i+1] : NULL;
-
-            switch (c) {
-            case 'a':
-                if (!nextarg) usage();
-                addr = nextarg;
-                i++;
-                break;
-            case 'm':
-                if (!nextarg) usage();
-                unsigned newc;
-                if (sscanf( nextarg, "%d", &newc) != 1) usage();
-                count = newc;
-                i++;
-                break;
-            default:
-                usage();
-            }
-        }
-        else usage();
-    }
-}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8074793b/proton-c/bindings/cpp/examples/SimpleSend.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/examples/SimpleSend.cpp b/proton-c/bindings/cpp/examples/SimpleSend.cpp
deleted file mode 100644
index 89ca39d..0000000
--- a/proton-c/bindings/cpp/examples/SimpleSend.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- *
- * 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.
- *
- */
-
-#include "proton/cpp/Container.h"
-#include "proton/cpp/MessagingHandler.h"
-#include "proton/cpp/Connection.h"
-
-#include <iostream>
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-
-using namespace proton::reactor;
-
-class Send : public MessagingHandler {
-  private:
-    std::string url;
-    int sent;
-    int confirmed;
-    int total;
-  public:
-
-    Send(const std::string &s, int c) : url(s), sent(0), confirmed(0), total(c) {}
-
-    void onStart(Event &e) {
-        e.getContainer().createSender(url);
-    }
-
-    void onSendable(Event &e) {
-        Sender sender = e.getSender();
-        while (sender.getCredit() && sent < total) {
-            Message msg;
-            msg.setId(sent + 1);
-            // TODO: fancy map body content as in Python example.  Simple binary for now.
-            const char *bin = "some arbitrary binary data";
-            msg.setBody(bin, strlen(bin));
-            sender.send(msg);
-            sent++;
-        }
-    }
-
-    void onAccepted(Event &e) {
-        confirmed++;
-        if (confirmed == total) {
-            std::cout << "all messages confirmed" << std::endl;
-            e.getConnection().close();
-        }
-    }
-
-    void onDisconnected(Event &e) {
-        sent = confirmed;
-    }
-};
-
-static void parse_options(int argc, char **argv, int &count, std::string &addr);
-
-int main(int argc, char **argv) {
-    int messageCount = 100;
-    std::string address("localhost:5672/examples");
-    parse_options(argc, argv, messageCount, address);
-    Send send(address, messageCount);
-    Container(send).run();
-}
-
-
-static void usage() {
-    std::cout << "Usage: SimpleSend -m message_count -a address:" << std::endl;
-    exit (1);
-}
-
-
-static void parse_options(int argc, char **argv, int &count, std::string &addr) {
-    int c, i;
-    for (i = 1; i < argc; i++) {
-        if (strlen(argv[i]) == 2 && argv[i][0] == '-') {
-            c = argv[i][1];
-            const char *nextarg = i < argc ? argv[i+1] : NULL;
-
-            switch (c) {
-            case 'a':
-                if (!nextarg) usage();
-                addr = nextarg;
-                i++;
-                break;
-            case 'm':
-                if (!nextarg) usage();
-                unsigned newc;
-                if (sscanf( nextarg, "%d", &newc) != 1) usage();
-                count = newc;
-                i++;
-                break;
-            default:
-                usage();
-            }
-        }
-        else usage();
-    }
-}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8074793b/proton-c/bindings/cpp/include/proton/cpp/Delivery.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Delivery.h b/proton-c/bindings/cpp/include/proton/cpp/Delivery.h
index 8171dd5..089ae1b 100644
--- a/proton-c/bindings/cpp/include/proton/cpp/Delivery.h
+++ b/proton-c/bindings/cpp/include/proton/cpp/Delivery.h
@@ -24,8 +24,6 @@
 #include "proton/cpp/ImportExport.h"
 #include "proton/cpp/ProtonHandle.h"
 
-#include "ProtonImplRef.h"
-
 #include "proton/delivery.h"
 #include "proton/disposition.h"
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8074793b/proton-c/bindings/cpp/include/proton/cpp/Handle.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Handle.h b/proton-c/bindings/cpp/include/proton/cpp/Handle.h
index 77b7814..2cf3f99 100644
--- a/proton-c/bindings/cpp/include/proton/cpp/Handle.h
+++ b/proton-c/bindings/cpp/include/proton/cpp/Handle.h
@@ -28,6 +28,7 @@ namespace proton {
 namespace reactor {
 
 template <class> class PrivateImplRef;
+template <class> class ProtonImplRef;
 
 /**
  * A handle is like a pointer: refers to an underlying implementation object.

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8074793b/proton-c/bindings/cpp/include/proton/cpp/exceptions.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/exceptions.h b/proton-c/bindings/cpp/include/proton/cpp/exceptions.h
index 713c5c5..9fdef94 100644
--- a/proton-c/bindings/cpp/include/proton/cpp/exceptions.h
+++ b/proton-c/bindings/cpp/include/proton/cpp/exceptions.h
@@ -21,34 +21,27 @@
  * under the License.
  *
  */
-#include "proton/cpp/ImportExport.h"
-#include <string>
-#include <exception>
+#include <stdexcept>
 
 namespace proton {
 namespace reactor {
 
-class ProtonException : public std::exception
+class ProtonException : public std::runtime_error
 {
   public:
-    PROTON_CPP_EXTERN explicit ProtonException(const std::string& message=std::string()) throw();
-    PROTON_CPP_EXTERN virtual ~ProtonException() throw();
-    PROTON_CPP_EXTERN virtual const char* what() const throw();
-
-  private:
-    const std::string message;
+    explicit ProtonException(const std::string& msg) throw() : std::runtime_error(msg) {}
 };
 
 class MessageReject : public ProtonException
 {
   public:
-    PROTON_CPP_EXTERN explicit MessageReject(const std::string& message=std::string()) throw();
+    explicit MessageReject(const std::string& msg) throw() : ProtonException(msg) {}
 };
 
 class MessageRelease : public ProtonException
 {
   public:
-    PROTON_CPP_EXTERN explicit MessageRelease(const std::string& message=std::string()) throw();
+    explicit MessageRelease(const std::string& msg) throw() : ProtonException(msg) {}
 };
 
 }} // namespace proton::reactor

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8074793b/proton-c/bindings/cpp/src/Connector.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Connector.cpp b/proton-c/bindings/cpp/src/Connector.cpp
index 8ebdfb6..fc6eed3 100644
--- a/proton-c/bindings/cpp/src/Connector.cpp
+++ b/proton-c/bindings/cpp/src/Connector.cpp
@@ -27,7 +27,6 @@
 #include "Connector.h"
 #include "ConnectionImpl.h"
 #include "Url.h"
-#include "LogInternal.h"
 
 namespace proton {
 namespace reactor {
@@ -46,7 +45,6 @@ void Connector::connect() {
     Url url(address);
     std::string hostname = url.getHost() + ":" + url.getPort();
     pn_connection_set_hostname(conn, hostname.c_str());
-    PN_CPP_LOG(info, "connecting to " << hostname << "...");
     transport = new Transport();
     transport->bind(connection);
     connection.impl->transport = transport;
@@ -57,16 +55,13 @@ void Connector::onConnectionLocalOpen(Event &e) {
     connect();
 }
 
-void Connector::onConnectionRemoteOpen(Event &e) {
-    PN_CPP_LOG(info, "connected to " << e.getConnection().getHostname());
-}
+void Connector::onConnectionRemoteOpen(Event &e) {}
 
 void Connector::onConnectionInit(Event &e) {
 }
 
 void Connector::onTransportClosed(Event &e) {
     // TODO: prepend with reconnect logic
-    PN_CPP_LOG(info, "Disconnected");
     pn_connection_release(connection.impl->pnConnection);
     // No more interaction, so drop our counted reference.
     connection = Connection();

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8074793b/proton-c/bindings/cpp/src/Container.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Container.cpp b/proton-c/bindings/cpp/src/Container.cpp
index e72f484..5a551a1 100644
--- a/proton-c/bindings/cpp/src/Container.cpp
+++ b/proton-c/bindings/cpp/src/Container.cpp
@@ -27,7 +27,6 @@
 #include "proton/cpp/exceptions.h"
 #include "ContainerImpl.h"
 #include "PrivateImplRef.h"
-#include "LogInternal.h"
 
 #include "Connector.h"
 #include "contexts.h"

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8074793b/proton-c/bindings/cpp/src/ContainerImpl.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/ContainerImpl.cpp b/proton-c/bindings/cpp/src/ContainerImpl.cpp
index 1424dbb..ce69928 100644
--- a/proton-c/bindings/cpp/src/ContainerImpl.cpp
+++ b/proton-c/bindings/cpp/src/ContainerImpl.cpp
@@ -25,8 +25,8 @@
 #include "proton/cpp/MessagingAdapter.h"
 #include "proton/cpp/Acceptor.h"
 #include "proton/cpp/exceptions.h"
-#include "LogInternal.h"
 
+#include "Msg.h"
 #include "ContainerImpl.h"
 #include "ConnectionImpl.h"
 #include "Connector.h"

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8074793b/proton-c/bindings/cpp/src/Delivery.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Delivery.cpp b/proton-c/bindings/cpp/src/Delivery.cpp
index 990e394..d0b2f3c 100644
--- a/proton-c/bindings/cpp/src/Delivery.cpp
+++ b/proton-c/bindings/cpp/src/Delivery.cpp
@@ -21,6 +21,7 @@
 
 #include "proton/cpp/Delivery.h"
 #include "proton/delivery.h"
+#include "ProtonImplRef.h"
 
 namespace proton {
 namespace reactor {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8074793b/proton-c/bindings/cpp/src/LogInternal.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/LogInternal.h b/proton-c/bindings/cpp/src/LogInternal.h
deleted file mode 100644
index 427f90b..0000000
--- a/proton-c/bindings/cpp/src/LogInternal.h
+++ /dev/null
@@ -1,51 +0,0 @@
-#ifndef PROTON_CPP_LOG_INTERNAL_H
-#define PROTON_CPP_LOG_INTERNAL_H
-
-/*
- *
- * 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.
- *
- */
-
-#include "Msg.h"
-
-namespace proton {
-namespace reactor {
-
-enum Level { trace, debug, info, notice, warning, error, critical };
-
-class Logger
-{
-public:
-    // TODO: build out to be ultra configurable as for corresponding QPID class + Statement
-    static void log(Level level, const char* file, int line, const char* function, const std::string& message);
-private:
-    //This class has only one instance so no need to copy
-    Logger();
-    ~Logger();
-
-    Logger(const Logger&);
-    Logger operator=(const Logger&);
-};
-
-// Just do simple logging for now
-#define PN_CPP_LOG(LEVEL, MESSAGE) Logger::log(LEVEL, 0, 0, 0, ::proton::reactor::Msg() << MESSAGE)
-
-}} // namespace proton::reactor
-
-#endif  /*!PROTON_CPP_LOG_INTERNAL_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8074793b/proton-c/bindings/cpp/src/Logger.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Logger.cpp b/proton-c/bindings/cpp/src/Logger.cpp
deleted file mode 100644
index 2671b2e..0000000
--- a/proton-c/bindings/cpp/src/Logger.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- *
- * 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.
- *
- */
-
-#include "LogInternal.h"
-#include <cstdlib>
-
-namespace proton {
-namespace reactor {
-
-namespace {
-bool levelSet = false;
-Level logLevel = error;
-Level getLogLevel() {
-    if (!levelSet) {
-        levelSet = true;
-        const char *l = getenv("PROTON_CPP_LOG_LEVEL");
-        if (l && l[0] != 0 && l[1] == 0) {
-            char low = '0' + trace;
-            char high = '0' + critical;
-            if (*l >= low && *l <= high)
-                logLevel = (Level) (*l - '0');
-        }
-    }
-    return logLevel;
-}
-
-} // namespace
-
-
-void Logger::log(Level level, const char* file, int line, const char* function, const std::string& message)
-{
-    if (level >= getLogLevel()) {
-        std::cout << message << std::endl;
-        std::cout.flush();
-    }
-}
-
-}} // namespace proton::reactor

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8074793b/proton-c/bindings/cpp/src/exceptions.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/exceptions.cpp b/proton-c/bindings/cpp/src/exceptions.cpp
deleted file mode 100644
index c19e61d..0000000
--- a/proton-c/bindings/cpp/src/exceptions.cpp
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- *
- * 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.
- *
- */
-#include "proton/cpp/exceptions.h"
-
-namespace proton {
-namespace reactor {
-
-ProtonException::ProtonException(const std::string& msg) throw() : message(msg) {}
-ProtonException::~ProtonException() throw() {}
-const char* ProtonException::what() const throw() { return message.c_str(); }
-
-MessageReject::MessageReject(const std::string& msg) throw() : ProtonException(msg) {}
-MessageRelease::MessageRelease(const std::string& msg) throw() : ProtonException(msg) {}
-
-}} // namespace proton::reactor


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


[20/50] [abbrv] qpid-proton git commit: PROTON-860: allow acceptor to be configured for ssl

Posted by ac...@apache.org.
PROTON-860: allow acceptor to be configured for ssl


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/995e00d7
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/995e00d7
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/995e00d7

Branch: refs/heads/cjansen-cpp-client
Commit: 995e00d70b6f9005e116e352507127d9c930a4db
Parents: d5bd60d
Author: Gordon Sim <gs...@redhat.com>
Authored: Wed May 6 12:50:11 2015 +0100
Committer: Gordon Sim <gs...@redhat.com>
Committed: Thu May 14 13:24:55 2015 +0100

----------------------------------------------------------------------
 proton-c/bindings/python/proton/reactor.py | 12 +++++++++---
 proton-c/include/proton/reactor.h          |  2 ++
 proton-c/src/reactor/acceptor.c            | 15 +++++++++++++++
 3 files changed, 26 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/995e00d7/proton-c/bindings/python/proton/reactor.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/proton/reactor.py b/proton-c/bindings/python/proton/reactor.py
index 09cbc23..0145a25 100644
--- a/proton-c/bindings/python/proton/reactor.py
+++ b/proton-c/bindings/python/proton/reactor.py
@@ -51,6 +51,9 @@ class Acceptor(Wrapper):
     def __init__(self, impl):
         Wrapper.__init__(self, impl)
 
+    def set_ssl_domain(self, ssl_domain):
+        pn_acceptor_set_ssl_domain(self._impl, ssl_domain._domain)
+
     def close(self):
         pn_acceptor_close(self._impl)
 
@@ -742,10 +745,13 @@ class Container(Reactor):
         on the interface and port specified.
         """
         url = Url(url)
+        acceptor = self.acceptor(url.host, url.port)
         ssl_config = ssl_domain
-        if not ssl_config and url.scheme == 'amqps':
-            ssl_config = self.ssl_domain
-        return self.acceptor(url.host, url.port)
+        if not ssl_config and url.scheme == 'amqps' and self.ssl:
+            ssl_config = self.ssl.server
+        if ssl_config:
+            acceptor.set_ssl_domain(ssl_config)
+        return acceptor
 
     def do_work(self, timeout=None):
         if timeout:

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/995e00d7/proton-c/include/proton/reactor.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/reactor.h b/proton-c/include/proton/reactor.h
index 36ee336..59b2282 100644
--- a/proton-c/include/proton/reactor.h
+++ b/proton-c/include/proton/reactor.h
@@ -26,6 +26,7 @@
 #include <proton/type_compat.h>
 #include <proton/event.h>
 #include <proton/selectable.h>
+#include <proton/ssl.h>
 
 #ifdef __cplusplus
 extern "C" {
@@ -85,6 +86,7 @@ PN_EXTERN void pn_reactor_run(pn_reactor_t *reactor);
 PN_EXTERN pn_task_t *pn_reactor_schedule(pn_reactor_t *reactor, int delay, pn_handler_t *handler);
 
 
+PN_EXTERN void pn_acceptor_set_ssl_domain(pn_acceptor_t *acceptor, pn_ssl_domain_t *domain);
 PN_EXTERN void pn_acceptor_close(pn_acceptor_t *acceptor);
 
 PN_EXTERN pn_timer_t *pn_timer(pn_collector_t *collector);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/995e00d7/proton-c/src/reactor/acceptor.c
----------------------------------------------------------------------
diff --git a/proton-c/src/reactor/acceptor.c b/proton-c/src/reactor/acceptor.c
index f7202d4..31fa0cc 100644
--- a/proton-c/src/reactor/acceptor.c
+++ b/proton-c/src/reactor/acceptor.c
@@ -29,6 +29,7 @@
 pn_selectable_t *pn_reactor_selectable_transport(pn_reactor_t *reactor, pn_socket_t sock, pn_transport_t *transport);
 
 PN_HANDLE(PNI_ACCEPTOR_HANDLER)
+PN_HANDLE(PNI_ACCEPTOR_SSL_DOMAIN)
 
 void pni_acceptor_readable(pn_selectable_t *sel) {
   pn_reactor_t *reactor = (pn_reactor_t *) pni_selectable_get_context(sel);
@@ -36,9 +37,15 @@ void pni_acceptor_readable(pn_selectable_t *sel) {
   pn_socket_t sock = pn_accept(pn_reactor_io(reactor), pn_selectable_get_fd(sel), name, 1024);
   pn_handler_t *handler = (pn_handler_t *) pn_record_get(pn_selectable_attachments(sel), PNI_ACCEPTOR_HANDLER);
   if (!handler) { handler = pn_reactor_get_handler(reactor); }
+  pn_record_t *record = pn_selectable_attachments(sel);
+  pn_ssl_domain_t *ssl_domain = (pn_ssl_domain_t *) pn_record_get(record, PNI_ACCEPTOR_SSL_DOMAIN);
   pn_connection_t *conn = pn_reactor_connection(reactor, handler);
   pn_transport_t *trans = pn_transport();
   pn_transport_set_server(trans);
+  if (ssl_domain) {
+    pn_ssl_t *ssl = pn_ssl(trans);
+    pn_ssl_init(ssl, ssl_domain, 0);
+  }
   pn_transport_bind(trans, conn);
   pn_decref(trans);
   pn_reactor_selectable_transport(reactor, sock, trans);
@@ -80,3 +87,11 @@ void pn_acceptor_close(pn_acceptor_t *acceptor) {
     pn_reactor_update(reactor, sel);
   }
 }
+
+void pn_acceptor_set_ssl_domain(pn_acceptor_t *acceptor, pn_ssl_domain_t *domain)
+{
+  pn_selectable_t *sel = (pn_selectable_t *) acceptor;
+  pn_record_t *record = pn_selectable_attachments(sel);
+  pn_record_def(record, PNI_ACCEPTOR_SSL_DOMAIN, PN_WEAKREF);
+  pn_record_set(record, PNI_ACCEPTOR_SSL_DOMAIN, domain);
+}


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


[23/50] [abbrv] qpid-proton git commit: PROTON-827: Fix link in bindings/go/README.md for changed branch go -> go1

Posted by ac...@apache.org.
PROTON-827: Fix link in bindings/go/README.md for changed branch go -> go1

'go get' tool will pull go1 instead of master if it exists, so this works better.


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/145c017d
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/145c017d
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/145c017d

Branch: refs/heads/cjansen-cpp-client
Commit: 145c017d2e92479c54701639a2af37081691d872
Parents: d443772
Author: Alan Conway <ac...@redhat.com>
Authored: Thu May 14 11:02:16 2015 -0400
Committer: Alan Conway <ac...@redhat.com>
Committed: Thu May 14 11:02:24 2015 -0400

----------------------------------------------------------------------
 proton-c/bindings/go/README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/145c017d/proton-c/bindings/go/README.md
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/README.md b/proton-c/bindings/go/README.md
index 4ac15a1..a5580e9 100644
--- a/proton-c/bindings/go/README.md
+++ b/proton-c/bindings/go/README.md
@@ -2,4 +2,4 @@
 
 Experimental work on the Go language binding has been moved to the `go1` branch
 until it is ready for use. You can `git checkout go1` on your git clone, or
-browse at https://github.com/apache/qpid-proton/blob/go/proton-c/bindings/go1/README.md
+browse at https://github.com/apache/qpid-proton/blob/go1/go/README.md


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


[04/50] [abbrv] qpid-proton git commit: PROTON-884: add explicit cast for win build

Posted by ac...@apache.org.
PROTON-884: add explicit cast for win build


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/c8f2d8a3
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/c8f2d8a3
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/c8f2d8a3

Branch: refs/heads/cjansen-cpp-client
Commit: c8f2d8a3aea0ffedc4b498e8146bfc0baa1562c3
Parents: d39f222
Author: Chuck Rolke <cr...@redhat.com>
Authored: Mon May 11 09:37:16 2015 -0400
Committer: Chuck Rolke <cr...@redhat.com>
Committed: Mon May 11 09:37:16 2015 -0400

----------------------------------------------------------------------
 proton-c/bindings/python/cproton.i | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/c8f2d8a3/proton-c/bindings/python/cproton.i
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/cproton.i b/proton-c/bindings/python/cproton.i
index 357cd82..814dbe3 100644
--- a/proton-c/bindings/python/cproton.i
+++ b/proton-c/bindings/python/cproton.i
@@ -318,7 +318,7 @@ int pn_ssl_get_peer_hostname(pn_ssl_t *ssl, char *OUTPUT, size_t *OUTPUT_SIZE);
 
   PyObject *pn_transport_get_pytracer(pn_transport_t *transport) {
     pn_record_t *record = pn_transport_attachments(transport);
-    PyObject *obj = pn_record_get(record, PNI_PYTRACER);
+    PyObject *obj = (PyObject *)pn_record_get(record, PNI_PYTRACER);
     if (obj) {
       Py_XINCREF(obj);
       return obj;


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


[22/50] [abbrv] qpid-proton git commit: Allow setup.py for bundling proton

Posted by ac...@apache.org.
Allow setup.py for bundling proton

As of now, it's not possible to install python-qpid-proton if
libqpid-proton is not present in the system. To be more precises, it's
possible to build python-qpid-proton using cmake, upload it and beg to
the gods of OPs that the required (and correct) shared library will be
present in the system.

This patch adds to python-qpid-proton the ability to download, build and
install qpid-proton if the required version is not present in the
system. It does this by checking - using pkg-config - whether the
required version is installed and if not, it goes to downloading the
package from the official apache source and builds it using cmake.

As nasty as it sounds, this process is not strange in the Python
community. Very famous - and way more used - libraries like PyZMQ (from
which this work took lots of inspiration) do this already in a fairly
more complex way.

This first step is quite simple, it checks, downloads and builds using
the standard tools. It's enabled just for linux and it does not use
fancy flags. Future enhancements could take care of improving the
implementation and extending it to support other systems.


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/2e2ba9c7
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/2e2ba9c7
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/2e2ba9c7

Branch: refs/heads/cjansen-cpp-client
Commit: 2e2ba9c7597293883fc51b231786f7cd49796e28
Parents: d5bd60d
Author: Flavio Percoco <fl...@gmail.com>
Authored: Wed May 13 18:45:07 2015 +0200
Committer: Flavio Percoco <fl...@gmail.com>
Committed: Thu May 14 16:24:45 2015 +0200

----------------------------------------------------------------------
 proton-c/bindings/python/PYZMQ_LICENSE.BSD      |  32 ++++
 proton-c/bindings/python/setup.py               | 188 ++++++++++++++++++-
 proton-c/bindings/python/setuputils/__init__.py |   0
 proton-c/bindings/python/setuputils/bundle.py   |  84 +++++++++
 proton-c/bindings/python/setuputils/log.py      |  46 +++++
 proton-c/bindings/python/setuputils/misc.py     | 137 ++++++++++++++
 6 files changed, 485 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2e2ba9c7/proton-c/bindings/python/PYZMQ_LICENSE.BSD
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/PYZMQ_LICENSE.BSD b/proton-c/bindings/python/PYZMQ_LICENSE.BSD
new file mode 100644
index 0000000..a0a3790
--- /dev/null
+++ b/proton-c/bindings/python/PYZMQ_LICENSE.BSD
@@ -0,0 +1,32 @@
+PyZMQ is licensed under the terms of the Modified BSD License (also known as
+New or Revised BSD), as follows:
+
+Copyright (c) 2009-2012, Brian Granger, Min Ragan-Kelley
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+Redistributions of source code must retain the above copyright notice, this
+list of conditions and the following disclaimer.
+
+Redistributions in binary form must reproduce the above copyright notice, this
+list of conditions and the following disclaimer in the documentation and/or
+other materials provided with the distribution.
+
+Neither the name of PyZMQ nor the names of its contributors may be used to
+endorse or promote products derived from this software without specific prior
+written permission.
+
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2e2ba9c7/proton-c/bindings/python/setup.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/setup.py b/proton-c/bindings/python/setup.py
index cdfa104..e61edc7 100755
--- a/proton-c/bindings/python/setup.py
+++ b/proton-c/bindings/python/setup.py
@@ -16,12 +16,195 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-#
 
+"""
+python-qpid-proton setup script
+
+DISCLAIMER: This script took lots of inspirations from PyZMQ, which is licensed
+under the 'MODIFIED BSD LICENSE'.
+
+Although inspired by the work in PyZMQ, this script and the modules it depends
+on were largely simplified to meet the requirements of the library.
+
+The default behavior of this script is to build the registered `_cproton`
+extension using the system qpid-proton library. However, before doing that, the
+script will try to discover the available qpid-proton's version and whether it's
+suitable for the version of this library. This allows us to have a tight release
+between the versions of the bindings and qpid-proton's version.
+
+The versions used to verify this are in `setuputils.bundle` and they should be
+increased on every release. Note that `bundled_version` matches the current
+released version. The motivation behind this is that we don't know how many
+new releases will be made in the `0.9` series, therefore we need to target the
+latest possible.
+
+If qpid-proton is found in the system and the available versions are match the
+required ones, then the install process will continue normally.
+
+If the available versions are not good for the bindings or the library is
+missing, then the following will happen:
+
+The setup script will attempt to download qpid-proton's tar - see
+`setuputils.bundle.fetch_libqpid_proton` - and it'll build it and then install
+it. Note that if this is being executed outside a virtualenv, it'll install it
+on whatever `distutils.sysconfig.PREFIX` is available. Once qpid-proton has been
+built and installed, the extension build will proceed normally as if the library
+would have been found. The extension will use the recently built library.
+
+While the above removes the need of *always* having qpid-proton installed, it does
+not solve the need of having `cmake` and `swig` installed to make this setup work.
+Eventually, future works should remove the need of `cmake` by collecting sources
+and letting `distutils` do the compilation.
+
+On a final note, it's important to say that in either case, the library paths will
+be added as `rpaths` to the `_cproton` shared library. Mainly because we need to
+make sure `libqpid-proton.so` will be found and loaded when it's not installed in
+the main system.
+
+From the Python side, this scripts overrides 1 command - build_ext - and it adds a
+new one. The later - Configure - is called from the former to setup/discover what's
+in the system. The rest of the comands and steps are done normally without any kind
+of monkey patching.
+"""
+
+import os
+import subprocess
+import sys
+
+import distutils.spawn as ds_spawn
+import distutils.sysconfig as ds_sys
 from distutils.core import setup, Extension
+from distutils.command.build import build
+from distutils.command.build_ext import build_ext
+
+from setuputils import bundle
+from setuputils import log
+from setuputils import misc
+
+
+class CustomBuildOrder(build):
+    # NOTE(flaper87): The sole purpose of this class is to re-order
+    # the commands execution so that `build_ext` is executed *before*
+    # build_py. We need this to make sure `cproton.py` is generated
+    # before the python modules are collected. Otherwise, it won't
+    # be installed.
+    sub_commands = [
+        ('build_ext', build.has_ext_modules),
+        ('build_py', build.has_pure_modules),
+        ('build_clib', build.has_c_libraries),
+        ('build_scripts', build.has_scripts),
+    ]
+
+
+class CheckingBuildExt(build_ext):
+    """Subclass build_ext to build qpid-proton using `cmake`"""
+
+    def build_extensions(self):
+        self.check_extensions_list(self.extensions)
+
+        for ext in self.extensions:
+            self.build_extension(ext)
+
+    def build_cmake_proton(self, ext):
+        if not ds_spawn.find_executable('cmake'):
+            log.fatal("cmake needed for this script it work")
+
+        try:
+            ds_spawn.spawn(['cmake'] + ext.extra_compile_args + ext.sources)
+            ds_spawn.spawn(['make', 'install'])
+        except ds_spawn.DistutilsExecError:
+            msg = "Error while running cmake"
+            msg += "\nrun 'setup.py build --help' for build options"
+            log.fatal(msg)
+
+    def build_extension(self, ext):
+        if ext.name == 'cmake_cproton':
+            return self.build_cmake_proton(ext)
+
+        return build_ext.build_extension(self, ext)
+
+    def run(self):
+        # Discover qpid-proton in the system
+        self.distribution.run_command('configure')
+        build_ext.run(self)
+
+
+class Configure(build_ext):
+    description = "Discover Qpid Proton version"
+
+    def bundle_libqpid_proton_extension(self):
+        bundledir = "bundled"
+        ext_modules = self.distribution.ext_modules
+
+        log.info("Using bundled libqpid-proton")
+
+        if not os.path.exists(bundledir):
+            os.makedirs(bundledir)
+
+        bundle.fetch_libqpid_proton(bundledir)
+
+        libqpid_proton_dir = os.path.join(bundledir, 'qpid-proton')
+
+        # NOTE(flaper87): Find prefix. We need to run make ourselves
+        libqpid_proton = Extension(
+            'cmake_cproton',
+            sources = [libqpid_proton_dir],
+
+            # NOTE(flaper87): Disable all bindings, set the prefix to whatever
+            # is in `distutils.sysconfig.PREFIX` and finally, disable testing
+            # as well. The python binding will be built by this script later
+            # on. Don't let cmake do it.
+            extra_compile_args = ['-DCMAKE_INSTALL_PREFIX:PATH=%s' % ds_sys.PREFIX,
+                                  '-DBUILD_PYTHON=False',
+                                  '-DBUILD_JAVA=False',
+                                  '-DBUILD_PERL=False',
+                                  '-DBUILD_RUBY=False',
+                                  '-DBUILD_PHP=False',
+                                  '-DBUILD_JAVASCRIPT=False',
+                                  '-DBUILD_TESTING=False',
+            ]
+        )
+
+        # NOTE(flaper87): Register this new extension and make
+        # sure it's built and installed *before* `_cproton`.
+        self.distribution.ext_modules.insert(0, libqpid_proton)
+
+    def set_cproton_settings(self, prefix=None):
+        settings = misc.settings_from_prefix(prefix)
+        ext = self.distribution.ext_modules[-1]
+
+        for k, v in settings.items():
+            setattr(ext, k, v)
+
+    def check_qpid_proton_version(self):
+        """check the qpid_proton version"""
+
+        target_version = bundle.bundled_version_str
+        return (misc.pkg_config_version(max_version=target_version) and
+                misc.pkg_config_version(atleast=bundle.min_qpid_proton_str))
+
+
+    @property
+    def bundle_proton(self):
+        return sys.platform == 'linux2' and not self.check_qpid_proton_version()
+
+    def run(self):
+        prefix = None
+        if self.bundle_proton:
+            self.bundle_libqpid_proton_extension()
+            prefix = ds_sys.PREFIX
+
+        self.set_cproton_settings(prefix)
+
+
+# NOTE(flaper87): Override `build_ext` and add `configure`
+cmdclass = {'configure': Configure,
+            'build': CustomBuildOrder,
+            'build_ext': CheckingBuildExt}
+
 
 setup(name='python-qpid-proton',
-      version='0.9',
+      version=bundle.min_qpid_proton_str,
       description='An AMQP based messaging library.',
       author='Apache Qpid',
       author_email='proton@qpid.apache.org',
@@ -32,5 +215,6 @@ setup(name='python-qpid-proton',
       classifiers=["License :: OSI Approved :: Apache Software License",
                    "Intended Audience :: Developers",
                    "Programming Language :: Python"],
+      cmdclass = cmdclass,
       ext_modules=[Extension('_cproton', ['cproton.i'],
                              libraries=['qpid-proton'])])

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2e2ba9c7/proton-c/bindings/python/setuputils/__init__.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/setuputils/__init__.py b/proton-c/bindings/python/setuputils/__init__.py
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2e2ba9c7/proton-c/bindings/python/setuputils/bundle.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/setuputils/bundle.py b/proton-c/bindings/python/setuputils/bundle.py
new file mode 100644
index 0000000..498e163
--- /dev/null
+++ b/proton-c/bindings/python/setuputils/bundle.py
@@ -0,0 +1,84 @@
+#-----------------------------------------------------------------------------
+#  Copyright (C) PyZMQ Developers
+#  Distributed under the terms of the Modified BSD License.
+#
+#  This bundling code is largely adapted from pyzmq-static's get.sh by
+#  Brandon Craig-Rhodes, which is itself BSD licensed.
+#-----------------------------------------------------------------------------
+
+#-----------------------------------------------------------------------------
+#  This bundling code is largely adapted from pyzmq's code
+#  PyZMQ Developers, which is itself Modified BSD licensed.
+#-----------------------------------------------------------------------------
+
+import os
+import shutil
+import stat
+import sys
+import tarfile
+from glob import glob
+from subprocess import Popen, PIPE
+
+try:
+    # py2
+    from urllib2 import urlopen
+except ImportError:
+    # py3
+    from urllib.request import urlopen
+
+from . import log
+
+
+#-----------------------------------------------------------------------------
+# Constants
+#-----------------------------------------------------------------------------
+min_qpid_proton = (0, 9)
+min_qpid_proton_str = "%i.%i" % min_qpid_proton
+
+bundled_version = (0,9,1)
+bundled_version_str = "%i.%i.%i" % (0,9,1)
+libqpid_proton = "qpid-proton-%s.tar.gz" % bundled_version_str
+libqpid_proton_url = ("http://www.apache.org/dist/qpid/proton/%s/%s" %
+                      (bundled_version_str, libqpid_proton))
+
+HERE = os.path.dirname(__file__)
+ROOT = os.path.dirname(HERE)
+
+
+def fetch_archive(savedir, url, fname):
+    """Download an archive to a specific location
+
+    :param savedir: Destination dir
+    :param url: URL where the archive should be downloaded from
+    :param fname: Archive's filename
+    """
+    dest = os.path.join(savedir, fname)
+
+    if os.path.exists(dest):
+        log.info("already have %s" % fname)
+        return dest
+
+    log.info("fetching %s into %s" % (url, savedir))
+    if not os.path.exists(savedir):
+        os.makedirs(savedir)
+    req = urlopen(url)
+    with open(dest, 'wb') as f:
+        f.write(req.read())
+    return dest
+
+
+def fetch_libqpid_proton(savedir):
+    """Download qpid-proton to `savedir`."""
+    dest = os.path.join(savedir, 'qpid-proton')
+    if os.path.exists(dest):
+        log.info("already have %s" % dest)
+        return
+    fname = fetch_archive(savedir, libqpid_proton_url, libqpid_proton)
+    tf = tarfile.open(fname)
+    member = tf.firstmember.path
+    if member == '.':
+        member = tf.getmembers()[1].path
+    with_version = os.path.join(savedir, member)
+    tf.extractall(savedir)
+    tf.close()
+    shutil.move(with_version, dest)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2e2ba9c7/proton-c/bindings/python/setuputils/log.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/setuputils/log.py b/proton-c/bindings/python/setuputils/log.py
new file mode 100644
index 0000000..1e051d4
--- /dev/null
+++ b/proton-c/bindings/python/setuputils/log.py
@@ -0,0 +1,46 @@
+#-----------------------------------------------------------------------------
+#  Copyright (C) PyZMQ Developers
+#  Distributed under the terms of the Modified BSD License.
+#
+#  This bundling code is largely adapted from pyzmq-static's get.sh by
+#  Brandon Craig-Rhodes, which is itself BSD licensed.
+#-----------------------------------------------------------------------------
+
+#-----------------------------------------------------------------------------
+# Logging (adapted from h5py: http://h5py.googlecode.com)
+#-----------------------------------------------------------------------------
+
+#-----------------------------------------------------------------------------
+#  This log code is largely adapted from pyzmq's code
+#  PyZMQ Developers, which is itself Modified BSD licensed.
+#-----------------------------------------------------------------------------
+
+
+import os
+import sys
+import logging
+
+
+logger = logging.getLogger()
+if os.environ.get('DEBUG'):
+    logger.setLevel(logging.DEBUG)
+else:
+    logger.setLevel(logging.INFO)
+    logger.addHandler(logging.StreamHandler(sys.stderr))
+
+
+def debug(msg):
+    logger.debug(msg)
+
+
+def info(msg):
+    logger.info(msg)
+
+
+def fatal(msg, code=1):
+    logger.error("Fatal: " + msg)
+    exit(code)
+
+
+def warn(msg):
+    logger.error("Warning: " + msg)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/2e2ba9c7/proton-c/bindings/python/setuputils/misc.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/setuputils/misc.py b/proton-c/bindings/python/setuputils/misc.py
new file mode 100644
index 0000000..3ebb160
--- /dev/null
+++ b/proton-c/bindings/python/setuputils/misc.py
@@ -0,0 +1,137 @@
+#-----------------------------------------------------------------------------
+#  Copyright (C) PyZMQ Developers
+#  Distributed under the terms of the Modified BSD License.
+#
+#  This bundling code is largely adapted from pyzmq-static's get.sh by
+#  Brandon Craig-Rhodes, which is itself BSD licensed.
+#-----------------------------------------------------------------------------
+
+#-----------------------------------------------------------------------------
+#  These functions were largely adapted from pyzmq's code
+#  PyZMQ Developers, which is itself Modified BSD licensed.
+#-----------------------------------------------------------------------------
+
+
+import os
+import subprocess
+import sys
+
+from . import log
+
+
+def settings_from_prefix(prefix=None):
+    """Load appropriate library/include settings from qpid-proton prefix
+
+    NOTE: Funcion adapted from PyZMQ, which is itself Modified BSD licensed.
+
+    :param prefix: The install prefix where the dependencies are expected to be
+    """
+    settings = {}
+    settings['libraries'] = []
+    settings['include_dirs'] = []
+    settings['library_dirs'] = []
+    settings['swig_opts'] = []
+    settings['runtime_library_dirs'] = []
+    settings['extra_link_args'] = []
+
+    if sys.platform.startswith('win'):
+        settings['libraries'].append('libqpid-proton')
+
+        if prefix:
+            settings['include_dirs'] += [os.path.join(prefix, 'include')]
+            settings['library_dirs'] += [os.path.join(prefix, 'lib')]
+    else:
+
+        # If prefix is not explicitly set, pull it from pkg-config by default.
+
+        if not prefix:
+            try:
+                cmd = 'pkg-config --variable=prefix --print-errors libqpid-proton'.split()
+                p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+            except OSError as e:
+                if e.errno == errno.ENOENT:
+                    log.info("pkg-config not found")
+                else:
+                    log.warn("Running pkg-config failed - %s." % e)
+                p = None
+            if p is not None:
+                if p.wait():
+                    log.info("Did not find libqpid-proton via pkg-config:")
+                    log.info(p.stderr.read().decode())
+                else:
+                    prefix = p.stdout.readline().strip().decode()
+                    log.info("Using qpid-proton-prefix %s (found via pkg-config)." % prefix)
+
+        settings['libraries'].append('qpid-proton')
+        # add pthread on freebsd
+        if sys.platform.startswith('freebsd'):
+            settings['libraries'].append('pthread')
+
+        if sys.platform == 'sunos5':
+          if platform.architecture()[0] == '32bit':
+            settings['extra_link_args'] += ['-m32']
+          else:
+            settings['extra_link_args'] += ['-m64']
+        if prefix:
+            settings['include_dirs'] += [os.path.join(prefix, 'include')]
+            settings['library_dirs'] += [os.path.join(prefix, 'lib')]
+            settings['library_dirs'] += [os.path.join(prefix, 'lib64')]
+
+        else:
+            if sys.platform == 'darwin' and os.path.isdir('/opt/local/lib'):
+                # allow macports default
+                settings['include_dirs'] += ['/opt/local/include']
+                settings['library_dirs'] += ['/opt/local/lib']
+                settings['library_dirs'] += ['/opt/local/lib64']
+            if os.environ.get('VIRTUAL_ENV', None):
+                # find libqpid_proton installed in virtualenv
+                env = os.environ['VIRTUAL_ENV']
+                settings['include_dirs'] += [os.path.join(env, 'include')]
+                settings['library_dirs'] += [os.path.join(env, 'lib')]
+                settings['library_dirs'] += [os.path.join(env, 'lib64')]
+
+        if sys.platform != 'darwin':
+            settings['runtime_library_dirs'] += [
+                os.path.abspath(x) for x in settings['library_dirs']
+            ]
+
+    for d in settings['include_dirs']:
+        settings['swig_opts'] += ['-I' + d]
+
+    return settings
+
+
+def pkg_config_version(atleast=None, max_version=None):
+    """Check the qpid_proton version using pkg-config
+
+    This function returns True/False depending on whether
+    the library is found and atleast/max_version are met.
+
+    :param atleast: The minimum required version
+    :param max_version: The maximum supported version. This
+        basically represents the target version.
+    """
+
+    if atleast and max_version:
+        log.error('Specify either atleast or max_version')
+
+    try:
+        cmd = ['pkg-config',
+               '--%s-version=%s' % (atleast and 'atleast' or 'max',
+                                    atleast or max_version),
+               'libqpid-proton']
+        p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+    except OSError as e:
+        if e.errno == errno.ENOENT:
+            log.info("pkg-config not found")
+        else:
+            log.warn("Running pkg-config failed - %s." % e)
+        return False
+
+    if p.wait():
+        log.info("Did not find libqpid-proton via pkg-config:")
+        log.info(p.stderr.read().decode())
+        return False
+
+    log.info("Using libqpid-proton (found via pkg-config).")
+    return True


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


[08/50] [abbrv] qpid-proton git commit: modify PN_CLASSDEF macro to provide accessor for the pn_class_t

Posted by ac...@apache.org.
modify PN_CLASSDEF macro to provide accessor for the pn_class_t


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/0e155e29
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/0e155e29
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/0e155e29

Branch: refs/heads/cjansen-cpp-client
Commit: 0e155e292ffbb2e3b6c054e47cad29ff3fc2aef5
Parents: 1fe0aa2
Author: Rafael Schloming <rh...@alum.mit.edu>
Authored: Tue May 12 10:56:39 2015 -0400
Committer: Rafael Schloming <rh...@alum.mit.edu>
Committed: Tue May 12 10:56:39 2015 -0400

----------------------------------------------------------------------
 proton-c/include/proton/object.h | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0e155e29/proton-c/include/proton/object.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/object.h b/proton-c/include/proton/object.h
index 48d2872..83c3cba 100644
--- a/proton-c/include/proton/object.h
+++ b/proton-c/include/proton/object.h
@@ -101,7 +101,7 @@ static int PREFIX ## _inspect_cast(void *object, pn_string_t *str) {      \
   }                                                                       \
 }                                                                         \
                                                                           \
-PREFIX ## _t *PREFIX ## _new(void) {                                      \
+const pn_class_t *PREFIX ## __class(void) {                               \
   static const pn_class_t clazz = {                                       \
     #PREFIX,                                                              \
     CID_ ## PREFIX,                                                       \
@@ -117,7 +117,12 @@ PREFIX ## _t *PREFIX ## _new(void) {                                      \
     PREFIX ## _compare_cast,                                              \
     PREFIX ## _inspect_cast                                               \
   };                                                                      \
-  return (PREFIX ## _t *) pn_class_new(&clazz, sizeof(PREFIX ## _t));     \
+  return &clazz;                                                          \
+}                                                                         \
+                                                                          \
+PREFIX ## _t *PREFIX ## _new(void) {                                      \
+  return (PREFIX ## _t *) pn_class_new(PREFIX ## __class(),               \
+                                       sizeof(PREFIX ## _t));             \
 }
 
 #define PN_CLASS(PREFIX) {                      \


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


[25/50] [abbrv] qpid-proton git commit: NO-JIRA: Update Windows CI badge to only report master branch

Posted by ac...@apache.org.
NO-JIRA: Update Windows CI badge to only report master branch


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/1e4042ab
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/1e4042ab
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/1e4042ab

Branch: refs/heads/cjansen-cpp-client
Commit: 1e4042ab02e19f1a19a47b5b14fa68e08691b4f3
Parents: 0aa8592
Author: Andrew Stitcher <as...@apache.org>
Authored: Fri May 15 12:03:59 2015 -0400
Committer: Andrew Stitcher <as...@apache.org>
Committed: Fri May 15 12:03:59 2015 -0400

----------------------------------------------------------------------
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1e4042ab/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 4f020f7..53bceac 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@ Qpid Proton - AMQP messaging toolkit
 
 Linux Build | Windows Build
 ------------|--------------
-[![Linux Build Status](https://travis-ci.org/apache/qpid-proton.svg?branch=master)](https://travis-ci.org/apache/qpid-proton) | [![Windows Build Status](https://ci.appveyor.com/api/projects/status/owb4mohqyxrnql98?svg=true)](https://ci.appveyor.com/project/ke4qqq/qpid-proton)
+[![Linux Build Status](https://travis-ci.org/apache/qpid-proton.svg?branch=master)](https://travis-ci.org/apache/qpid-proton) | [![Windows Build Status](https://ci.appveyor.com/api/projects/status/owb4mohqyxrnql98/branch/master?svg=true)](https://ci.appveyor.com/project/ke4qqq/qpid-proton)
 
 Qpid Proton is a high-performance, lightweight messaging library. It can be
 used in the widest range of messaging applications, including brokers, client


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


[40/50] [abbrv] qpid-proton git commit: PROTON-885: allow pip to set the install path for proton

Posted by ac...@apache.org.
PROTON-885: allow pip to set the install path for proton


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/a21bd427
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/a21bd427
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/a21bd427

Branch: refs/heads/cjansen-cpp-client
Commit: a21bd4272838c71212be954931e811277a94eb70
Parents: 26a0622
Author: Flavio Percoco <fl...@gmail.com>
Authored: Wed May 27 13:11:14 2015 -0400
Committer: Ken Giusti <kg...@apache.org>
Committed: Wed May 27 13:11:14 2015 -0400

----------------------------------------------------------------------
 proton-c/bindings/python/setup.py             | 12 +++++++-----
 proton-c/bindings/python/setuputils/bundle.py |  2 +-
 2 files changed, 8 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a21bd427/proton-c/bindings/python/setup.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/setup.py b/proton-c/bindings/python/setup.py
index e61edc7..09fa76a 100755
--- a/proton-c/bindings/python/setup.py
+++ b/proton-c/bindings/python/setup.py
@@ -133,7 +133,9 @@ class Configure(build_ext):
     description = "Discover Qpid Proton version"
 
     def bundle_libqpid_proton_extension(self):
-        bundledir = "bundled"
+        base = self.get_finalized_command('build').build_base
+        install = self.get_finalized_command('install').install_base
+        bundledir = os.path.join(base, "bundled")
         ext_modules = self.distribution.ext_modules
 
         log.info("Using bundled libqpid-proton")
@@ -154,7 +156,7 @@ class Configure(build_ext):
             # is in `distutils.sysconfig.PREFIX` and finally, disable testing
             # as well. The python binding will be built by this script later
             # on. Don't let cmake do it.
-            extra_compile_args = ['-DCMAKE_INSTALL_PREFIX:PATH=%s' % ds_sys.PREFIX,
+            extra_compile_args = ['-DCMAKE_INSTALL_PREFIX:PATH=%s' % install,
                                   '-DBUILD_PYTHON=False',
                                   '-DBUILD_JAVA=False',
                                   '-DBUILD_PERL=False',
@@ -168,6 +170,7 @@ class Configure(build_ext):
         # NOTE(flaper87): Register this new extension and make
         # sure it's built and installed *before* `_cproton`.
         self.distribution.ext_modules.insert(0, libqpid_proton)
+        return install
 
     def set_cproton_settings(self, prefix=None):
         settings = misc.settings_from_prefix(prefix)
@@ -191,8 +194,7 @@ class Configure(build_ext):
     def run(self):
         prefix = None
         if self.bundle_proton:
-            self.bundle_libqpid_proton_extension()
-            prefix = ds_sys.PREFIX
+            prefix = self.bundle_libqpid_proton_extension()
 
         self.set_cproton_settings(prefix)
 
@@ -204,7 +206,7 @@ cmdclass = {'configure': Configure,
 
 
 setup(name='python-qpid-proton',
-      version=bundle.min_qpid_proton_str,
+      version=bundle.bundled_version_str,
       description='An AMQP based messaging library.',
       author='Apache Qpid',
       author_email='proton@qpid.apache.org',

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a21bd427/proton-c/bindings/python/setuputils/bundle.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/setuputils/bundle.py b/proton-c/bindings/python/setuputils/bundle.py
index 498e163..920744d 100644
--- a/proton-c/bindings/python/setuputils/bundle.py
+++ b/proton-c/bindings/python/setuputils/bundle.py
@@ -36,7 +36,7 @@ min_qpid_proton = (0, 9)
 min_qpid_proton_str = "%i.%i" % min_qpid_proton
 
 bundled_version = (0,9,1)
-bundled_version_str = "%i.%i.%i" % (0,9,1)
+bundled_version_str = "%i.%i.%i" % bundled_version
 libqpid_proton = "qpid-proton-%s.tar.gz" % bundled_version_str
 libqpid_proton_url = ("http://www.apache.org/dist/qpid/proton/%s/%s" %
                       (bundled_version_str, libqpid_proton))


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


[31/50] [abbrv] qpid-proton git commit: PROTON-883: Wrap pn_transport_peek for Ruby.

Posted by ac...@apache.org.
PROTON-883: Wrap pn_transport_peek for Ruby.

Returns an array consisting of the number of bytes returned an a String
packed with the bytes in the buffer.


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/585b306b
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/585b306b
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/585b306b

Branch: refs/heads/cjansen-cpp-client
Commit: 585b306bd22f500cdfc268c759ed2b9c7738940e
Parents: ff159e8
Author: Darryl L. Pierce <mc...@gmail.com>
Authored: Mon May 11 10:01:46 2015 -0400
Committer: Darryl L. Pierce <mc...@gmail.com>
Committed: Tue May 19 08:06:49 2015 -0400

----------------------------------------------------------------------
 proton-c/bindings/ruby/ruby.i | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/585b306b/proton-c/bindings/ruby/ruby.i
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/ruby.i b/proton-c/bindings/ruby/ruby.i
index e0ffb17..7380068 100644
--- a/proton-c/bindings/ruby/ruby.i
+++ b/proton-c/bindings/ruby/ruby.i
@@ -273,6 +273,20 @@ ssize_t pn_transport_input(pn_transport_t *transport, char *STRING, size_t LENGT
 %}
 %ignore pn_transport_output;
 
+%rename(pn_transport_peek) wrap_pn_transport_peek;
+%inline %{
+  int wrap_pn_transport_peek(pn_transport_t *transport, char *OUTPUT, size_t *OUTPUT_SIZE) {
+    ssize_t sz = pn_transport_peek(transport, OUTPUT, OUTPUT_SIZE);
+    if(sz >= 0) {
+      *OUTPUT_SIZE = sz;
+    } else {
+      *OUTPUT_SIZE = 0;
+    }
+    return sz;
+  }
+%}
+%ignore pn_transport_peek;
+
 %rename(pn_delivery) wrap_pn_delivery;
 %inline %{
   pn_delivery_t *wrap_pn_delivery(pn_link_t *link, char *STRING, size_t LENGTH) {


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


[19/50] [abbrv] qpid-proton git commit: NO-JIRA: updated go README for change of branch.

Posted by ac...@apache.org.
NO-JIRA: updated go README for change of branch.

Using go1 instead of go, go get will download from this branch.


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/d5bd60d9
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/d5bd60d9
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/d5bd60d9

Branch: refs/heads/cjansen-cpp-client
Commit: d5bd60d9aa001533ce23bb202465756eec02903b
Parents: 5741434
Author: Alan Conway <ac...@redhat.com>
Authored: Wed May 13 16:30:30 2015 -0400
Committer: Alan Conway <ac...@redhat.com>
Committed: Wed May 13 16:30:30 2015 -0400

----------------------------------------------------------------------
 proton-c/bindings/go/README.md | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d5bd60d9/proton-c/bindings/go/README.md
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/README.md b/proton-c/bindings/go/README.md
index 9fd0a0f..4ac15a1 100644
--- a/proton-c/bindings/go/README.md
+++ b/proton-c/bindings/go/README.md
@@ -1,5 +1,5 @@
 # *EXPERIMENTAL* Go binding for proton
 
-Experimental work on the Go language binding has been moved to the `go` branch
-until it is ready for use. You can `git checkout go` on your git clone, or
-browse at https://github.com/apache/qpid-proton/blob/go/proton-c/bindings/go/README.md
+Experimental work on the Go language binding has been moved to the `go1` branch
+until it is ready for use. You can `git checkout go1` on your git clone, or
+browse at https://github.com/apache/qpid-proton/blob/go/proton-c/bindings/go1/README.md


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


[35/50] [abbrv] qpid-proton git commit: PROTON-883: Fixed using a pointer value as a size - It's not clear to me how the warning message this caused went ignored - It's also not clear to me why this error passed the tests without crashing, probably the

Posted by ac...@apache.org.
PROTON-883: Fixed using a pointer value as a size
- It's not clear to me how the warning message this caused went ignored
- It's also not clear to me why this error passed the tests without
  crashing, probably the ruby tests need improving.


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/e349a021
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/e349a021
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/e349a021

Branch: refs/heads/cjansen-cpp-client
Commit: e349a02120d306babb0219238f172c26cc8b49ea
Parents: c1f9ed4
Author: Andrew Stitcher <as...@apache.org>
Authored: Thu May 21 16:27:25 2015 -0400
Committer: Andrew Stitcher <as...@apache.org>
Committed: Thu May 21 16:27:25 2015 -0400

----------------------------------------------------------------------
 proton-c/bindings/ruby/ruby.i | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e349a021/proton-c/bindings/ruby/ruby.i
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/ruby.i b/proton-c/bindings/ruby/ruby.i
index 7380068..7205f57 100644
--- a/proton-c/bindings/ruby/ruby.i
+++ b/proton-c/bindings/ruby/ruby.i
@@ -276,7 +276,7 @@ ssize_t pn_transport_input(pn_transport_t *transport, char *STRING, size_t LENGT
 %rename(pn_transport_peek) wrap_pn_transport_peek;
 %inline %{
   int wrap_pn_transport_peek(pn_transport_t *transport, char *OUTPUT, size_t *OUTPUT_SIZE) {
-    ssize_t sz = pn_transport_peek(transport, OUTPUT, OUTPUT_SIZE);
+    ssize_t sz = pn_transport_peek(transport, OUTPUT, *OUTPUT_SIZE);
     if(sz >= 0) {
       *OUTPUT_SIZE = sz;
     } else {


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


[27/50] [abbrv] qpid-proton git commit: NO-JIRA: Make Windows CI link go to master branch too

Posted by ac...@apache.org.
NO-JIRA: Make Windows CI link go to master branch too


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/cb6c172f
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/cb6c172f
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/cb6c172f

Branch: refs/heads/cjansen-cpp-client
Commit: cb6c172f97e9ca4896d389f7f7d2cc0453dfec7d
Parents: 894a463
Author: Andrew Stitcher <as...@apache.org>
Authored: Fri May 15 13:36:57 2015 -0400
Committer: Andrew Stitcher <as...@apache.org>
Committed: Fri May 15 13:36:57 2015 -0400

----------------------------------------------------------------------
 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/cb6c172f/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 53bceac..9f95939 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@ Qpid Proton - AMQP messaging toolkit
 
 Linux Build | Windows Build
 ------------|--------------
-[![Linux Build Status](https://travis-ci.org/apache/qpid-proton.svg?branch=master)](https://travis-ci.org/apache/qpid-proton) | [![Windows Build Status](https://ci.appveyor.com/api/projects/status/owb4mohqyxrnql98/branch/master?svg=true)](https://ci.appveyor.com/project/ke4qqq/qpid-proton)
+[![Linux Build Status](https://travis-ci.org/apache/qpid-proton.svg?branch=master)](https://travis-ci.org/apache/qpid-proton) | [![Windows Build Status](https://ci.appveyor.com/api/projects/status/github/apache/qpid-proton?branch=master&svg=true)](https://ci.appveyor.com/project/ke4qqq/qpid-proton/branch/master)
 
 Qpid Proton is a high-performance, lightweight messaging library. It can be
 used in the widest range of messaging applications, including brokers, client


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


[06/50] [abbrv] qpid-proton git commit: PROTON-877: Move client outcome processing to output side - Also add some (somewhat imperfect) tests

Posted by ac...@apache.org.
PROTON-877: Move client outcome processing to output side
- Also add some (somewhat imperfect) tests


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/520f0d8e
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/520f0d8e
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/520f0d8e

Branch: refs/heads/cjansen-cpp-client
Commit: 520f0d8e3d215dbd38b8ae0d9222f5a66d860c66
Parents: 196ef80
Author: Andrew Stitcher <as...@apache.org>
Authored: Fri May 8 17:12:02 2015 -0400
Committer: Andrew Stitcher <as...@apache.org>
Committed: Mon May 11 15:55:59 2015 -0400

----------------------------------------------------------------------
 proton-c/src/sasl/sasl.c            | 15 ++++++----
 tests/python/proton_tests/engine.py | 47 ++++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/520f0d8e/proton-c/src/sasl/sasl.c
----------------------------------------------------------------------
diff --git a/proton-c/src/sasl/sasl.c b/proton-c/src/sasl/sasl.c
index ae3a025..4a2a2f0 100644
--- a/proton-c/src/sasl/sasl.c
+++ b/proton-c/src/sasl/sasl.c
@@ -337,8 +337,13 @@ static void pni_post_sasl_frame(pn_transport_t *transport)
       pn_post_frame(transport, SASL_FRAME_TYPE, 0, "DL[B]", SASL_OUTCOME, sasl->outcome);
       pni_emit(transport);
       break;
-    case SASL_NONE:
     case SASL_RECVED_OUTCOME:
+      if (sasl->last_state < SASL_POSTED_INIT) {
+        desired_state = SASL_POSTED_INIT;
+        continue;
+      }
+      break;
+    case SASL_NONE:
       return;
     }
     sasl->last_state = desired_state;
@@ -575,9 +580,8 @@ int pn_do_mechanisms(pn_transport_t *transport, uint8_t frame_type, uint16_t cha
       pni_process_mechanisms(transport, pn_string_get(mechs))) {
     pni_sasl_set_desired_state(transport, SASL_POSTED_INIT);
   } else {
-    sasl->last_state = SASL_RECVED_OUTCOME;
-    sasl->halt = true;
-    pn_transport_close_tail(transport);
+    sasl->outcome = PN_SASL_PERM;
+    pni_sasl_set_desired_state(transport, SASL_RECVED_OUTCOME);
   }
 
   pn_free(mechs);
@@ -617,8 +621,7 @@ int pn_do_outcome(pn_transport_t *transport, uint8_t frame_type, uint16_t channe
 
   pni_sasl_t *sasl = transport->sasl;
   sasl->outcome = (pn_sasl_outcome_t) outcome;
-  sasl->last_state = SASL_RECVED_OUTCOME;
-  sasl->halt = true;
+  pni_sasl_set_desired_state(transport, SASL_RECVED_OUTCOME);
 
   return 0;
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/520f0d8e/tests/python/proton_tests/engine.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/engine.py b/tests/python/proton_tests/engine.py
index 05c8e19..924b3bc 100644
--- a/tests/python/proton_tests/engine.py
+++ b/tests/python/proton_tests/engine.py
@@ -2505,3 +2505,50 @@ class SaslEventTest(CollectorTest):
       self.drain()
     p = transport.pending()
     self.expect()
+
+  def testPipelinedServerReadFirst(self):
+    if "java" in sys.platform:
+      raise Skipped()
+    conn = Connection()
+    conn.collect(self.collector)
+    transport = Transport(Transport.CLIENT)
+    s = transport.sasl()
+    s.allowed_mechs("ANONYMOUS PLAIN")
+    transport.bind(conn)
+    self.expect(Event.CONNECTION_INIT, Event.CONNECTION_BOUND)
+    transport.push('AMQP\x03\x01\x00\x00\x00\x00\x00\x1c\x02\x01\x00\x00\x00S@'
+                   '\xc0\x0f\x01\xe0\x0c\x01\xa3\tANONYMOUS\x00\x00\x00\x10'
+                   '\x02\x01\x00\x00\x00SD\xc0\x03\x01P\x00AMQP\x00\x01\x00'
+                   '\x00')
+    self.expect(Event.TRANSPORT)
+    p = transport.pending()
+    bytes = transport.peek(p)
+    transport.pop(p)
+
+    server = Transport(Transport.SERVER)
+    server.push(bytes)
+    assert server.sasl().outcome == SASL.OK
+
+  def testPipelinedServerWriteFirst(self):
+    if "java" in sys.platform:
+      raise Skipped()
+    conn = Connection()
+    conn.collect(self.collector)
+    transport = Transport(Transport.CLIENT)
+    s = transport.sasl()
+    s.allowed_mechs("ANONYMOUS")
+    transport.bind(conn)
+    p = transport.pending()
+    bytes = transport.peek(p)
+    transport.pop(p)
+    self.expect(Event.CONNECTION_INIT, Event.CONNECTION_BOUND, Event.TRANSPORT)
+    transport.push('AMQP\x03\x01\x00\x00\x00\x00\x00\x1c\x02\x01\x00\x00\x00S@'
+                   '\xc0\x0f\x01\xe0\x0c\x01\xa3\tANONYMOUS\x00\x00\x00\x10'
+                   '\x02\x01\x00\x00\x00SD\xc0\x03\x01P\x00AMQP\x00\x01\x00'
+                   '\x00')
+    self.expect(Event.TRANSPORT)
+    p = transport.pending()
+    bytes = transport.peek(p)
+    transport.pop(p)
+    # XXX: the bytes above appear to be correct, but we don't get any
+    # sort of event indicating that the transport is authenticated


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


[24/50] [abbrv] qpid-proton git commit: NO-JIRA: Add Windows CI build badge to README.md

Posted by ac...@apache.org.
NO-JIRA: Add Windows CI build badge to README.md


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/0aa85920
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/0aa85920
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/0aa85920

Branch: refs/heads/cjansen-cpp-client
Commit: 0aa859208d729d04eebe7d9ee16d208b827f8b64
Parents: 145c017
Author: Andrew Stitcher <as...@apache.org>
Authored: Thu May 14 13:28:24 2015 -0400
Committer: Andrew Stitcher <as...@apache.org>
Committed: Thu May 14 13:28:24 2015 -0400

----------------------------------------------------------------------
 README.md | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0aa85920/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index fe422dc..4f020f7 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,9 @@
 Qpid Proton - AMQP messaging toolkit
 ====================================
 
-[![Build Status](https://travis-ci.org/apache/qpid-proton.svg?branch=master)](https://travis-ci.org/apache/qpid-proton)
+Linux Build | Windows Build
+------------|--------------
+[![Linux Build Status](https://travis-ci.org/apache/qpid-proton.svg?branch=master)](https://travis-ci.org/apache/qpid-proton) | [![Windows Build Status](https://ci.appveyor.com/api/projects/status/owb4mohqyxrnql98?svg=true)](https://ci.appveyor.com/project/ke4qqq/qpid-proton)
 
 Qpid Proton is a high-performance, lightweight messaging library. It can be
 used in the widest range of messaging applications, including brokers, client


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


[45/50] [abbrv] qpid-proton git commit: PROTON-865: new cjansen-cpp-client branch for fledgling C++ client code using the event reactor

Posted by ac...@apache.org.
PROTON-865: new cjansen-cpp-client branch for fledgling C++ client code using the event reactor


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/ad7c9778
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/ad7c9778
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/ad7c9778

Branch: refs/heads/cjansen-cpp-client
Commit: ad7c9778f4ea33a6ca982ac4fea5178b0320b24d
Parents: 2386173
Author: Clifford Jansen <cl...@apache.org>
Authored: Thu Apr 30 11:22:03 2015 -0700
Committer: Alan Conway <ac...@redhat.com>
Committed: Tue Jun 2 14:46:14 2015 -0400

----------------------------------------------------------------------
 proton-c/bindings/CMakeLists.txt                |   7 +-
 proton-c/bindings/cpp/CMakeLists.txt            | 116 +++++++
 proton-c/bindings/cpp/examples/HelloWorld.cpp   |  62 ++++
 .../bindings/cpp/examples/HelloWorldDirect.cpp  |  70 +++++
 .../bindings/cpp/include/proton/cpp/Acceptor.h  |  50 +++
 .../cpp/include/proton/cpp/Connection.h         |  69 +++++
 .../bindings/cpp/include/proton/cpp/Container.h |  67 +++++
 .../bindings/cpp/include/proton/cpp/Endpoint.h  |  47 +++
 .../bindings/cpp/include/proton/cpp/Event.h     |  60 ++++
 .../bindings/cpp/include/proton/cpp/Handle.h    |  72 +++++
 .../bindings/cpp/include/proton/cpp/Handler.h   |  50 +++
 .../cpp/include/proton/cpp/ImportExport.h       |  50 +++
 proton-c/bindings/cpp/include/proton/cpp/Link.h |  63 ++++
 .../bindings/cpp/include/proton/cpp/Message.h   |  53 ++++
 .../cpp/include/proton/cpp/MessagingAdapter.h   |  57 ++++
 .../cpp/include/proton/cpp/MessagingEvent.h     |  92 ++++++
 .../cpp/include/proton/cpp/MessagingHandler.h   |  73 +++++
 .../cpp/include/proton/cpp/ProtonEvent.h        |  57 ++++
 .../cpp/include/proton/cpp/ProtonHandle.h       |  68 +++++
 .../cpp/include/proton/cpp/ProtonHandler.h      |  83 +++++
 .../bindings/cpp/include/proton/cpp/Receiver.h  |  47 +++
 .../bindings/cpp/include/proton/cpp/Sender.h    |  50 +++
 .../bindings/cpp/include/proton/cpp/Session.h   |  59 ++++
 .../bindings/cpp/include/proton/cpp/Transport.h |  48 +++
 .../cpp/include/proton/cpp/exceptions.h         |  56 ++++
 proton-c/bindings/cpp/src/Acceptor.cpp          |  56 ++++
 proton-c/bindings/cpp/src/Connection.cpp        |  69 +++++
 proton-c/bindings/cpp/src/ConnectionImpl.cpp    | 113 +++++++
 proton-c/bindings/cpp/src/ConnectionImpl.h      |  73 +++++
 proton-c/bindings/cpp/src/Connector.cpp         |  77 +++++
 proton-c/bindings/cpp/src/Connector.h           |  59 ++++
 proton-c/bindings/cpp/src/Container.cpp         |  86 ++++++
 proton-c/bindings/cpp/src/ContainerImpl.cpp     | 301 +++++++++++++++++++
 proton-c/bindings/cpp/src/ContainerImpl.h       |  69 +++++
 proton-c/bindings/cpp/src/Endpoint.cpp          |  37 +++
 proton-c/bindings/cpp/src/Event.cpp             |  71 +++++
 proton-c/bindings/cpp/src/Handler.cpp           |  44 +++
 proton-c/bindings/cpp/src/Link.cpp              |  99 ++++++
 proton-c/bindings/cpp/src/LogInternal.h         |  51 ++++
 proton-c/bindings/cpp/src/Logger.cpp            |  56 ++++
 proton-c/bindings/cpp/src/Message.cpp           |  92 ++++++
 proton-c/bindings/cpp/src/MessagingAdapter.cpp  | 191 ++++++++++++
 proton-c/bindings/cpp/src/MessagingEvent.cpp    | 133 ++++++++
 proton-c/bindings/cpp/src/MessagingHandler.cpp  |  60 ++++
 proton-c/bindings/cpp/src/Msg.h                 |  79 +++++
 proton-c/bindings/cpp/src/PrivateImplRef.h      |  97 ++++++
 proton-c/bindings/cpp/src/ProtonEvent.cpp       | 152 ++++++++++
 proton-c/bindings/cpp/src/ProtonHandler.cpp     |  74 +++++
 proton-c/bindings/cpp/src/ProtonImplRef.h       |  66 ++++
 proton-c/bindings/cpp/src/Receiver.cpp          |  43 +++
 proton-c/bindings/cpp/src/Sender.cpp            |  69 +++++
 proton-c/bindings/cpp/src/Session.cpp           |  64 ++++
 proton-c/bindings/cpp/src/Transport.cpp         |  39 +++
 proton-c/bindings/cpp/src/Url.cpp               |  77 +++++
 proton-c/bindings/cpp/src/Url.h                 |  49 +++
 proton-c/bindings/cpp/src/contexts.cpp          |  92 ++++++
 proton-c/bindings/cpp/src/contexts.h            |  48 +++
 proton-c/bindings/cpp/src/exceptions.cpp        |  33 ++
 proton-c/bindings/cpp/src/platform.cpp          |  79 +++++
 proton-c/bindings/cpp/src/platform.h            |  39 +++
 60 files changed, 4362 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/bindings/CMakeLists.txt b/proton-c/bindings/CMakeLists.txt
index 5df4682..f426ef3 100644
--- a/proton-c/bindings/CMakeLists.txt
+++ b/proton-c/bindings/CMakeLists.txt
@@ -20,7 +20,7 @@
 include(UseSWIG)
 
 # Add any new bindings here - the directory name must be the same as the binding name
-set (BINDINGS python ruby php perl javascript)
+set (BINDINGS python ruby php perl javascript cpp)
 
 # All swig modules should include ${PROTON_HEADERS} in SWIG_MODULE_<name>_EXTRA_DEPS
 file(GLOB PROTON_HEADERS "${CMAKE_SOURCE_DIR}/proton-c/include/proton/*.h")
@@ -109,6 +109,11 @@ if (EMSCRIPTEN_FOUND)
   set (DEFAULT_JAVASCRIPT ON)
 endif (EMSCRIPTEN_FOUND)
 
+# C++ client: very experimental.  To try, change this to "ON"
+# or provide -DBUILD_CPP=ON to CMake
+set (DEFAULT_CPP OFF)
+
+
 # Shouldn't need to modify below here when adding new language binding
 foreach(BINDING ${BINDINGS})
   string(TOUPPER ${BINDING} UBINDING)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/CMakeLists.txt b/proton-c/bindings/cpp/CMakeLists.txt
new file mode 100644
index 0000000..7e456a5
--- /dev/null
+++ b/proton-c/bindings/cpp/CMakeLists.txt
@@ -0,0 +1,116 @@
+#
+# 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.
+#
+
+project (Proton C CXX)
+
+include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/src")
+include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/include")
+
+set (qpid-proton-cpp-platform
+  "src/platform"
+  )
+
+set (qpid-proton-cpp-core
+    src/Connection.cpp
+    src/ConnectionImpl.cpp
+    src/Connector.cpp
+    src/Connector.h
+    src/Container.cpp
+    src/ContainerImpl.cpp
+    src/Endpoint.cpp
+    src/Event.cpp
+    src/Handler.cpp
+    src/Link.cpp
+    src/Acceptor.cpp
+    src/Url.cpp
+    src/Message.cpp
+    src/MessagingAdapter.cpp
+    src/MessagingEvent.cpp
+    src/MessagingHandler.cpp
+    src/ProtonEvent.cpp
+    src/ProtonHandler.cpp
+    src/Receiver.cpp
+    src/Sender.cpp
+    src/Session.cpp
+    src/Transport.cpp
+    src/Logger.cpp
+    src/contexts.cpp
+    src/exceptions.cpp
+  )
+
+#set_source_files_properties (
+#  ${qpid-proton-cpp-core}
+#  PROPERTIES
+#  COMPILE_FLAGS "${COMPILE_WARNING_FLAGS} ${COMPILE_LANGUAGE_FLAGS}"
+#  )
+
+set_source_files_properties (${qpid-proton-cpp-platform} PROPERTIES LANGUAGE CXX)
+set_source_files_properties (
+  ${qpid-proton-cpp-platform}
+  PROPERTIES
+  COMPILE_FLAGS "${COMPILE_PLATFORM_FLAGS}"
+  COMPILE_DEFINITIONS "${PLATFORM_DEFINITIONS}"
+  )
+
+
+
+add_library (
+  qpid-proton-cpp SHARED
+
+  ${qpid-proton-cpp-core}
+  ${qpid-proton-cpp-platform}
+
+  )
+
+target_link_libraries (qpid-proton-cpp ${PLATFORM_LIBS} qpid-proton)
+
+set_target_properties (
+  qpid-proton-cpp
+  PROPERTIES
+  LINKER_LANGUAGE CXX
+  VERSION   "${PN_LIB_SOMAJOR}.${PN_LIB_SOMINOR}"
+  SOVERSION "${PN_LIB_SOMAJOR}"
+  LINK_FLAGS "${CATCH_UNDEFINED}"
+  )
+
+add_executable (HelloWorld examples/HelloWorld.cpp)
+target_link_libraries (HelloWorld qpid-proton-cpp)
+add_executable (HelloWorldDirect examples/HelloWorldDirect.cpp)
+target_link_libraries (HelloWorldDirect qpid-proton-cpp)
+
+install (TARGETS qpid-proton-cpp
+  EXPORT  proton
+  ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
+  LIBRARY DESTINATION ${LIB_INSTALL_DIR})
+
+# Install windows qpid-proton-cpp pdb files
+if (MSVC)
+  install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Debug/qpid-proton${CMAKE_DEBUG_POSTFIX}.pdb
+    DESTINATION bin
+    CONFIGURATIONS Debug
+    OPTIONAL)
+  install(FILES ${CMAKE_CURRENT_BINARY_DIR}/RelWithDebInfo/qpid-proton.pdb
+    DESTINATION bin
+    CONFIGURATIONS RelWithDebInfo
+    OPTIONAL)
+endif (MSVC)
+
+# Install header files
+file(GLOB headers "include/proton/cpp/*.h")
+install (FILES ${headers} DESTINATION ${INCLUDE_INSTALL_DIR}/proton/cpp)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/examples/HelloWorld.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/examples/HelloWorld.cpp b/proton-c/bindings/cpp/examples/HelloWorld.cpp
new file mode 100644
index 0000000..1fc124b
--- /dev/null
+++ b/proton-c/bindings/cpp/examples/HelloWorld.cpp
@@ -0,0 +1,62 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "proton/cpp/Container.h"
+#include "proton/cpp/MessagingHandler.h"
+
+#include <iostream>
+
+
+using namespace proton::reactor;
+
+class HelloWorld : public MessagingHandler {
+  private:
+    std::string server;
+    std::string address;
+  public:
+
+    HelloWorld(const std::string &s, const std::string &addr) : server(s), address(addr) {}
+
+    void onStart(Event &e) {
+        Connection conn = e.getContainer().connect(server);
+        e.getContainer().createReceiver(conn, address);
+        e.getContainer().createSender(conn, address);
+    }
+
+    void onSendable(Event &e) {
+        Message m;
+        m.setBody("Hello World!");
+        e.getSender().send(m);
+        e.getSender().close();
+    }
+
+    void onMessage(Event &e) {
+        std::string body = e.getMessage().getBody();
+        std::cout << body << std::endl;
+        e.getConnection().close();
+    }
+
+};
+
+int main(int argc, char **argv) {
+    HelloWorld hw("localhost:5672", "examples");
+    Container(hw).run();
+}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/examples/HelloWorldDirect.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/examples/HelloWorldDirect.cpp b/proton-c/bindings/cpp/examples/HelloWorldDirect.cpp
new file mode 100644
index 0000000..a695dd0
--- /dev/null
+++ b/proton-c/bindings/cpp/examples/HelloWorldDirect.cpp
@@ -0,0 +1,70 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "proton/cpp/MessagingHandler.h"
+#include "proton/cpp/Container.h"
+
+//#include "proton/cpp/Acceptor.h"
+#include <iostream>
+
+
+using namespace proton::reactor;
+
+
+class HelloWorldDirect : public MessagingHandler {
+  private:
+    std::string url;
+    Acceptor acceptor;
+  public:
+
+    HelloWorldDirect(const std::string &u) : url(u) {}
+
+    void onStart(Event &e) {
+        acceptor = e.getContainer().listen(url);
+        e.getContainer().createSender(url);
+    }
+
+    void onSendable(Event &e) {
+        Message m;
+        m.setBody("Hello World!");
+        e.getSender().send(m);
+        e.getSender().close();
+    }
+
+    void onMessage(Event &e) {
+        std::string body = e.getMessage().getBody();
+        std::cout << body << std::endl;
+    }
+
+    void onAccepted(Event &e) {
+        e.getConnection().close();
+    }
+
+    void onConnectionClosed(Event &e) {
+        acceptor.close();
+    }
+
+};
+
+int main(int argc, char **argv) {
+    HelloWorldDirect hwd("localhost:8888/examples");
+    Container(hwd).run();
+}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/include/proton/cpp/Acceptor.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Acceptor.h b/proton-c/bindings/cpp/include/proton/cpp/Acceptor.h
new file mode 100644
index 0000000..852ca97
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/Acceptor.h
@@ -0,0 +1,50 @@
+#ifndef PROTON_CPP_ACCEPTOR_H
+#define PROTON_CPP_ACCEPTOR_H
+
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/cpp/ImportExport.h"
+#include "proton/cpp/ProtonHandle.h"
+#include "proton/reactor.h"
+
+struct pn_connection_t;
+
+namespace proton {
+namespace reactor {
+
+class Acceptor : public ProtonHandle<pn_acceptor_t>
+{
+  public:
+    PROTON_CPP_EXTERN Acceptor();
+    PROTON_CPP_EXTERN Acceptor(pn_acceptor_t *);
+    PROTON_CPP_EXTERN Acceptor(const Acceptor&);
+    PROTON_CPP_EXTERN Acceptor& operator=(const Acceptor&);
+    PROTON_CPP_EXTERN ~Acceptor();
+
+    PROTON_CPP_EXTERN void close();
+  private:
+    friend class ProtonImplRef<Acceptor>;
+};
+
+
+}} // namespace proton::reactor
+
+#endif  /*!PROTON_CPP_ACCEPTOR_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/include/proton/cpp/Connection.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Connection.h b/proton-c/bindings/cpp/include/proton/cpp/Connection.h
new file mode 100644
index 0000000..7d97ebb
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/Connection.h
@@ -0,0 +1,69 @@
+#ifndef PROTON_CPP_CONNECTION_H
+#define PROTON_CPP_CONNECTION_H
+
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/cpp/ImportExport.h"
+#include "proton/cpp/Handle.h"
+#include "proton/cpp/Endpoint.h"
+#include "proton/cpp/Container.h"
+#include "proton/types.h"
+#include <string>
+
+struct pn_connection_t;
+
+namespace proton {
+namespace reactor {
+
+class Handler;
+class Transport;
+class Container;
+class ConnectionImpl;
+
+class Connection : public Endpoint, public Handle<ConnectionImpl>
+{
+  public:
+    PROTON_CPP_EXTERN Connection();
+    PROTON_CPP_EXTERN Connection(ConnectionImpl *);
+    PROTON_CPP_EXTERN Connection(const Connection& c);
+    PROTON_CPP_EXTERN Connection& operator=(const Connection& c);
+    PROTON_CPP_EXTERN ~Connection();
+
+    PROTON_CPP_EXTERN Connection(Container &c);
+    PROTON_CPP_EXTERN Transport &getTransport();
+    PROTON_CPP_EXTERN Handler *getOverride();
+    PROTON_CPP_EXTERN void setOverride(Handler *h);
+    PROTON_CPP_EXTERN void open();
+    PROTON_CPP_EXTERN void close();
+    PROTON_CPP_EXTERN pn_connection_t *getPnConnection();
+    PROTON_CPP_EXTERN Container &getContainer();
+    PROTON_CPP_EXTERN std::string getHostname();
+    virtual PROTON_CPP_EXTERN Connection &getConnection();
+  private:
+   friend class PrivateImplRef<Connection>;
+   friend class Connector;
+   friend class ConnectionImpl;
+};
+
+
+}} // namespace proton::reactor
+
+#endif  /*!PROTON_CPP_CONNECTION_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/include/proton/cpp/Container.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Container.h b/proton-c/bindings/cpp/include/proton/cpp/Container.h
new file mode 100644
index 0000000..fbb1a83
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/Container.h
@@ -0,0 +1,67 @@
+#ifndef PROTON_CPP_CONTAINER_H
+#define PROTON_CPP_CONTAINER_H
+
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/cpp/ImportExport.h"
+#include "proton/cpp/Handle.h"
+#include "proton/cpp/Acceptor.h"
+#include <proton/reactor.h>
+#include <string>
+
+namespace proton {
+namespace reactor {
+
+class DispatchHelper;
+class Connection;
+class Connector;
+class Acceptor;
+class ContainerImpl;
+class MessagingHandler;
+class Sender;
+class Receiver;
+class Link;
+
+class Container : public Handle<ContainerImpl>
+{
+  public:
+    PROTON_CPP_EXTERN Container(ContainerImpl *);
+    PROTON_CPP_EXTERN Container(const Container& c);
+    PROTON_CPP_EXTERN Container& operator=(const Container& c);
+    PROTON_CPP_EXTERN ~Container();
+
+    PROTON_CPP_EXTERN Container(MessagingHandler &mhandler);
+    PROTON_CPP_EXTERN Connection connect(std::string &host);
+    PROTON_CPP_EXTERN void run();
+    PROTON_CPP_EXTERN pn_reactor_t *getReactor();
+    PROTON_CPP_EXTERN pn_handler_t *getGlobalHandler();
+    PROTON_CPP_EXTERN Sender createSender(Connection &connection, std::string &addr);
+    PROTON_CPP_EXTERN Sender createSender(std::string &url);
+    PROTON_CPP_EXTERN Receiver createReceiver(Connection &connection, std::string &addr);
+    PROTON_CPP_EXTERN Acceptor listen(const std::string &url);
+    PROTON_CPP_EXTERN std::string getContainerId();
+  private:
+   friend class PrivateImplRef<Container>;
+};
+
+}} // namespace proton::reactor
+
+#endif  /*!PROTON_CPP_CONTAINER_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/include/proton/cpp/Endpoint.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Endpoint.h b/proton-c/bindings/cpp/include/proton/cpp/Endpoint.h
new file mode 100644
index 0000000..9992eff
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/Endpoint.h
@@ -0,0 +1,47 @@
+#ifndef PROTON_CPP_ENDPOINT_H
+#define PROTON_CPP_ENDPOINT_H
+
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/cpp/ImportExport.h"
+
+namespace proton {
+namespace reactor {
+
+class Handler;
+class Connection;
+class Transport;
+
+class Endpoint
+{
+  public:
+    // TODO: getCondition, getRemoteCondition, updateCondition, get/setHandler
+    virtual PROTON_CPP_EXTERN Connection &getConnection() = 0;
+    Transport PROTON_CPP_EXTERN &getTransport();
+  protected:
+    Endpoint();
+    ~Endpoint();
+};
+
+
+}} // namespace proton::reactor
+
+#endif  /*!PROTON_CPP_ENDPOINT_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/include/proton/cpp/Event.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Event.h b/proton-c/bindings/cpp/include/proton/cpp/Event.h
new file mode 100644
index 0000000..47aee2d
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/Event.h
@@ -0,0 +1,60 @@
+#ifndef PROTON_CPP_EVENT_H
+#define PROTON_CPP_EVENT_H
+
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/cpp/ImportExport.h"
+#include "proton/cpp/Link.h"
+#include "proton/cpp/Connection.h"
+#include "proton/cpp/Message.h"
+#include <vector>
+
+
+namespace proton {
+namespace reactor {
+
+class Handler;
+class Container;
+class Connection;
+
+class Event
+{
+  public:
+    virtual PROTON_CPP_EXTERN void dispatch(Handler &h) = 0;
+    virtual PROTON_CPP_EXTERN Container &getContainer();
+    virtual PROTON_CPP_EXTERN Connection &getConnection();
+    virtual PROTON_CPP_EXTERN Sender getSender();
+    virtual PROTON_CPP_EXTERN Receiver getReceiver();
+    virtual PROTON_CPP_EXTERN Link getLink();
+    virtual PROTON_CPP_EXTERN Message getMessage();
+    virtual PROTON_CPP_EXTERN void setMessage(Message &);
+    virtual PROTON_CPP_EXTERN ~Event();
+  protected:
+    PROTON_CPP_EXTERN PROTON_CPP_EXTERN Event();
+  private:
+    PROTON_CPP_EXTERN Event(const Event&);
+    PROTON_CPP_EXTERN Event& operator=(const Event&);
+};
+
+
+}} // namespace proton::reactor
+
+#endif  /*!PROTON_CPP_EVENT_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/include/proton/cpp/Handle.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Handle.h b/proton-c/bindings/cpp/include/proton/cpp/Handle.h
new file mode 100644
index 0000000..632e30e
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/Handle.h
@@ -0,0 +1,72 @@
+#ifndef PROTON_CPP_HANDLE_H
+#define PROTON_CPP_HANDLE_H
+
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "proton/cpp/ImportExport.h"
+
+namespace proton {
+namespace reactor {
+
+template <class> class PrivateImplRef;
+
+/**
+ * A handle is like a pointer: refers to an underlying implementation object.
+ * Copying the handle does not copy the object.
+ *
+ * Handles can be null,  like a 0 pointer. Use isValid(), isNull() or the
+ * conversion to bool to test for a null handle.
+ */
+template <class T> class Handle {
+  public:
+
+    /**@return true if handle is valid,  i.e. not null. */
+    PROTON_CPP_INLINE_EXTERN bool isValid() const { return impl; }
+
+    /**@return true if handle is null. It is an error to call any function on a null handle. */
+    PROTON_CPP_INLINE_EXTERN bool isNull() const { return !impl; }
+
+    /** Conversion to bool supports idiom if (handle) { handle->... } */
+    PROTON_CPP_INLINE_EXTERN operator bool() const { return impl; }
+
+    /** Operator ! supports idiom if (!handle) { do_if_handle_is_null(); } */
+    PROTON_CPP_INLINE_EXTERN bool operator !() const { return !impl; }
+
+    void swap(Handle<T>& h) { T* t = h.impl; h.impl = impl; impl = t; }
+
+  private:
+    // Not implemented, subclasses must implement.
+    Handle(const Handle&);
+    Handle& operator=(const Handle&);
+
+  protected:
+    typedef T Impl;
+    PROTON_CPP_INLINE_EXTERN Handle() :impl() {}
+
+    Impl* impl;
+
+  friend class PrivateImplRef<T>;
+};
+
+}} // namespace proton::reactor
+
+#endif  /*!PROTON_CPP_HANDLE_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/include/proton/cpp/Handler.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Handler.h b/proton-c/bindings/cpp/include/proton/cpp/Handler.h
new file mode 100644
index 0000000..231942f
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/Handler.h
@@ -0,0 +1,50 @@
+#ifndef PROTON_CPP_HANDLER_H
+#define PROTON_CPP_HANDLER_H
+
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/cpp/ImportExport.h"
+#include "proton/cpp/Event.h"
+#include "proton/event.h"
+#include <vector>
+
+namespace proton {
+namespace reactor {
+
+class PROTON_CPP_EXTERN Handler
+{
+  public:
+    PROTON_CPP_EXTERN Handler();
+    PROTON_CPP_EXTERN virtual ~Handler();
+
+    PROTON_CPP_EXTERN virtual void onUnhandled(Event &e);
+
+    PROTON_CPP_EXTERN virtual void addChildHandler(Handler &e);
+    PROTON_CPP_EXTERN std::vector<Handler *>::iterator childHandlersBegin();
+    PROTON_CPP_EXTERN std::vector<Handler *>::iterator childHandlersEnd();
+  protected:
+    std::vector<Handler *>childHandlers;
+};
+
+
+}} // namespace proton::reactor
+
+#endif  /*!PROTON_CPP_HANDLER_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/include/proton/cpp/ImportExport.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/ImportExport.h b/proton-c/bindings/cpp/include/proton/cpp/ImportExport.h
new file mode 100644
index 0000000..4a88576
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/ImportExport.h
@@ -0,0 +1,50 @@
+#ifndef PROTON_CPP_IMPORTEXPORT_H
+#define PROTON_CPP_IMPORTEXPORT_H
+
+/*
+ *
+ * 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.
+ *
+ */
+#if defined(WIN32) && !defined(PROTON_CPP_DECLARE_STATIC)
+  //
+  // Import and Export definitions for Windows:
+  //
+#  define PROTON_CPP_EXPORT __declspec(dllexport)
+#  define PROTON_CPP_IMPORT __declspec(dllimport)
+#else
+  //
+  // Non-Windows (Linux, etc.) definitions:
+  //
+#  define PROTON_CPP_EXPORT
+#  define PROTON_CPP_IMPORT
+#endif
+
+
+// For c++ library symbols
+
+#ifdef protoncpp_EXPORTS
+#  define PROTON_CPP_EXTERN PROTON_CPP_EXPORT
+#else
+#  define PROTON_CPP_EXTERN PROTON_CPP_IMPORT
+#endif
+
+// TODO:
+#define PROTON_CPP_INLINE_EXTERN
+
+#endif  /*!PROTON_CPP_IMPORTEXPORT_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/include/proton/cpp/Link.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Link.h b/proton-c/bindings/cpp/include/proton/cpp/Link.h
new file mode 100644
index 0000000..21b1ca2
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/Link.h
@@ -0,0 +1,63 @@
+#ifndef PROTON_CPP_LINK_H
+#define PROTON_CPP_LINK_H
+
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/cpp/ImportExport.h"
+#include "proton/cpp/ProtonHandle.h"
+#include "proton/cpp/Endpoint.h"
+#include "proton/types.h"
+#include <string>
+
+struct pn_connection_t;
+
+namespace proton {
+namespace reactor {
+
+class Link : public Endpoint, public ProtonHandle<pn_link_t>
+{
+  public:
+    PROTON_CPP_EXTERN Link(pn_link_t *);
+    PROTON_CPP_EXTERN Link();
+    PROTON_CPP_EXTERN ~Link();
+    PROTON_CPP_EXTERN Link(const Link&);
+    PROTON_CPP_EXTERN Link& operator=(const Link&);
+    PROTON_CPP_EXTERN void open();
+    PROTON_CPP_EXTERN void close();
+    PROTON_CPP_EXTERN bool isSender();
+    PROTON_CPP_EXTERN bool isReceiver();
+    PROTON_CPP_EXTERN int getCredit();
+    PROTON_CPP_EXTERN pn_link_t *getPnLink() const;
+    virtual PROTON_CPP_EXTERN Connection &getConnection();
+  protected:
+    virtual void verifyType(pn_link_t *l);
+  private:
+    friend class ProtonImplRef<Link>;
+    bool senderLink;
+};
+
+
+}} // namespace proton::reactor
+
+#include "proton/cpp/Sender.h"
+#include "proton/cpp/Receiver.h"
+
+#endif  /*!PROTON_CPP_LINK_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/include/proton/cpp/Message.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Message.h b/proton-c/bindings/cpp/include/proton/cpp/Message.h
new file mode 100644
index 0000000..51ca731
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/Message.h
@@ -0,0 +1,53 @@
+#ifndef PROTON_CPP_MESSAGE_H
+#define PROTON_CPP_MESSAGE_H
+
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/cpp/ImportExport.h"
+#include "proton/message.h"
+#include <string>
+
+
+namespace proton {
+namespace reactor {
+
+class Message
+{
+  public:
+    PROTON_CPP_EXTERN Message();
+    PROTON_CPP_EXTERN ~Message();
+    PROTON_CPP_EXTERN Message(const Message&);
+    PROTON_CPP_EXTERN Message& operator=(const Message&);
+
+    PROTON_CPP_EXTERN pn_message_t *getPnMessage();
+    PROTON_CPP_EXTERN void setBody(const std::string &data);
+    PROTON_CPP_EXTERN std::string getBody();
+    PROTON_CPP_EXTERN void encode(std::string &data);
+    PROTON_CPP_EXTERN void decode(const std::string &data);
+
+  private:
+    pn_message_t *pnMessage;
+};
+
+
+}} // namespace proton::reactor
+
+#endif  /*!PROTON_CPP_MESSAGE_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/include/proton/cpp/MessagingAdapter.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/MessagingAdapter.h b/proton-c/bindings/cpp/include/proton/cpp/MessagingAdapter.h
new file mode 100644
index 0000000..8551c9c
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/MessagingAdapter.h
@@ -0,0 +1,57 @@
+#ifndef PROTON_CPP_MESSAGING_ADAPTER_H
+#define PROTON_CPP_MESSAGING_ADAPTER_H
+
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "proton/cpp/ProtonHandler.h"
+#include "proton/cpp/MessagingHandler.h"
+
+#include "proton/cpp/MessagingEvent.h"
+#include "proton/event.h"
+#include "proton/reactor.h"
+
+namespace proton {
+namespace reactor {
+
+// For now, stands in for Python's: EndpointStateHandler, IncomingMessageHandler, OutgoingMessageHandler
+
+
+class MessagingAdapter : public ProtonHandler
+{
+  public:
+    PROTON_CPP_EXTERN MessagingAdapter(MessagingHandler &delegate);
+    PROTON_CPP_EXTERN virtual ~MessagingAdapter();
+    PROTON_CPP_EXTERN virtual void onReactorInit(Event &e);
+    PROTON_CPP_EXTERN virtual void onLinkFlow(Event &e);
+    PROTON_CPP_EXTERN virtual void onDelivery(Event &e);
+    PROTON_CPP_EXTERN virtual void onUnhandled(Event &e);
+    PROTON_CPP_EXTERN virtual void onConnectionRemoteClose(Event &e);
+    PROTON_CPP_EXTERN virtual void onLinkRemoteOpen(Event &e);
+  private:
+    MessagingHandler &delegate;  // The actual MessagingHandler
+    pn_handler_t *handshaker;
+};
+
+
+}} // namespace proton::reactor
+
+#endif  /*!PROTON_CPP_MESSAGING_ADAPTER_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/include/proton/cpp/MessagingEvent.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/MessagingEvent.h b/proton-c/bindings/cpp/include/proton/cpp/MessagingEvent.h
new file mode 100644
index 0000000..d8d5c7f
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/MessagingEvent.h
@@ -0,0 +1,92 @@
+#ifndef PROTON_CPP_MESSAGINGEVENT_H
+#define PROTON_CPP_MESSAGINGEVENT_H
+
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/cpp/ProtonEvent.h"
+#include "proton/cpp/Link.h"
+
+namespace proton {
+namespace reactor {
+
+class Handler;
+class Container;
+class Connection;
+
+typedef enum {
+    PN_MESSAGING_PROTON = 0,  // Wrapped pn_event_t
+    // Covenience events for C++ MessagingHandlers
+    PN_MESSAGING_ABORT,
+    PN_MESSAGING_ACCEPTED,
+    PN_MESSAGING_COMMIT,
+    PN_MESSAGING_CONNECTION_CLOSE,
+    PN_MESSAGING_CONNECTION_CLOSED,
+    PN_MESSAGING_CONNECTION_CLOSING,
+    PN_MESSAGING_CONNECTION_OPEN,
+    PN_MESSAGING_CONNECTION_OPENED,
+    PN_MESSAGING_DISCONNECTED,
+    PN_MESSAGING_FETCH,
+    PN_MESSAGING_ID_LOADED,
+    PN_MESSAGING_LINK_CLOSING,
+    PN_MESSAGING_LINK_OPENED,
+    PN_MESSAGING_LINK_OPENING,
+    PN_MESSAGING_MESSAGE,
+    PN_MESSAGING_QUIT,
+    PN_MESSAGING_RECORD_INSERTED,
+    PN_MESSAGING_RECORDS_LOADED,
+    PN_MESSAGING_REJECTED,
+    PN_MESSAGING_RELEASED,
+    PN_MESSAGING_REQUEST,
+    PN_MESSAGING_RESPONSE,
+    PN_MESSAGING_SENDABLE,
+    PN_MESSAGING_SETTLED,
+    PN_MESSAGING_START,
+    PN_MESSAGING_TIMER,
+    PN_MESSAGING_TRANSACTION_ABORTED,
+    PN_MESSAGING_TRANSACTION_COMMITTED,
+    PN_MESSAGING_TRANSACTION_DECLARED
+} MessagingEventType_t;
+
+class MessagingEvent : public ProtonEvent
+{
+  public:
+    MessagingEvent(pn_event_t *ce, pn_event_type_t t, Container &c);
+    MessagingEvent(MessagingEventType_t t, ProtonEvent *parent, Container &c);
+    ~MessagingEvent();
+    virtual PROTON_CPP_EXTERN void dispatch(Handler &h);
+    virtual PROTON_CPP_EXTERN Connection &getConnection();
+    virtual PROTON_CPP_EXTERN Sender getSender();
+    virtual PROTON_CPP_EXTERN Receiver getReceiver();
+    virtual PROTON_CPP_EXTERN Link getLink();
+    virtual PROTON_CPP_EXTERN Message getMessage();
+    virtual PROTON_CPP_EXTERN void setMessage(Message &);
+  private:
+    MessagingEventType_t messagingType;
+    ProtonEvent *parentEvent;
+    Message *message;
+    MessagingEvent operator=(const MessagingEvent&);
+    MessagingEvent(const MessagingEvent&);
+};
+
+
+}} // namespace proton::reactor
+
+#endif  /*!PROTON_CPP_MESSAGINGEVENT_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/include/proton/cpp/MessagingHandler.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/MessagingHandler.h b/proton-c/bindings/cpp/include/proton/cpp/MessagingHandler.h
new file mode 100644
index 0000000..875af43
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/MessagingHandler.h
@@ -0,0 +1,73 @@
+#ifndef PROTON_CPP_MESSAGING_HANDLER_H
+#define PROTON_CPP_MESSAGING_HANDLER_H
+
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "proton/cpp/ProtonHandler.h"
+#include "proton/event.h"
+
+namespace proton {
+namespace reactor {
+
+class Event;
+
+class PROTON_CPP_EXTERN MessagingHandler : public ProtonHandler
+{
+  public:
+    PROTON_CPP_EXTERN MessagingHandler();
+    virtual ~MessagingHandler();
+
+    virtual void onAbort(Event &e);
+    virtual void onAccepted(Event &e);
+    virtual void onCommit(Event &e);
+    virtual void onConnectionClose(Event &e);
+    virtual void onConnectionClosed(Event &e);
+    virtual void onConnectionClosing(Event &e);
+    virtual void onConnectionOpen(Event &e);
+    virtual void onConnectionOpened(Event &e);
+    virtual void onDisconnected(Event &e);
+    virtual void onFetch(Event &e);
+    virtual void onIdLoaded(Event &e);
+    virtual void onLinkClosing(Event &e);
+    virtual void onLinkOpened(Event &e);
+    virtual void onLinkOpening(Event &e);
+    virtual void onMessage(Event &e);
+    virtual void onQuit(Event &e);
+    virtual void onRecordInserted(Event &e);
+    virtual void onRecordsLoaded(Event &e);
+    virtual void onRejected(Event &e);
+    virtual void onReleased(Event &e);
+    virtual void onRequest(Event &e);
+    virtual void onResponse(Event &e);
+    virtual void onSendable(Event &e);
+    virtual void onSettled(Event &e);
+    virtual void onStart(Event &e);
+    virtual void onTimer(Event &e);
+    virtual void onTransactionAborted(Event &e);
+    virtual void onTransactionCommitted(Event &e);
+    virtual void onTransactionDeclared(Event &e);
+};
+
+
+}} // namespace proton::reactor
+
+#endif  /*!PROTON_CPP_MESSAGING_HANDLER_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/include/proton/cpp/ProtonEvent.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/ProtonEvent.h b/proton-c/bindings/cpp/include/proton/cpp/ProtonEvent.h
new file mode 100644
index 0000000..9e5e9f3
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/ProtonEvent.h
@@ -0,0 +1,57 @@
+#ifndef PROTON_CPP_PROTONEVENT_H
+#define PROTON_CPP_PROTONEVENT_H
+
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/cpp/Event.h"
+#include "proton/cpp/Link.h"
+
+namespace proton {
+namespace reactor {
+
+class Handler;
+class Container;
+class Connection;
+class Container;
+
+class ProtonEvent : public Event
+{
+  public:
+    virtual PROTON_CPP_EXTERN void dispatch(Handler &h);
+    virtual PROTON_CPP_EXTERN Container &getContainer();
+    virtual PROTON_CPP_EXTERN Connection &getConnection();
+    virtual PROTON_CPP_EXTERN Sender getSender();
+    virtual PROTON_CPP_EXTERN Receiver getReceiver();
+    virtual PROTON_CPP_EXTERN Link getLink();
+    PROTON_CPP_EXTERN int getType();
+    PROTON_CPP_EXTERN pn_event_t* getPnEvent();
+  protected:
+    PROTON_CPP_EXTERN ProtonEvent(pn_event_t *ce, pn_event_type_t t, Container &c);
+  private:
+    pn_event_t *pnEvent;
+    int type;
+    Container &container;
+};
+
+
+}} // namespace proton::reactor
+
+#endif  /*!PROTON_CPP_PROTONEVENT_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/include/proton/cpp/ProtonHandle.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/ProtonHandle.h b/proton-c/bindings/cpp/include/proton/cpp/ProtonHandle.h
new file mode 100644
index 0000000..8fe6f4c
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/ProtonHandle.h
@@ -0,0 +1,68 @@
+#ifndef PROTON_CPP_PROTONHANDLE_H
+#define PROTON_CPP_PROTONHANDLE_H
+
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "proton/cpp/ImportExport.h"
+
+namespace proton {
+namespace reactor {
+
+template <class> class ProtonImplRef;
+
+/**
+ * See Handle.h.  Similar but for lightly wrapped Proton pn_object_t targets.
+ */
+template <class T> class ProtonHandle {
+  public:
+
+    /**@return true if handle is valid,  i.e. not null. */
+    PROTON_CPP_INLINE_EXTERN bool isValid() const { return impl; }
+
+    /**@return true if handle is null. It is an error to call any function on a null handle. */
+    PROTON_CPP_INLINE_EXTERN bool isNull() const { return !impl; }
+
+    /** Conversion to bool supports idiom if (handle) { handle->... } */
+    PROTON_CPP_INLINE_EXTERN operator bool() const { return impl; }
+
+    /** Operator ! supports idiom if (!handle) { do_if_handle_is_null(); } */
+    PROTON_CPP_INLINE_EXTERN bool operator !() const { return !impl; }
+
+    void swap(ProtonHandle<T>& h) { T* t = h.impl; h.impl = impl; impl = t; }
+
+  private:
+    // Not implemented, subclasses must implement.
+    ProtonHandle(const ProtonHandle&);
+    ProtonHandle& operator=(const ProtonHandle&);
+
+  protected:
+    typedef T Impl;
+    PROTON_CPP_INLINE_EXTERN ProtonHandle() :impl() {}
+
+    Impl* impl;
+
+  friend class ProtonImplRef<T>;
+};
+
+}} // namespace proton::reactor
+
+#endif  /*!PROTON_CPP_PROTONHANDLE_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/include/proton/cpp/ProtonHandler.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/ProtonHandler.h b/proton-c/bindings/cpp/include/proton/cpp/ProtonHandler.h
new file mode 100644
index 0000000..b639cc3
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/ProtonHandler.h
@@ -0,0 +1,83 @@
+#ifndef PROTON_CPP_PROTONHANDLER_H
+#define PROTON_CPP_PROTONHANDLER_H
+
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/cpp/Handler.h"
+
+namespace proton {
+namespace reactor {
+
+class Event;
+class ProtonEvent;
+
+class ProtonHandler : public Handler
+{
+  public:
+    PROTON_CPP_EXTERN ProtonHandler();
+    virtual void onReactorInit(Event &e);
+    virtual void onReactorQuiesced(Event &e);
+    virtual void onReactorFinal(Event &e);
+    virtual void onTimerTask(Event &e);
+    virtual void onConnectionInit(Event &e);
+    virtual void onConnectionBound(Event &e);
+    virtual void onConnectionUnbound(Event &e);
+    virtual void onConnectionLocalOpen(Event &e);
+    virtual void onConnectionLocalClose(Event &e);
+    virtual void onConnectionRemoteOpen(Event &e);
+    virtual void onConnectionRemoteClose(Event &e);
+    virtual void onConnectionFinal(Event &e);
+    virtual void onSessionInit(Event &e);
+    virtual void onSessionLocalOpen(Event &e);
+    virtual void onSessionLocalClose(Event &e);
+    virtual void onSessionRemoteOpen(Event &e);
+    virtual void onSessionRemoteClose(Event &e);
+    virtual void onSessionFinal(Event &e);
+    virtual void onLinkInit(Event &e);
+    virtual void onLinkLocalOpen(Event &e);
+    virtual void onLinkLocalClose(Event &e);
+    virtual void onLinkLocalDetach(Event &e);
+    virtual void onLinkRemoteOpen(Event &e);
+    virtual void onLinkRemoteClose(Event &e);
+    virtual void onLinkRemoteDetach(Event &e);
+    virtual void onLinkFlow(Event &e);
+    virtual void onLinkFinal(Event &e);
+    virtual void onDelivery(Event &e);
+    virtual void onTransport(Event &e);
+    virtual void onTransportError(Event &e);
+    virtual void onTransportHeadClosed(Event &e);
+    virtual void onTransportTailClosed(Event &e);
+    virtual void onTransportClosed(Event &e);
+    virtual void onSelectableInit(Event &e);
+    virtual void onSelectableUpdated(Event &e);
+    virtual void onSelectableReadable(Event &e);
+    virtual void onSelectableWritable(Event &e);
+    virtual void onSelectableExpired(Event &e);
+    virtual void onSelectableError(Event &e);
+    virtual void onSelectableFinal(Event &e);
+
+    virtual void onUnhandled(Event &e);
+};
+
+
+}} // namespace proton::reactor
+
+#endif  /*!PROTON_CPP_PROTONHANDLER_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/include/proton/cpp/Receiver.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Receiver.h b/proton-c/bindings/cpp/include/proton/cpp/Receiver.h
new file mode 100644
index 0000000..197cfb1
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/Receiver.h
@@ -0,0 +1,47 @@
+#ifndef PROTON_CPP_RECEIVER_H
+#define PROTON_CPP_RECEIVER_H
+
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/cpp/ImportExport.h"
+#include "proton/cpp/Endpoint.h"
+#include "proton/cpp/Link.h"
+#include "proton/types.h"
+#include <string>
+
+struct pn_connection_t;
+
+namespace proton {
+namespace reactor {
+
+class Receiver : public Link
+{
+  public:
+    PROTON_CPP_EXTERN Receiver(pn_link_t *lnk);
+    PROTON_CPP_EXTERN Receiver();
+  protected:
+    virtual void verifyType(pn_link_t *l);
+};
+
+
+}} // namespace proton::reactor
+
+#endif  /*!PROTON_CPP_RECEIVER_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/include/proton/cpp/Sender.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Sender.h b/proton-c/bindings/cpp/include/proton/cpp/Sender.h
new file mode 100644
index 0000000..fa8cce8
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/Sender.h
@@ -0,0 +1,50 @@
+#ifndef PROTON_CPP_SENDER_H
+#define PROTON_CPP_SENDER_H
+
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/cpp/ImportExport.h"
+#include "proton/cpp/Link.h"
+#include "proton/cpp/Message.h"
+
+#include "proton/types.h"
+#include <string>
+
+struct pn_connection_t;
+
+namespace proton {
+namespace reactor {
+
+
+class Sender : public Link
+{
+  public:
+    PROTON_CPP_EXTERN Sender(pn_link_t *lnk);
+    PROTON_CPP_EXTERN Sender();
+    PROTON_CPP_EXTERN void send(Message &m);
+  protected:
+    virtual void verifyType(pn_link_t *l);
+};
+
+
+}} // namespace proton::reactor
+
+#endif  /*!PROTON_CPP_SENDER_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/include/proton/cpp/Session.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Session.h b/proton-c/bindings/cpp/include/proton/cpp/Session.h
new file mode 100644
index 0000000..e556cde
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/Session.h
@@ -0,0 +1,59 @@
+#ifndef PROTON_CPP_SESSION_H
+#define PROTON_CPP_SESSION_H
+
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/cpp/ImportExport.h"
+#include "proton/cpp/Endpoint.h"
+#include "proton/cpp/Link.h"
+
+#include "proton/types.h"
+#include "proton/link.h"
+#include <string>
+
+struct pn_connection_t;
+
+namespace proton {
+namespace reactor {
+
+class Container;
+class Handler;
+class Transport;
+
+class Session : public Endpoint
+{
+  public:
+    PROTON_CPP_EXTERN Session(pn_session_t *s);
+    PROTON_CPP_EXTERN ~Session();
+    PROTON_CPP_EXTERN void open();
+    PROTON_CPP_EXTERN void close();
+    PROTON_CPP_EXTERN pn_session_t *getPnSession();
+    virtual PROTON_CPP_EXTERN Connection &getConnection();
+    Receiver createReceiver(std::string name);
+    Sender createSender(std::string name);
+  private:
+    pn_session_t *pnSession;
+};
+
+
+}} // namespace proton::reactor
+
+#endif  /*!PROTON_CPP_SESSION_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/include/proton/cpp/Transport.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Transport.h b/proton-c/bindings/cpp/include/proton/cpp/Transport.h
new file mode 100644
index 0000000..141e0a3
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/Transport.h
@@ -0,0 +1,48 @@
+#ifndef PROTON_CPP_TRANSPORT_H
+#define PROTON_CPP_TRANSPORT_H
+
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/cpp/ImportExport.h"
+#include "proton/transport.h"
+#include <string>
+
+struct pn_connection_t;
+
+namespace proton {
+namespace reactor {
+
+class Connection;
+
+class Transport
+{
+  public:
+    PROTON_CPP_EXTERN Transport();
+    PROTON_CPP_EXTERN ~Transport();
+    PROTON_CPP_EXTERN void bind(Connection &c);
+    Connection *connection;
+    pn_transport_t *pnTransport;
+};
+
+
+}} // namespace proton::reactor
+
+#endif  /*!PROTON_CPP_TRANSPORT_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/include/proton/cpp/exceptions.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/exceptions.h b/proton-c/bindings/cpp/include/proton/cpp/exceptions.h
new file mode 100644
index 0000000..713c5c5
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/exceptions.h
@@ -0,0 +1,56 @@
+#ifndef PROTON_CPP_EXCEPTIONS_H
+#define PROTON_CPP_EXCEPTIONS_H
+
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/cpp/ImportExport.h"
+#include <string>
+#include <exception>
+
+namespace proton {
+namespace reactor {
+
+class ProtonException : public std::exception
+{
+  public:
+    PROTON_CPP_EXTERN explicit ProtonException(const std::string& message=std::string()) throw();
+    PROTON_CPP_EXTERN virtual ~ProtonException() throw();
+    PROTON_CPP_EXTERN virtual const char* what() const throw();
+
+  private:
+    const std::string message;
+};
+
+class MessageReject : public ProtonException
+{
+  public:
+    PROTON_CPP_EXTERN explicit MessageReject(const std::string& message=std::string()) throw();
+};
+
+class MessageRelease : public ProtonException
+{
+  public:
+    PROTON_CPP_EXTERN explicit MessageRelease(const std::string& message=std::string()) throw();
+};
+
+}} // namespace proton::reactor
+
+#endif  /*!PROTON_CPP_EXCEPTIONS_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/src/Acceptor.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Acceptor.cpp b/proton-c/bindings/cpp/src/Acceptor.cpp
new file mode 100644
index 0000000..aa73ebf
--- /dev/null
+++ b/proton-c/bindings/cpp/src/Acceptor.cpp
@@ -0,0 +1,56 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "proton/cpp/Acceptor.h"
+#include "proton/cpp/exceptions.h"
+#include "ProtonImplRef.h"
+#include "Msg.h"
+
+namespace proton {
+namespace reactor {
+
+template class ProtonHandle<pn_acceptor_t>;
+typedef ProtonImplRef<Acceptor> PI;
+
+Acceptor::Acceptor() {}
+
+Acceptor::Acceptor(pn_acceptor_t *a)
+{
+    PI::ctor(*this, a);
+}
+
+Acceptor::~Acceptor() { PI::dtor(*this); }
+
+
+Acceptor::Acceptor(const Acceptor& a) : ProtonHandle<pn_acceptor_t>() {
+    PI::copy(*this, a);
+}
+
+Acceptor& Acceptor::operator=(const Acceptor& a) {
+    return PI::assign(*this, a);
+}
+
+void Acceptor::close() {
+    if (impl)
+        pn_acceptor_close(impl);
+}
+
+}} // namespace proton::reactor

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/src/Connection.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Connection.cpp b/proton-c/bindings/cpp/src/Connection.cpp
new file mode 100644
index 0000000..e85b323
--- /dev/null
+++ b/proton-c/bindings/cpp/src/Connection.cpp
@@ -0,0 +1,69 @@
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/cpp/Container.h"
+#include "proton/cpp/Connection.h"
+#include "proton/cpp/Handler.h"
+#include "proton/cpp/exceptions.h"
+#include "Msg.h"
+#include "contexts.h"
+#include "ConnectionImpl.h"
+#include "PrivateImplRef.h"
+
+#include "proton/connection.h"
+
+namespace proton {
+namespace reactor {
+
+template class Handle<ConnectionImpl>;
+typedef PrivateImplRef<Connection> PI;
+
+Connection::Connection() {}
+Connection::Connection(ConnectionImpl* p) { PI::ctor(*this, p); }
+Connection::Connection(const Connection& c) : Handle<ConnectionImpl>() { PI::copy(*this, c); }
+
+Connection& Connection::operator=(const Connection& c) { return PI::assign(*this, c); }
+Connection::~Connection() { PI::dtor(*this); }
+
+Connection::Connection(Container &c) {
+    ConnectionImpl *cimpl = new ConnectionImpl(c);
+    PI::ctor(*this, cimpl);
+}
+
+Transport &Connection::getTransport() { return impl->getTransport(); }
+
+Handler* Connection::getOverride() { return impl->getOverride(); }
+void Connection::setOverride(Handler *h) { impl->setOverride(h); }
+
+void Connection::open() { impl->open(); }
+
+void Connection::close() { impl->close(); }
+
+pn_connection_t *Connection::getPnConnection() { return impl->getPnConnection(); }
+
+std::string Connection::getHostname() { return impl->getHostname(); }
+
+Connection &Connection::getConnection() {
+    return (*this);
+}
+
+Container &Connection::getContainer() { return impl->getContainer(); }
+
+}} // namespace proton::reactor

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/src/ConnectionImpl.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/ConnectionImpl.cpp b/proton-c/bindings/cpp/src/ConnectionImpl.cpp
new file mode 100644
index 0000000..2feecb5
--- /dev/null
+++ b/proton-c/bindings/cpp/src/ConnectionImpl.cpp
@@ -0,0 +1,113 @@
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/cpp/Container.h"
+#include "proton/cpp/Handler.h"
+#include "proton/cpp/exceptions.h"
+#include "ConnectionImpl.h"
+#include "Msg.h"
+#include "contexts.h"
+
+#include "proton/connection.h"
+
+namespace proton {
+namespace reactor {
+
+void ConnectionImpl::incref(ConnectionImpl *impl) {
+    impl->refCount++;
+}
+
+void ConnectionImpl::decref(ConnectionImpl *impl) {
+    impl->refCount--;
+    if (impl->refCount == 0)
+        delete impl;
+}
+
+ConnectionImpl::ConnectionImpl(Container &c) : container(c), refCount(0), override(0), transport(0), defaultSession(0),
+                                               pnConnection(pn_reactor_connection(container.getReactor(), NULL)),
+                                               reactorReference(this)
+{
+    setConnectionContext(pnConnection, this);
+}
+
+ConnectionImpl::~ConnectionImpl() {}
+
+Transport &ConnectionImpl::getTransport() {
+    if (transport)
+        return *transport;
+    throw ProtonException(MSG("Connection has no transport"));
+}
+
+Handler* ConnectionImpl::getOverride() { return override; }
+void ConnectionImpl::setOverride(Handler *h) { override = h; }
+
+void ConnectionImpl::open() {
+    pn_connection_open(pnConnection);
+}
+
+void ConnectionImpl::close() {
+    pn_connection_close(pnConnection);
+}
+
+pn_connection_t *ConnectionImpl::getPnConnection() { return pnConnection; }
+
+std::string ConnectionImpl::getHostname() {
+    return std::string(pn_connection_get_hostname(pnConnection));
+}
+
+Connection &ConnectionImpl::getConnection() {
+    // Endpoint interface.  Should be implemented in the Connection object.
+    throw ProtonException(MSG("Internal error"));
+}
+
+Container &ConnectionImpl::getContainer() {
+    return (container);
+}
+
+void ConnectionImpl::reactorDetach() {
+    // "save" goes out of scope last, preventing possible recursive destructor
+    // confusion with reactorReference.
+    Connection save(reactorReference);
+    if (reactorReference)
+        reactorReference = Connection();
+    pnConnection = 0;
+}
+
+Connection &ConnectionImpl::getReactorReference(pn_connection_t *conn) {
+    if (!conn)
+        throw ProtonException(MSG("Null Proton connection"));
+    ConnectionImpl *impl = getConnectionContext(conn);
+    if (!impl) {
+        // First time we have seen this connection
+        pn_reactor_t *reactor = pn_object_reactor(conn);
+        if (!reactor)
+            throw ProtonException(MSG("Invalid Proton connection specifier"));
+        Container container(getContainerContext(reactor));
+        if (!container)  // can't be one created by our container
+            throw ProtonException(MSG("Unknown Proton connection specifier"));
+        Connection connection(container);
+        impl = connection.impl;
+        setConnectionContext(conn, impl);
+        impl->reactorReference = connection;
+    }
+    return impl->reactorReference;
+}
+
+}} // namespace proton::reactor

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/src/ConnectionImpl.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/ConnectionImpl.h b/proton-c/bindings/cpp/src/ConnectionImpl.h
new file mode 100644
index 0000000..ad8d71e
--- /dev/null
+++ b/proton-c/bindings/cpp/src/ConnectionImpl.h
@@ -0,0 +1,73 @@
+#ifndef PROTON_CPP_CONNECTIONIMPL_H
+#define PROTON_CPP_CONNECTIONIMPL_H
+
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/cpp/ImportExport.h"
+#include "proton/cpp/Endpoint.h"
+#include "proton/cpp/Container.h"
+#include "proton/types.h"
+#include <string>
+
+struct pn_connection_t;
+
+namespace proton {
+namespace reactor {
+
+class Handler;
+class Transport;
+class Container;
+
+class ConnectionImpl : public Endpoint
+{
+  public:
+    PROTON_CPP_EXTERN ConnectionImpl(Container &c);
+    PROTON_CPP_EXTERN ~ConnectionImpl();
+    PROTON_CPP_EXTERN Transport &getTransport();
+    PROTON_CPP_EXTERN Handler *getOverride();
+    PROTON_CPP_EXTERN void setOverride(Handler *h);
+    PROTON_CPP_EXTERN void open();
+    PROTON_CPP_EXTERN void close();
+    PROTON_CPP_EXTERN pn_connection_t *getPnConnection();
+    PROTON_CPP_EXTERN Container &getContainer();
+    PROTON_CPP_EXTERN std::string getHostname();
+    virtual PROTON_CPP_EXTERN Connection &getConnection();
+    static Connection &getReactorReference(pn_connection_t *);
+    static ConnectionImpl *getImpl(const Connection &c) { return c.impl; }
+    void reactorDetach();
+    static void incref(ConnectionImpl *);
+    static void decref(ConnectionImpl *);
+  private:
+    friend class Connector;
+    friend class ContainerImpl;
+    Container container;
+    int refCount;
+    Handler *override;
+    Transport *transport;
+    pn_session_t *defaultSession;  // Temporary, for SessionPerConnection style policy.
+    pn_connection_t *pnConnection;
+    Connection reactorReference;   // Keep-alive reference, until PN_CONNECTION_FINAL.
+};
+
+
+}} // namespace proton::reactor
+
+#endif  /*!PROTON_CPP_CONNECTIONIMPL_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/src/Connector.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Connector.cpp b/proton-c/bindings/cpp/src/Connector.cpp
new file mode 100644
index 0000000..6885575
--- /dev/null
+++ b/proton-c/bindings/cpp/src/Connector.cpp
@@ -0,0 +1,77 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "proton/cpp/Connection.h"
+#include "proton/cpp/Transport.h"
+#include "proton/cpp/Container.h"
+#include "proton/cpp/Event.h"
+#include "proton/connection.h"
+#include "Connector.h"
+#include "ConnectionImpl.h"
+#include "Url.h"
+#include "LogInternal.h"
+
+namespace proton {
+namespace reactor {
+
+Connector::Connector(Connection &c) : connection(c), transport(0) {}
+
+Connector::~Connector() {}
+
+void Connector::setAddress(const std::string &a) {
+    address = a;
+}
+
+void Connector::connect() {
+    pn_connection_t *conn = connection.getPnConnection();
+    pn_connection_set_container(conn, connection.getContainer().getContainerId().c_str());
+    Url url(address);
+    std::string hostname = url.getHost() + ":" + url.getPort();
+    pn_connection_set_hostname(conn, hostname.c_str());
+    PN_CPP_LOG(info, "connecting to " << hostname << "...");
+    transport = new Transport();
+    transport->bind(connection);
+    connection.impl->transport = transport;
+}
+
+
+void Connector::onConnectionLocalOpen(Event &e) {
+    connect();
+}
+
+void Connector::onConnectionRemoteOpen(Event &e) {
+    PN_CPP_LOG(info, "connected to " << e.getConnection().getHostname());
+}
+
+void Connector::onConnectionInit(Event &e) {
+
+}
+
+void Connector::onTransportClosed(Event &e) {
+    // TODO: prepend with reconnect logic
+    PN_CPP_LOG(info, "Disconnected");
+    connection.setOverride(0);  // No more call backs
+    pn_connection_release(connection.impl->pnConnection);
+    delete this;
+}
+
+
+}} // namespace proton::reactor

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/src/Connector.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Connector.h b/proton-c/bindings/cpp/src/Connector.h
new file mode 100644
index 0000000..d829699
--- /dev/null
+++ b/proton-c/bindings/cpp/src/Connector.h
@@ -0,0 +1,59 @@
+#ifndef PROTON_CPP_CONNECTOR_HANDLER_H
+#define PROTON_CPP_CONNECTOR_HANDLER_H
+
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "proton/cpp/ProtonHandler.h"
+#include "proton/event.h"
+#include "proton/reactor.h"
+#include <string>
+
+
+namespace proton {
+namespace reactor {
+
+class Event;
+class Connection;
+class Transport;
+
+class Connector : public ProtonHandler
+{
+  public:
+    Connector(Connection &c);
+    ~Connector();
+    void setAddress(const std::string &host);
+    void connect();
+    virtual void onConnectionLocalOpen(Event &e);
+    virtual void onConnectionRemoteOpen(Event &e);
+    virtual void onConnectionInit(Event &e);
+    virtual void onTransportClosed(Event &e);
+
+  private:
+    Connection connection;
+    std::string address;
+    Transport *transport;
+};
+
+
+}} // namespace proton::reactor
+
+#endif  /*!PROTON_CPP_CONNECTOR_HANDLER_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/ad7c9778/proton-c/bindings/cpp/src/Container.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Container.cpp b/proton-c/bindings/cpp/src/Container.cpp
new file mode 100644
index 0000000..8e79b15
--- /dev/null
+++ b/proton-c/bindings/cpp/src/Container.cpp
@@ -0,0 +1,86 @@
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/cpp/Container.h"
+#include "proton/cpp/MessagingEvent.h"
+#include "proton/cpp/Connection.h"
+#include "proton/cpp/Session.h"
+#include "proton/cpp/MessagingAdapter.h"
+#include "proton/cpp/Acceptor.h"
+#include "proton/cpp/exceptions.h"
+#include "ContainerImpl.h"
+#include "PrivateImplRef.h"
+#include "LogInternal.h"
+
+#include "Connector.h"
+#include "contexts.h"
+#include "Url.h"
+#include "platform.h"
+
+#include "proton/connection.h"
+#include "proton/session.h"
+
+namespace proton {
+namespace reactor {
+
+template class Handle<ContainerImpl>;
+typedef PrivateImplRef<Container> PI;
+
+Container::Container(ContainerImpl* p) { PI::ctor(*this, p); }
+Container::Container(const Container& c) : Handle<ContainerImpl>() { PI::copy(*this, c); }
+Container& Container::operator=(const Container& c) { return PI::assign(*this, c); }
+Container::~Container() { PI::dtor(*this); }
+
+Container::Container(MessagingHandler &mhandler) {
+    ContainerImpl *cimpl = new ContainerImpl(mhandler);
+    PI::ctor(*this, cimpl);
+}
+
+Connection Container::connect(std::string &host) { return impl->connect(host); }
+
+pn_reactor_t *Container::getReactor() { return impl->getReactor(); }
+
+pn_handler_t *Container::getGlobalHandler() { return impl->getGlobalHandler(); }
+
+std::string Container::getContainerId() { return impl->getContainerId(); }
+
+
+Sender Container::createSender(Connection &connection, std::string &addr) {
+    return impl->createSender(connection, addr);
+}
+
+Sender Container::createSender(std::string &urlString) {
+    return impl->createSender(urlString);
+}
+
+Receiver Container::createReceiver(Connection &connection, std::string &addr) {
+    return impl->createReceiver(connection, addr);
+}
+
+Acceptor Container::listen(const std::string &urlString) {
+    return impl->listen(urlString);
+}
+
+
+void Container::run() {
+    impl->run();
+}
+
+}} // namespace proton::reactor


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


[13/50] [abbrv] qpid-proton git commit: PROTON-827: Moved go binding work to branch `go`

Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/132820cb/proton-c/bindings/go/src/qpid.apache.org/proton/interop_test.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/proton/interop_test.go b/proton-c/bindings/go/src/qpid.apache.org/proton/interop_test.go
deleted file mode 100644
index 67d804c..0000000
--- a/proton-c/bindings/go/src/qpid.apache.org/proton/interop_test.go
+++ /dev/null
@@ -1,308 +0,0 @@
-/*
-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.
-*/
-
-// Test that conversion of Go type to/from AMQP is compatible with other
-// bindings.
-//
-package proton
-
-import (
-	"bytes"
-	"fmt"
-	"io"
-	"io/ioutil"
-	"os"
-	"reflect"
-	"strings"
-	"testing"
-)
-
-func assertEqual(want interface{}, got interface{}) {
-	if !reflect.DeepEqual(want, got) {
-		panic(fmt.Errorf("%#v != %#v", want, got))
-	}
-}
-
-func assertNil(err interface{}) {
-	if err != nil {
-		panic(err)
-	}
-}
-
-func getReader(name string) (r io.Reader) {
-	r, err := os.Open("../../../../../../tests/interop/" + name + ".amqp")
-	if err != nil {
-		panic(fmt.Errorf("Can't open %#v: %v", name, err))
-	}
-	return
-}
-
-func remaining(d *Decoder) string {
-	remainder, _ := ioutil.ReadAll(io.MultiReader(d.Buffered(), d.reader))
-	return string(remainder)
-}
-
-// assertDecode: want is the expected value, gotPtr is a pointer to a
-// instance of the same type for Decode.
-func assertDecode(d *Decoder, want interface{}, gotPtr interface{}) {
-
-	assertNil(d.Decode(gotPtr))
-
-	got := reflect.ValueOf(gotPtr).Elem().Interface()
-	assertEqual(want, got)
-
-	// Try round trip encoding
-	bytes, err := Marshal(want, nil)
-	assertNil(err)
-	n, err := Unmarshal(bytes, gotPtr)
-	assertNil(err)
-	assertEqual(n, len(bytes))
-	got = reflect.ValueOf(gotPtr).Elem().Interface()
-	assertEqual(want, got)
-}
-
-func TestUnmarshal(t *testing.T) {
-	bytes, err := ioutil.ReadAll(getReader("strings"))
-	if err != nil {
-		t.Error(err)
-	}
-	for _, want := range []string{"abc\000defg", "abcdefg", "abcdefg", "", "", ""} {
-		var got string
-		n, err := Unmarshal(bytes, &got)
-		if err != nil {
-			t.Error(err)
-		}
-		if want != got {
-			t.Errorf("%#v != %#v", want, got)
-		}
-		bytes = bytes[n:]
-	}
-}
-
-func TestPrimitivesExact(t *testing.T) {
-	d := NewDecoder(getReader("primitives"))
-	// Decoding into exact types
-	var b bool
-	assertDecode(d, true, &b)
-	assertDecode(d, false, &b)
-	var u8 uint8
-	assertDecode(d, uint8(42), &u8)
-	var u16 uint16
-	assertDecode(d, uint16(42), &u16)
-	var i16 int16
-	assertDecode(d, int16(-42), &i16)
-	var u32 uint32
-	assertDecode(d, uint32(12345), &u32)
-	var i32 int32
-	assertDecode(d, int32(-12345), &i32)
-	var u64 uint64
-	assertDecode(d, uint64(12345), &u64)
-	var i64 int64
-	assertDecode(d, int64(-12345), &i64)
-	var f32 float32
-	assertDecode(d, float32(0.125), &f32)
-	var f64 float64
-	assertDecode(d, float64(0.125), &f64)
-}
-
-func TestPrimitivesCompatible(t *testing.T) {
-	d := NewDecoder(getReader("primitives"))
-	// Decoding into compatible types
-	var b bool
-	var i int
-	var u uint
-	var f float64
-	assertDecode(d, true, &b)
-	assertDecode(d, false, &b)
-	assertDecode(d, uint(42), &u)
-	assertDecode(d, uint(42), &u)
-	assertDecode(d, -42, &i)
-	assertDecode(d, uint(12345), &u)
-	assertDecode(d, -12345, &i)
-	assertDecode(d, uint(12345), &u)
-	assertDecode(d, -12345, &i)
-	assertDecode(d, 0.125, &f)
-	assertDecode(d, 0.125, &f)
-}
-
-// assertDecodeValue: want is the expected value, decode into a reflect.Value
-func assertDecodeInterface(d *Decoder, want interface{}) {
-
-	var got, got2 interface{}
-	assertNil(d.Decode(&got))
-
-	assertEqual(want, got)
-
-	// Try round trip encoding
-	bytes, err := Marshal(got, nil)
-	assertNil(err)
-	n, err := Unmarshal(bytes, &got2)
-	assertNil(err)
-	assertEqual(n, len(bytes))
-	assertEqual(want, got2)
-}
-
-func TestPrimitivesInterface(t *testing.T) {
-	d := NewDecoder(getReader("primitives"))
-	assertDecodeInterface(d, true)
-	assertDecodeInterface(d, false)
-	assertDecodeInterface(d, uint8(42))
-	assertDecodeInterface(d, uint16(42))
-	assertDecodeInterface(d, int16(-42))
-	assertDecodeInterface(d, uint32(12345))
-	assertDecodeInterface(d, int32(-12345))
-	assertDecodeInterface(d, uint64(12345))
-	assertDecodeInterface(d, int64(-12345))
-	assertDecodeInterface(d, float32(0.125))
-	assertDecodeInterface(d, float64(0.125))
-}
-
-func TestStrings(t *testing.T) {
-	d := NewDecoder(getReader("strings"))
-	// Test decoding as plain Go strings
-	for _, want := range []string{"abc\000defg", "abcdefg", "abcdefg", "", "", ""} {
-		var got string
-		assertDecode(d, want, &got)
-	}
-	remains := remaining(d)
-	if remains != "" {
-		t.Errorf("leftover: %s", remains)
-	}
-
-	// Test decoding as specific string types
-	d = NewDecoder(getReader("strings"))
-	var bytes []byte
-	var str, sym string
-	assertDecode(d, []byte("abc\000defg"), &bytes)
-	assertDecode(d, "abcdefg", &str)
-	assertDecode(d, "abcdefg", &sym)
-	assertDecode(d, make([]byte, 0), &bytes)
-	assertDecode(d, "", &str)
-	assertDecode(d, "", &sym)
-	remains = remaining(d)
-	if remains != "" {
-		t.Fatalf("leftover: %s", remains)
-	}
-
-	// Test some error handling
-	d = NewDecoder(getReader("strings"))
-	var s string
-	err := d.Decode(s)
-	if err == nil {
-		t.Fatal("Expected error")
-	}
-	if !strings.Contains(err.Error(), "not a pointer") {
-		t.Error(err)
-	}
-	var i int
-	err = d.Decode(&i)
-	if !strings.Contains(err.Error(), "cannot unmarshal") {
-		t.Error(err)
-	}
-	_, err = Unmarshal([]byte{}, nil)
-	if !strings.Contains(err.Error(), "not enough data") {
-		t.Error(err)
-	}
-	_, err = Unmarshal([]byte("foobar"), nil)
-	if !strings.Contains(err.Error(), "invalid-argument") {
-		t.Error(err)
-	}
-}
-
-func TestEncodeDecode(t *testing.T) {
-	type data struct {
-		s  string
-		i  int
-		u8 uint8
-		b  bool
-		f  float32
-		v  interface{}
-	}
-
-	in := data{"foo", 42, 9, true, 1.234, "thing"}
-
-	buf := bytes.Buffer{}
-	e := NewEncoder(&buf)
-	assertNil(e.Encode(in.s))
-	assertNil(e.Encode(in.i))
-	assertNil(e.Encode(in.u8))
-	assertNil(e.Encode(in.b))
-	assertNil(e.Encode(in.f))
-	assertNil(e.Encode(in.v))
-
-	var out data
-	d := NewDecoder(&buf)
-	assertNil(d.Decode(&out.s))
-	assertNil(d.Decode(&out.i))
-	assertNil(d.Decode(&out.u8))
-	assertNil(d.Decode(&out.b))
-	assertNil(d.Decode(&out.f))
-	assertNil(d.Decode(&out.v))
-
-	assertEqual(in, out)
-}
-
-func TestMap(t *testing.T) {
-	d := NewDecoder(getReader("maps"))
-
-	// Generic map
-	var m Map
-	assertDecode(d, Map{"one": int32(1), "two": int32(2), "three": int32(3)}, &m)
-
-	// Interface as map
-	var i interface{}
-	assertDecode(d, Map{int32(1): "one", int32(2): "two", int32(3): "three"}, &i)
-
-	d = NewDecoder(getReader("maps"))
-	// Specific typed map
-	var m2 map[string]int
-	assertDecode(d, map[string]int{"one": 1, "two": 2, "three": 3}, &m2)
-
-	// Round trip a nested map
-	m = Map{int64(1): "one", "two": int32(2), true: Map{uint8(1): true, uint8(2): false}}
-	bytes, err := Marshal(m, nil)
-	assertNil(err)
-	_, err = Unmarshal(bytes, &i)
-	assertNil(err)
-	assertEqual(m, i)
-}
-
-func TestList(t *testing.T) {
-	d := NewDecoder(getReader("lists"))
-	var l List
-	assertDecode(d, List{int32(32), "foo", true}, &l)
-	assertDecode(d, List{}, &l)
-}
-
-func FIXMETestMessage(t *testing.T) {
-	// FIXME aconway 2015-04-09: integrate Message encoding under marshal/unmarshal API.
-	bytes, err := ioutil.ReadAll(getReader("message"))
-	assertNil(err)
-	m, err := DecodeMessage(bytes)
-	assertNil(err)
-	fmt.Printf("%+v\n", m)
-	assertEqual(m.Body(), "hello")
-
-	bytes2 := make([]byte, len(bytes))
-	bytes2, err = m.Encode(bytes2)
-	assertNil(err)
-	assertEqual(bytes, bytes2)
-}
-
-// FIXME aconway 2015-03-13: finish the full interop test

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/132820cb/proton-c/bindings/go/src/qpid.apache.org/proton/marshal.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/proton/marshal.go b/proton-c/bindings/go/src/qpid.apache.org/proton/marshal.go
deleted file mode 100644
index e4f230d..0000000
--- a/proton-c/bindings/go/src/qpid.apache.org/proton/marshal.go
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
-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.
-*/
-
-package proton
-
-// #include <proton/codec.h>
-import "C"
-
-import (
-	"io"
-	"qpid.apache.org/proton/internal"
-	"reflect"
-	"unsafe"
-)
-
-func dataError(prefix string, data *C.pn_data_t) error {
-	err := internal.PnError(unsafe.Pointer(C.pn_data_error(data)))
-	if err != nil {
-		err = internal.Errorf("%s: %s", prefix, err.(internal.Error))
-	}
-	return err
-}
-
-/*
-Marshal encodes a Go value as AMQP data in buffer.
-If buffer is nil, or is not large enough, a new buffer  is created.
-
-Returns the buffer used for encoding with len() adjusted to the actual size of data.
-
-Go types are encoded as follows
-
- +-------------------------------------+--------------------------------------------+
- |Go type                              |AMQP type                                   |
- +-------------------------------------+--------------------------------------------+
- |bool                                 |bool                                        |
- +-------------------------------------+--------------------------------------------+
- |int8, int16, int32, int64 (int)      |byte, short, int, long (int or long)        |
- +-------------------------------------+--------------------------------------------+
- |uint8, uint16, uint32, uint64 (uint) |ubyte, ushort, uint, ulong (uint or ulong)  |
- +-------------------------------------+--------------------------------------------+
- |float32, float64                     |float, double.                              |
- +-------------------------------------+--------------------------------------------+
- |string                               |string                                      |
- +-------------------------------------+--------------------------------------------+
- |[]byte, Binary                       |binary                                      |
- +-------------------------------------+--------------------------------------------+
- |Symbol                               |symbol                                      |
- +-------------------------------------+--------------------------------------------+
- |interface{}                          |the contained type                          |
- +-------------------------------------+--------------------------------------------+
- |nil                                  |null                                        |
- +-------------------------------------+--------------------------------------------+
- |map[K]T                              |map with K and T converted as above         |
- +-------------------------------------+--------------------------------------------+
- |Map                                  |map, may have mixed types for keys, values  |
- +-------------------------------------+--------------------------------------------+
- |[]T                                  |list with T converted as above              |
- +-------------------------------------+--------------------------------------------+
- |List                                 |list, may have mixed types  values          |
- +-------------------------------------+--------------------------------------------+
-
-TODO Go types: array, slice, struct
-
-Go types that cannot be marshaled: complex64/128, uintptr, function, interface, channel
-*/
-func Marshal(v interface{}, buffer []byte) (outbuf []byte, err error) {
-	defer internal.DoRecover(&err)
-	data := C.pn_data(0)
-	defer C.pn_data_free(data)
-	put(data, v)
-	encode := func(buf []byte) ([]byte, error) {
-		n := int(C.pn_data_encode(data, cPtr(buf), cLen(buf)))
-		switch {
-		case n == int(C.PN_OVERFLOW):
-			return buf, overflow
-		case n < 0:
-			return buf, dataError("marshal error", data)
-		default:
-			return buf[:n], nil
-		}
-	}
-	return encodeGrow(buffer, encode)
-}
-
-const minEncode = 256
-
-// overflow is returned when an encoding function can't fit data in the buffer.
-var overflow = internal.Errorf("buffer too small")
-
-// encodeFn encodes into buffer[0:len(buffer)].
-// Returns buffer with length adjusted for data encoded.
-// If buffer too small, returns overflow as error.
-type encodeFn func(buffer []byte) ([]byte, error)
-
-// encodeGrow calls encode() into buffer, if it returns overflow grows the buffer.
-// Returns the final buffer.
-func encodeGrow(buffer []byte, encode encodeFn) ([]byte, error) {
-	if buffer == nil || len(buffer) == 0 {
-		buffer = make([]byte, minEncode)
-	}
-	var err error
-	for buffer, err = encode(buffer); err == overflow; buffer, err = encode(buffer) {
-		buffer = make([]byte, 2*len(buffer))
-	}
-	return buffer, err
-}
-
-func put(data *C.pn_data_t, v interface{}) {
-	switch v := v.(type) {
-	case nil:
-		C.pn_data_put_null(data)
-	case bool:
-		C.pn_data_put_bool(data, C.bool(v))
-	case int8:
-		C.pn_data_put_byte(data, C.int8_t(v))
-	case int16:
-		C.pn_data_put_short(data, C.int16_t(v))
-	case int32:
-		C.pn_data_put_int(data, C.int32_t(v))
-	case int64:
-		C.pn_data_put_long(data, C.int64_t(v))
-	case int:
-		if unsafe.Sizeof(0) == 8 {
-			C.pn_data_put_long(data, C.int64_t(v))
-		} else {
-			C.pn_data_put_int(data, C.int32_t(v))
-		}
-	case uint8:
-		C.pn_data_put_ubyte(data, C.uint8_t(v))
-	case uint16:
-		C.pn_data_put_ushort(data, C.uint16_t(v))
-	case uint32:
-		C.pn_data_put_uint(data, C.uint32_t(v))
-	case uint64:
-		C.pn_data_put_ulong(data, C.uint64_t(v))
-	case uint:
-		if unsafe.Sizeof(0) == 8 {
-			C.pn_data_put_ulong(data, C.uint64_t(v))
-		} else {
-			C.pn_data_put_uint(data, C.uint32_t(v))
-		}
-	case float32:
-		C.pn_data_put_float(data, C.float(v))
-	case float64:
-		C.pn_data_put_double(data, C.double(v))
-	case string:
-		C.pn_data_put_string(data, pnBytes([]byte(v)))
-	case []byte:
-		C.pn_data_put_binary(data, pnBytes(v))
-	case Binary:
-		C.pn_data_put_binary(data, pnBytes([]byte(v)))
-	case Symbol:
-		C.pn_data_put_symbol(data, pnBytes([]byte(v)))
-	case Map: // Special map type
-		C.pn_data_put_map(data)
-		C.pn_data_enter(data)
-		for key, val := range v {
-			put(data, key)
-			put(data, val)
-		}
-		C.pn_data_exit(data)
-	default:
-		switch reflect.TypeOf(v).Kind() {
-		case reflect.Map:
-			putMap(data, v)
-		case reflect.Slice:
-			putList(data, v)
-		default:
-			panic(internal.Errorf("cannot marshal %s to AMQP", reflect.TypeOf(v)))
-		}
-	}
-	err := dataError("marshal", data)
-	if err != nil {
-		panic(err)
-	}
-	return
-}
-
-func putMap(data *C.pn_data_t, v interface{}) {
-	mapValue := reflect.ValueOf(v)
-	C.pn_data_put_map(data)
-	C.pn_data_enter(data)
-	for _, key := range mapValue.MapKeys() {
-		put(data, key.Interface())
-		put(data, mapValue.MapIndex(key).Interface())
-	}
-	C.pn_data_exit(data)
-}
-
-func putList(data *C.pn_data_t, v interface{}) {
-	listValue := reflect.ValueOf(v)
-	C.pn_data_put_list(data)
-	C.pn_data_enter(data)
-	for i := 0; i < listValue.Len(); i++ {
-		put(data, listValue.Index(i).Interface())
-	}
-	C.pn_data_exit(data)
-}
-
-// Encoder encodes AMQP values to an io.Writer
-type Encoder struct {
-	writer io.Writer
-	buffer []byte
-}
-
-// New encoder returns a new encoder that writes to w.
-func NewEncoder(w io.Writer) *Encoder {
-	return &Encoder{w, make([]byte, minEncode)}
-}
-
-func (e *Encoder) Encode(v interface{}) (err error) {
-	e.buffer, err = Marshal(v, e.buffer)
-	if err == nil {
-		e.writer.Write(e.buffer)
-	}
-	return err
-}
-
-func replace(data *C.pn_data_t, v interface{}) {
-	C.pn_data_clear(data)
-	put(data, v)
-}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/132820cb/proton-c/bindings/go/src/qpid.apache.org/proton/message.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/proton/message.go b/proton-c/bindings/go/src/qpid.apache.org/proton/message.go
deleted file mode 100644
index 44be51d..0000000
--- a/proton-c/bindings/go/src/qpid.apache.org/proton/message.go
+++ /dev/null
@@ -1,342 +0,0 @@
-/*
-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.
-*/
-
-package proton
-
-// #include <proton/types.h>
-// #include <proton/message.h>
-// #include <proton/codec.h>
-import "C"
-
-import (
-	"qpid.apache.org/proton/internal"
-	"time"
-	"unsafe"
-)
-
-// FIXME aconway 2015-04-28: Do we need the interface or can we just export the struct?
-
-// Message is the interface to an AMQP message.
-// Instances of this interface contain a pointer to the underlying struct.
-type Message interface {
-	/**
-	 * Inferred indicates how the message content
-	 * is encoded into AMQP sections. If inferred is true then binary and
-	 * list values in the body of the message will be encoded as AMQP DATA
-	 * and AMQP SEQUENCE sections, respectively. If inferred is false,
-	 * then all values in the body of the message will be encoded as AMQP
-	 * VALUE sections regardless of their type.
-	 */
-	Inferred() bool
-	SetInferred(bool)
-
-	/**
-	 * Durable indicates that any parties taking responsibility
-	 * for the message must durably store the content.
-	 */
-	Durable() bool
-	SetDurable(bool)
-
-	/**
-	 * Priority impacts ordering guarantees. Within a
-	 * given ordered context, higher priority messages may jump ahead of
-	 * lower priority messages.
-	 */
-	Priority() uint8
-	SetPriority(uint8)
-
-	/**
-	 * TTL or Time To Live, a message it may be dropped after this duration
-	 */
-	TTL() time.Duration
-	SetTTL(time.Duration)
-
-	/**
-	 * FirstAcquirer indicates
-	 * that the recipient of the message is the first recipient to acquire
-	 * the message, i.e. there have been no failed delivery attempts to
-	 * other acquirers. Note that this does not mean the message has not
-	 * been delivered to, but not acquired, by other recipients.
-	 */
-	FirstAcquirer() bool
-	SetFirstAcquirer(bool)
-
-	/**
-	 * DeliveryCount tracks how many attempts have been made to
-	 * delivery a message.
-	 */
-	DeliveryCount() uint32
-	SetDeliveryCount(uint32)
-
-	/**
-	 * MessageId provides a unique identifier for a message.
-	 * it can be an a string, an unsigned long, a uuid or a
-	 * binary value.
-	 */
-	MessageId() interface{}
-	SetMessageId(interface{})
-
-	UserId() string
-	SetUserId(string)
-
-	Address() string
-	SetAddress(string)
-
-	Subject() string
-	SetSubject(string)
-
-	ReplyTo() string
-	SetReplyTo(string)
-
-	/**
-	 * CorrelationId is set on correlated request and response messages. It can be an a string, an unsigned long, a uuid or a
-	 * binary value.
-	 */
-	CorrelationId() interface{}
-	SetCorrelationId(interface{})
-
-	ContentType() string
-	SetContentType(string)
-
-	ContentEncoding() string
-	SetContentEncoding(string)
-
-	// ExpiryTime indicates an absoulte time when the message may be dropped.
-	// A Zero time (i.e. t.isZero() == true) indicates a message never expires.
-	ExpiryTime() time.Time
-	SetExpiryTime(time.Time)
-
-	CreationTime() time.Time
-	SetCreationTime(time.Time)
-
-	GroupId() string
-	SetGroupId(string)
-
-	GroupSequence() int32
-	SetGroupSequence(int32)
-
-	ReplyToGroupId() string
-	SetReplyToGroupId(string)
-
-	/**
-	 * Instructions can be used to access or modify AMQP delivery instructions.
-	 */
-	Instructions() *map[string]interface{}
-
-	/**
-	 * Annotations  can be used to access or modify AMQP annotations.
-	 */
-	Annotations() *map[string]interface{}
-
-	/**
-	 * Properties  can be used to access or modify the application properties of a message.
-	 */
-	Properties() *map[string]interface{}
-
-	/**
-	 * Body of the message can be any AMQP encodable type.
-	 */
-	Body() interface{}
-	SetBody(interface{})
-
-	// Encode encodes the message as AMQP data. If buffer is non-nil and is large enough
-	// the message is encoded into it, otherwise a new buffer is created.
-	// Returns the buffer containing the message.
-	Encode(buffer []byte) ([]byte, error)
-}
-
-// NewMessage creates a new message instance. The returned interface contains a pointer.
-func NewMessage() Message {
-	pn := C.pn_message() // Pick up default setting from C message.
-	defer C.pn_message_free(pn)
-	return goMessage(pn)
-}
-
-// Message implementation copies all message data into Go space so it can be proprely
-// memory managed.
-//
-type message struct {
-	inferred, durable, firstAcquirer      bool
-	priority                              uint8
-	ttl                                   time.Duration
-	deliveryCount                         uint32
-	messageId                             interface{}
-	userId, address, subject, replyTo     string
-	contentType, contentEncoding          string
-	groupId, replyToGroupId               string
-	creationTime, expiryTime              time.Time
-	groupSequence                         int32
-	correlationId                         interface{}
-	instructions, annotations, properties map[string]interface{}
-	body                                  interface{}
-}
-
-func (m *message) Inferred() bool                        { return m.inferred }
-func (m *message) SetInferred(b bool)                    { m.inferred = b }
-func (m *message) Durable() bool                         { return m.durable }
-func (m *message) SetDurable(b bool)                     { m.durable = b }
-func (m *message) Priority() uint8                       { return m.priority }
-func (m *message) SetPriority(b uint8)                   { m.priority = b }
-func (m *message) TTL() time.Duration                    { return m.ttl }
-func (m *message) SetTTL(d time.Duration)                { m.ttl = d }
-func (m *message) FirstAcquirer() bool                   { return m.firstAcquirer }
-func (m *message) SetFirstAcquirer(b bool)               { m.firstAcquirer = b }
-func (m *message) DeliveryCount() uint32                 { return m.deliveryCount }
-func (m *message) SetDeliveryCount(c uint32)             { m.deliveryCount = c }
-func (m *message) MessageId() interface{}                { return m.messageId }
-func (m *message) SetMessageId(id interface{})           { m.messageId = id }
-func (m *message) UserId() string                        { return m.userId }
-func (m *message) SetUserId(s string)                    { m.userId = s }
-func (m *message) Address() string                       { return m.address }
-func (m *message) SetAddress(s string)                   { m.address = s }
-func (m *message) Subject() string                       { return m.subject }
-func (m *message) SetSubject(s string)                   { m.subject = s }
-func (m *message) ReplyTo() string                       { return m.replyTo }
-func (m *message) SetReplyTo(s string)                   { m.replyTo = s }
-func (m *message) CorrelationId() interface{}            { return m.correlationId }
-func (m *message) SetCorrelationId(c interface{})        { m.correlationId = c }
-func (m *message) ContentType() string                   { return m.contentType }
-func (m *message) SetContentType(s string)               { m.contentType = s }
-func (m *message) ContentEncoding() string               { return m.contentEncoding }
-func (m *message) SetContentEncoding(s string)           { m.contentEncoding = s }
-func (m *message) ExpiryTime() time.Time                 { return m.expiryTime }
-func (m *message) SetExpiryTime(t time.Time)             { m.expiryTime = t }
-func (m *message) CreationTime() time.Time               { return m.creationTime }
-func (m *message) SetCreationTime(t time.Time)           { m.creationTime = t }
-func (m *message) GroupId() string                       { return m.groupId }
-func (m *message) SetGroupId(s string)                   { m.groupId = s }
-func (m *message) GroupSequence() int32                  { return m.groupSequence }
-func (m *message) SetGroupSequence(s int32)              { m.groupSequence = s }
-func (m *message) ReplyToGroupId() string                { return m.replyToGroupId }
-func (m *message) SetReplyToGroupId(s string)            { m.replyToGroupId = s }
-func (m *message) Instructions() *map[string]interface{} { return &m.instructions }
-func (m *message) Annotations() *map[string]interface{}  { return &m.annotations }
-func (m *message) Properties() *map[string]interface{}   { return &m.properties }
-func (m *message) Body() interface{}                     { return m.body }
-func (m *message) SetBody(b interface{})                 { m.body = b }
-
-// rewindGet rewinds and then gets the value from a data object.
-func rewindGet(data *C.pn_data_t, v interface{}) {
-	if data != nil && C.pn_data_size(data) > 0 {
-		C.pn_data_rewind(data)
-		C.pn_data_next(data)
-		get(data, v)
-	}
-}
-
-// goMessage populates a Go message from a pn_message_t
-func goMessage(pn *C.pn_message_t) *message {
-	m := &message{
-		inferred:        bool(C.pn_message_is_inferred(pn)),
-		durable:         bool(C.pn_message_is_durable(pn)),
-		priority:        uint8(C.pn_message_get_priority(pn)),
-		ttl:             time.Duration(C.pn_message_get_ttl(pn)) * time.Millisecond,
-		firstAcquirer:   bool(C.pn_message_is_first_acquirer(pn)),
-		deliveryCount:   uint32(C.pn_message_get_delivery_count(pn)),
-		userId:          goString(C.pn_message_get_user_id(pn)),
-		address:         C.GoString(C.pn_message_get_address(pn)),
-		subject:         C.GoString(C.pn_message_get_subject(pn)),
-		replyTo:         C.GoString(C.pn_message_get_reply_to(pn)),
-		contentType:     C.GoString(C.pn_message_get_content_type(pn)),
-		contentEncoding: C.GoString(C.pn_message_get_content_encoding(pn)),
-		expiryTime:      time.Unix(0, int64(time.Millisecond*time.Duration(C.pn_message_get_expiry_time(pn)))),
-		creationTime:    time.Unix(0, int64(time.Millisecond)*int64(C.pn_message_get_creation_time(pn))),
-		groupId:         C.GoString(C.pn_message_get_group_id(pn)),
-		groupSequence:   int32(C.pn_message_get_group_sequence(pn)),
-		replyToGroupId:  C.GoString(C.pn_message_get_reply_to_group_id(pn)),
-		messageId:       nil,
-		correlationId:   nil,
-		instructions:    make(map[string]interface{}),
-		annotations:     make(map[string]interface{}),
-		properties:      make(map[string]interface{}),
-	}
-	rewindGet(C.pn_message_id(pn), &m.messageId)
-	rewindGet(C.pn_message_correlation_id(pn), &m.correlationId)
-	rewindGet(C.pn_message_instructions(pn), &m.instructions)
-	rewindGet(C.pn_message_annotations(pn), &m.annotations)
-	rewindGet(C.pn_message_properties(pn), &m.properties)
-	rewindGet(C.pn_message_body(pn), &m.body)
-	return m
-}
-
-// pnMessage populates a pn_message_t from a Go message.
-func (m *message) pnMessage() *C.pn_message_t {
-	pn := C.pn_message()
-	C.pn_message_set_inferred(pn, C.bool(m.Inferred()))
-	C.pn_message_set_durable(pn, C.bool(m.Durable()))
-	C.pn_message_set_priority(pn, C.uint8_t(m.priority))
-	C.pn_message_set_ttl(pn, C.pn_millis_t(m.TTL()/time.Millisecond))
-	C.pn_message_set_first_acquirer(pn, C.bool(m.FirstAcquirer()))
-	C.pn_message_set_delivery_count(pn, C.uint32_t(m.deliveryCount))
-	replace(C.pn_message_id(pn), m.MessageId())
-	C.pn_message_set_user_id(pn, pnBytes([]byte(m.UserId())))
-	C.pn_message_set_address(pn, C.CString(m.Address()))
-	C.pn_message_set_subject(pn, C.CString(m.Subject()))
-	C.pn_message_set_reply_to(pn, C.CString(m.ReplyTo()))
-	replace(C.pn_message_correlation_id(pn), m.CorrelationId())
-	C.pn_message_set_content_type(pn, C.CString(m.ContentType()))
-	C.pn_message_set_content_encoding(pn, C.CString(m.ContentEncoding()))
-	C.pn_message_set_expiry_time(pn, pnTime(m.ExpiryTime()))
-	C.pn_message_set_creation_time(pn, pnTime(m.CreationTime()))
-	C.pn_message_set_group_id(pn, C.CString(m.GroupId()))
-	C.pn_message_set_group_sequence(pn, C.pn_sequence_t(m.GroupSequence()))
-	C.pn_message_set_reply_to_group_id(pn, C.CString(m.ReplyToGroupId()))
-	replace(C.pn_message_instructions(pn), *m.Instructions())
-	replace(C.pn_message_annotations(pn), *m.Annotations())
-	replace(C.pn_message_properties(pn), *m.Properties())
-	replace(C.pn_message_body(pn), m.Body())
-	return pn
-}
-
-// FIXME aconway 2015-04-08: Move message encode/decode under Marshal/Unmarshal interfaces.
-
-// DecodeMessage decodes bytes as a message
-func DecodeMessage(data []byte) (Message, error) {
-	pnMsg := C.pn_message()
-	defer C.pn_message_free(pnMsg)
-	if len(data) == 0 {
-		return nil, internal.Errorf("empty buffer for decode")
-	}
-	if C.pn_message_decode(pnMsg, cPtr(data), cLen(data)) < 0 {
-		return nil, internal.Errorf("decoding message: %s",
-			internal.PnError(unsafe.Pointer(C.pn_message_error(pnMsg))))
-	}
-	return goMessage(pnMsg), nil
-}
-
-// Encode the message into bufffer.
-// If buffer is nil or len(buffer) is not sufficient to encode the message a larger
-// buffer will be returned.
-func (m *message) Encode(buffer []byte) ([]byte, error) {
-	pn := m.pnMessage()
-	defer C.pn_message_free(pn)
-	encode := func(buf []byte) ([]byte, error) {
-		len := cLen(buf)
-		result := C.pn_message_encode(pn, cPtr(buf), &len)
-		switch {
-		case result == C.PN_OVERFLOW:
-			return buf, overflow
-		case result < 0:
-			return buf, internal.Errorf("cannot encode message: %s", internal.PnErrorCode(result))
-		default:
-			return buf[:len], nil
-		}
-	}
-	return encodeGrow(buffer, encode)
-}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/132820cb/proton-c/bindings/go/src/qpid.apache.org/proton/message_test.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/proton/message_test.go b/proton-c/bindings/go/src/qpid.apache.org/proton/message_test.go
deleted file mode 100644
index 2baec22..0000000
--- a/proton-c/bindings/go/src/qpid.apache.org/proton/message_test.go
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
-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.
-*/
-
-package proton
-
-import (
-	"reflect"
-	"testing"
-	"time"
-)
-
-func roundTrip(t *testing.T, m Message) {
-	buffer, err := m.Encode(nil)
-	if err != nil {
-		t.Fatalf("Encode failed: %v", err)
-	}
-	m2, err := DecodeMessage(buffer)
-	if err != nil {
-		t.Fatalf("Decode failed: %v", err)
-	}
-	if !reflect.DeepEqual(m, m2) {
-		t.Errorf("Message mismatch got\n%#v\nwant\n%#v", m, m2)
-	}
-}
-
-func TestDefaultMessageRoundTrip(t *testing.T) {
-	m := NewMessage()
-	// Check defaults
-	assertEqual(m.Inferred(), false)
-	assertEqual(m.Durable(), false)
-	assertEqual(m.Priority(), uint8(4))
-	assertEqual(m.TTL(), time.Duration(0))
-	assertEqual(m.UserId(), "")
-	assertEqual(m.Address(), "")
-	assertEqual(m.Subject(), "")
-	assertEqual(m.ReplyTo(), "")
-	assertEqual(m.ContentType(), "")
-	assertEqual(m.ContentEncoding(), "")
-	assertEqual(m.GroupId(), "")
-	assertEqual(m.GroupSequence(), int32(0))
-	assertEqual(m.ReplyToGroupId(), "")
-	assertEqual(m.MessageId(), nil)
-	assertEqual(m.CorrelationId(), nil)
-	assertEqual(*m.Instructions(), map[string]interface{}{})
-	assertEqual(*m.Annotations(), map[string]interface{}{})
-	assertEqual(*m.Properties(), map[string]interface{}{})
-	assertEqual(m.Body(), nil)
-
-	roundTrip(t, m)
-}
-
-func TestMessageRoundTrip(t *testing.T) {
-	m := NewMessage()
-	m.SetInferred(false)
-	m.SetDurable(true)
-	m.SetPriority(42)
-	m.SetTTL(0)
-	m.SetUserId("user")
-	m.SetAddress("address")
-	m.SetSubject("subject")
-	m.SetReplyTo("replyto")
-	m.SetContentType("content")
-	m.SetContentEncoding("encoding")
-	m.SetGroupId("group")
-	m.SetGroupSequence(42)
-	m.SetReplyToGroupId("replytogroup")
-	m.SetMessageId("id")
-	m.SetCorrelationId("correlation")
-	*m.Instructions() = map[string]interface{}{"instructions": "foo"}
-	*m.Annotations() = map[string]interface{}{"annotations": "foo"}
-	*m.Properties() = map[string]interface{}{"int": int32(32), "bool": true, "string": "foo"}
-	m.SetBody("hello")
-	roundTrip(t, m)
-}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/132820cb/proton-c/bindings/go/src/qpid.apache.org/proton/messaging/doc.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/proton/messaging/doc.go b/proton-c/bindings/go/src/qpid.apache.org/proton/messaging/doc.go
deleted file mode 100644
index c815f4e..0000000
--- a/proton-c/bindings/go/src/qpid.apache.org/proton/messaging/doc.go
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
-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.
-*/
-
-/*
-Package messaging provides a procedural, concurrent Go API for exchanging AMQP messages.
-*/
-package messaging
-
-// #cgo LDFLAGS: -lqpid-proton
-import "C"
-
-// Just for package comment

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/132820cb/proton-c/bindings/go/src/qpid.apache.org/proton/messaging/example_test.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/proton/messaging/example_test.go b/proton-c/bindings/go/src/qpid.apache.org/proton/messaging/example_test.go
deleted file mode 100644
index 02302b6..0000000
--- a/proton-c/bindings/go/src/qpid.apache.org/proton/messaging/example_test.go
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
-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.
-*/
-
-// Tests to verify that example code behaves as expected.
-package messaging
-
-import (
-	"bufio"
-	"bytes"
-	"fmt"
-	"io"
-	"io/ioutil"
-	"math/rand"
-	"net"
-	"os"
-	"os/exec"
-	"path"
-	"path/filepath"
-	"reflect"
-	"testing"
-	"time"
-)
-
-func panicIf(err error) {
-	if err != nil {
-		panic(err)
-	}
-}
-
-// A demo broker process
-type broker struct {
-	cmd    *exec.Cmd
-	addr   string
-	runerr chan error
-	err    error
-}
-
-// Try to connect to the broker to verify it is ready, give up after a timeout
-func (b *broker) check() error {
-	dialer := net.Dialer{Deadline: time.Now().Add(time.Second * 10)}
-	for {
-		c, err := dialer.Dial("tcp", b.addr)
-		if err == nil { // Success
-			c.Close()
-			return nil
-		}
-		select {
-		case runerr := <-b.runerr: // Broker exited.
-			return runerr
-		default:
-		}
-		if neterr, ok := err.(net.Error); ok && neterr.Timeout() { // Running but timed out
-			b.stop()
-			return fmt.Errorf("timed out waiting for broker")
-		}
-		time.Sleep(time.Second / 10)
-	}
-}
-
-// Start the demo broker, wait till it is listening on *addr. No-op if already started.
-func (b *broker) start() error {
-	build("event/broker.go")
-	if b.cmd == nil { // Not already started
-		// FIXME aconway 2015-04-30: better way to pick/configure a broker address.
-		b.addr = fmt.Sprintf(":%d", rand.Intn(10000)+10000)
-		b.cmd = exec.Command(exepath("broker"), "-addr", b.addr, "-verbose", "0")
-		b.runerr = make(chan error)
-		// Change the -verbose setting above to see broker output on stdout/stderr.
-		b.cmd.Stderr, b.cmd.Stdout = os.Stderr, os.Stdout
-		go func() {
-			b.runerr <- b.cmd.Run()
-		}()
-		b.err = b.check()
-	}
-	return b.err
-}
-
-func (b *broker) stop() {
-	if b != nil && b.cmd != nil {
-		b.cmd.Process.Kill()
-		b.cmd.Wait()
-	}
-}
-
-// FIXME aconway 2015-04-30: redo all assert/panic tests with checkEqual style.
-func checkEqual(want interface{}, got interface{}) error {
-	if reflect.DeepEqual(want, got) {
-		return nil
-	}
-	return fmt.Errorf("%#v != %#v", want, got)
-}
-
-// runCommand returns an exec.Cmd to run an example.
-func exampleCommand(prog string, arg ...string) *exec.Cmd {
-	build(prog + ".go")
-	cmd := exec.Command(exepath(prog), arg...)
-	cmd.Stderr = os.Stderr
-	return cmd
-}
-
-// Run an example Go program, return the combined output as a string.
-func runExample(prog string, arg ...string) (string, error) {
-	cmd := exampleCommand(prog, arg...)
-	out, err := cmd.Output()
-	return string(out), err
-}
-
-func prefix(prefix string, err error) error {
-	if err != nil {
-		return fmt.Errorf("%s: %s", prefix, err)
-	}
-	return nil
-}
-
-func runExampleWant(want string, prog string, args ...string) error {
-	out, err := runExample(prog, args...)
-	if err != nil {
-		return fmt.Errorf("%s failed: %s: %s", prog, err, out)
-	}
-	return prefix(prog, checkEqual(want, out))
-}
-
-func exampleArgs(args ...string) []string {
-	return append(args, testBroker.addr+"/foo", testBroker.addr+"/bar", testBroker.addr+"/baz")
-}
-
-// Send then receive
-func TestExampleSendReceive(t *testing.T) {
-	if testing.Short() {
-		t.Skip("Skip demo tests in short mode")
-	}
-	testBroker.start()
-	err := runExampleWant(
-		"send: Received all 15 acknowledgements\n",
-		"send",
-		exampleArgs("-count", "5", "-verbose", "1")...)
-	if err != nil {
-		t.Fatal(err)
-	}
-	err = runExampleWant(
-		"receive: Listening\nreceive: Received 15 messages\n",
-		"receive",
-		exampleArgs("-verbose", "1", "-count", "15")...)
-	if err != nil {
-		t.Fatal(err)
-	}
-}
-
-var ready error
-
-func init() { ready = fmt.Errorf("Ready") }
-
-// Run receive in a goroutine.
-// Send ready on errchan when it is listening.
-// Send final error when it is done.
-// Returns the Cmd, caller must Wait()
-func goReceiveWant(errchan chan<- error, want string, arg ...string) *exec.Cmd {
-	cmd := exampleCommand("receive", arg...)
-	go func() {
-		pipe, err := cmd.StdoutPipe()
-		if err != nil {
-			errchan <- err
-			return
-		}
-		out := bufio.NewReader(pipe)
-		cmd.Start()
-		line, err := out.ReadString('\n')
-		if err != nil && err != io.EOF {
-			errchan <- err
-			return
-		}
-		listening := "receive: Listening\n"
-		if line != listening {
-			errchan <- checkEqual(listening, line)
-			return
-		}
-		errchan <- ready
-		buf := bytes.Buffer{}
-		io.Copy(&buf, out) // Collect the rest of the output
-		errchan <- checkEqual(want, buf.String())
-		close(errchan)
-	}()
-	return cmd
-}
-
-// Start receiver first, wait till it is running, then send.
-func TestExampleReceiveSend(t *testing.T) {
-	if testing.Short() {
-		t.Skip("Skip demo tests in short mode")
-	}
-	testBroker.start()
-	recvErr := make(chan error)
-	recvCmd := goReceiveWant(recvErr,
-		"receive: Received 15 messages\n",
-		exampleArgs("-count", "15", "-verbose", "1")...)
-	defer func() {
-		recvCmd.Process.Kill()
-		recvCmd.Wait()
-	}()
-	if err := <-recvErr; err != ready { // Wait for receiver ready
-		t.Fatal(err)
-	}
-	err := runExampleWant(
-		"send: Received all 15 acknowledgements\n",
-		"send",
-		exampleArgs("-count", "5", "-verbose", "1")...)
-	if err != nil {
-		t.Fatal(err)
-	}
-	if err := <-recvErr; err != nil {
-		t.Fatal(err)
-	}
-}
-
-func exepath(relative string) string {
-	if binDir == "" {
-		panic("bindir not set, cannot run example binaries")
-	}
-	return path.Join(binDir, relative)
-}
-
-var testBroker *broker
-var binDir, exampleDir string
-var built map[string]bool
-
-func init() {
-	built = make(map[string]bool)
-}
-
-func build(prog string) {
-	if !built[prog] {
-		build := exec.Command("go", "build", path.Join(exampleDir, prog))
-		build.Dir = binDir
-		out, err := build.CombinedOutput()
-		if err != nil {
-			panic(fmt.Errorf("%v: %s", err, out))
-		}
-		built[prog] = true
-	}
-}
-
-func TestMain(m *testing.M) {
-	var err error
-	exampleDir, err = filepath.Abs("../../../../../../../examples/go")
-	panicIf(err)
-	binDir, err = ioutil.TempDir("", "example_test.go")
-	panicIf(err)
-	defer os.Remove(binDir) // Clean up binaries
-	testBroker = &broker{}  // Broker is started on-demand by tests.
-	defer testBroker.stop()
-	os.Exit(m.Run())
-}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/132820cb/proton-c/bindings/go/src/qpid.apache.org/proton/messaging/handler.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/proton/messaging/handler.go b/proton-c/bindings/go/src/qpid.apache.org/proton/messaging/handler.go
deleted file mode 100644
index 514f0cf..0000000
--- a/proton-c/bindings/go/src/qpid.apache.org/proton/messaging/handler.go
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
-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.
-*/
-
-package messaging
-
-import (
-	"qpid.apache.org/proton"
-	"qpid.apache.org/proton/event"
-)
-
-// FIXME aconway 2015-04-28: cleanup - exposing delivery vs. disposition.
-
-type acksMap map[event.Delivery]chan Disposition
-type receiverMap map[event.Link]chan proton.Message
-
-type handler struct {
-	connection *Connection
-	acks       acksMap
-	receivers  receiverMap
-}
-
-func newHandler(c *Connection) *handler {
-	return &handler{c, make(acksMap), make(receiverMap)}
-}
-
-func (h *handler) HandleMessagingEvent(t event.MessagingEventType, e event.Event) error {
-	switch t {
-	// FIXME aconway 2015-04-29: handle errors.
-	case event.MConnectionClosed:
-		for _, ack := range h.acks {
-			// FIXME aconway 2015-04-29: communicate error info
-			close(ack)
-		}
-
-	case event.MSettled:
-		ack := h.acks[e.Delivery()]
-		if ack != nil {
-			ack <- Disposition(e.Delivery().Remote().Type())
-			close(ack)
-			delete(h.acks, e.Delivery())
-		}
-
-	case event.MMessage:
-		r := h.receivers[e.Link()]
-		if r != nil {
-			m, _ := event.DecodeMessage(e)
-			// FIXME aconway 2015-04-29: hack, direct send, possible blocking.
-			r <- m
-		} else {
-			// FIXME aconway 2015-04-29: Message with no receiver - log? panic? deadletter? drop?
-		}
-	}
-	return nil
-}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/132820cb/proton-c/bindings/go/src/qpid.apache.org/proton/messaging/messaging.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/proton/messaging/messaging.go b/proton-c/bindings/go/src/qpid.apache.org/proton/messaging/messaging.go
deleted file mode 100644
index d32aada..0000000
--- a/proton-c/bindings/go/src/qpid.apache.org/proton/messaging/messaging.go
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
-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.
-*/
-
-package messaging
-
-// #include <proton/disposition.h>
-import "C"
-
-import (
-	"net"
-	"qpid.apache.org/proton"
-	"qpid.apache.org/proton/event"
-)
-
-// Connection is a connection to a remote AMQP endpoint.
-//
-// You can set exported fields to configure the connection before calling
-// Connection.Open()
-//
-type Connection struct {
-	// Server = true means a the connection will do automatic protocol detection.
-	Server bool
-
-	// FIXME aconway 2015-04-17: Other parameters to set up SSL, SASL etc.
-
-	handler *handler
-	pump    *event.Pump
-	session Session
-}
-
-// Make an AMQP connection over a net.Conn connection.
-//
-// Use Connection.Close() to close the Connection, this will also close conn.
-// Using conn.Close() directly will cause an abrupt disconnect rather than an
-// orderly AMQP close.
-//
-func (c *Connection) Open(conn net.Conn) (err error) {
-	c.handler = newHandler(c)
-	c.pump, err = event.NewPump(conn,
-		event.NewMessagingDelegator(c.handler),
-	)
-	if err != nil {
-		return err
-	}
-	if c.Server {
-		c.pump.Server()
-	}
-	go c.pump.Run()
-	return nil
-}
-
-// Connect opens a default client connection. It is a shortcut for
-//    c := &Connection
-//    c.Open()
-//
-func Connect(conn net.Conn) (*Connection, error) {
-	c := &Connection{}
-	err := c.Open(conn)
-	return c, err
-}
-
-// Close the connection.
-//
-// Connections must be closed to clean up resources and stop associated goroutines.
-func (c *Connection) Close() error { return c.pump.Close() }
-
-// DefaultSession returns a default session for the connection.
-//
-// It is created on the first call to DefaultSession() and returned from all subsequent calls.
-// Use Session() for more control over creating sessions.
-//
-func (c *Connection) DefaultSession() (s Session, err error) {
-	if c.session.e.IsNil() {
-		c.session, err = c.Session()
-	}
-	return c.session, err
-}
-
-type sessionErr struct {
-	s   event.Session
-	err error
-}
-
-// Session creates a new session.
-func (c *Connection) Session() (Session, error) {
-	connection := c.pump.Connection()
-	result := make(chan sessionErr)
-	c.pump.Inject <- func() {
-		s, err := connection.Session()
-		if err == nil {
-			s.Open()
-		}
-		result <- sessionErr{s, err}
-	}
-	se := <-result
-	return Session{se.s, c.pump}, se.err
-}
-
-// FIXME aconway 2015-04-27: set sender name, options etc.
-
-// Sender creates a Sender that will send messages to the address addr.
-func (c *Connection) Sender(addr string) (s Sender, err error) {
-	session, err := c.DefaultSession()
-	if err != nil {
-		return Sender{}, err
-	}
-	result := make(chan Sender)
-	c.pump.Inject <- func() {
-		link := session.e.Sender(linkNames.Next())
-		if link.IsNil() {
-			err = session.e.Error()
-		} else {
-			link.Target().SetAddress(addr)
-			// FIXME aconway 2015-04-27: link options?
-			link.Open()
-		}
-		result <- Sender{Link{c, link}}
-	}
-	return <-result, err
-}
-
-// Receiver returns a receiver that will receive messages sent to address addr.
-func (c *Connection) Receiver(addr string) (r Receiver, err error) {
-	// FIXME aconway 2015-04-29: move code to session, in link.go?
-	session, err := c.DefaultSession()
-	if err != nil {
-		return Receiver{}, err
-	}
-	result := make(chan Receiver)
-	c.pump.Inject <- func() {
-		link := session.e.Receiver(linkNames.Next())
-		if link.IsNil() {
-			err = session.e.Error()
-		} else {
-			link.Source().SetAddress(addr)
-			// FIXME aconway 2015-04-27: link options?
-			link.Open()
-		}
-		// FIXME aconway 2015-04-29: hack to avoid blocking, need proper buffering linked to flow control
-		rchan := make(chan proton.Message, 1000)
-		c.handler.receivers[link] = rchan
-		result <- Receiver{Link{c, link}, rchan}
-	}
-	return <-result, err
-}
-
-// FIXME aconway 2015-04-29: counter per session.
-var linkNames proton.UidCounter
-
-// Session is an AMQP session, it contains Senders and Receivers.
-// Every Connection has a DefaultSession, you can create additional sessions
-// with Connection.Session()
-type Session struct {
-	e    event.Session
-	pump *event.Pump
-}
-
-// FIXME aconway 2015-05-05: REWORK Sender/receiver/session.
-
-// Disposition indicates the outcome of a settled message delivery.
-type Disposition uint64
-
-const (
-	// Message was accepted by the receiver
-	Accepted Disposition = C.PN_ACCEPTED
-	// Message was rejected as invalid by the receiver
-	Rejected = C.PN_REJECTED
-	// Message was not processed by the receiver but may be processed by some other receiver.
-	Released = C.PN_RELEASED
-)
-
-// String human readable name for a Disposition.
-func (d Disposition) String() string {
-	switch d {
-	case Accepted:
-		return "Accepted"
-	case Rejected:
-		return "Rejected"
-	case Released:
-		return "Released"
-	default:
-		return "Unknown"
-	}
-}
-
-// FIXME aconway 2015-04-29: How to signal errors via ack channels.
-
-// An Acknowledgement is a channel which will receive the Disposition of the message
-// when it is acknowledged. The channel is closed after the disposition is sent.
-type Acknowledgement <-chan Disposition
-
-// Link has common data and methods for Sender and Receiver links.
-type Link struct {
-	connection *Connection
-	elink      event.Link
-}
-
-// Sender sends messages.
-type Sender struct {
-	Link
-}
-
-// FIXME aconway 2015-04-28: allow user to specify delivery tag.
-// FIXME aconway 2015-04-28: should we provide a sending channel rather than a send function?
-
-// Send sends a message. If d is not nil, the disposition is retured on d.
-// If d is nil the message is sent pre-settled and no disposition is returned.
-func (s *Sender) Send(m proton.Message) (ack Acknowledgement, err error) {
-	ackChan := make(chan Disposition, 1)
-	ack = ackChan
-	s.connection.pump.Inject <- func() {
-		// FIXME aconway 2015-04-28: flow control & credit, buffer or fail?
-		delivery, err := s.elink.Send(m)
-		if err == nil { // FIXME aconway 2015-04-28: error handling
-			s.connection.handler.acks[delivery] = ackChan
-		}
-	}
-	return ack, nil
-}
-
-// Close the sender.
-func (s *Sender) Close() error { return nil } // FIXME aconway 2015-04-27: close/free
-
-// Receiver receives messages via the channel Receive.
-type Receiver struct {
-	Link
-	// Channel of messag
-	Receive <-chan proton.Message
-}
-
-// FIXME aconway 2015-04-29: settlement - ReceivedMessage with Settle() method?
-
-// Close the Receiver.
-func (r *Receiver) Close() error { return nil } // FIXME aconway 2015-04-29: close/free

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/132820cb/proton-c/bindings/go/src/qpid.apache.org/proton/types.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/proton/types.go b/proton-c/bindings/go/src/qpid.apache.org/proton/types.go
deleted file mode 100644
index 07f8aea..0000000
--- a/proton-c/bindings/go/src/qpid.apache.org/proton/types.go
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
-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.
-*/
-
-package proton
-
-// #include <proton/codec.h>
-// const pn_type_t PN_DATA_TYPE_ERROR = (pn_type_t) -1;
-import "C"
-
-import (
-	"bytes"
-	"fmt"
-	"reflect"
-	"time"
-	"unsafe"
-)
-
-func pnTypeString(pt C.pn_type_t) string {
-	switch pt {
-	case C.PN_NULL:
-		return "null"
-	case C.PN_BOOL:
-		return "bool"
-	case C.PN_UBYTE:
-		return "ubyte"
-	case C.PN_BYTE:
-		return "byte"
-	case C.PN_USHORT:
-		return "ushort"
-	case C.PN_SHORT:
-		return "short"
-	case C.PN_CHAR:
-		return "char"
-	case C.PN_UINT:
-		return "uint"
-	case C.PN_INT:
-		return "int"
-	case C.PN_ULONG:
-		return "ulong"
-	case C.PN_LONG:
-		return "long"
-	case C.PN_TIMESTAMP:
-		return "timestamp"
-	case C.PN_FLOAT:
-		return "float"
-	case C.PN_DOUBLE:
-		return "double"
-	case C.PN_DECIMAL32:
-		return "decimal32"
-	case C.PN_DECIMAL64:
-		return "decimal64"
-	case C.PN_DECIMAL128:
-		return "decimal128"
-	case C.PN_UUID:
-		return "uuid"
-	case C.PN_BINARY:
-		return "binary"
-	case C.PN_STRING:
-		return "string"
-	case C.PN_SYMBOL:
-		return "symbol"
-	case C.PN_DESCRIBED:
-		return "described"
-	case C.PN_ARRAY:
-		return "array"
-	case C.PN_LIST:
-		return "list"
-	case C.PN_MAP:
-		return "map"
-	case C.PN_DATA_TYPE_ERROR:
-		return "no-data"
-	default:
-		return fmt.Sprintf("unknown-type(%d)", pt)
-	}
-}
-
-// Go types
-var (
-	bytesType = reflect.TypeOf([]byte{})
-	valueType = reflect.TypeOf(reflect.Value{})
-)
-
-// FIXME aconway 2015-04-08: can't handle AMQP maps with key types that are not valid Go map keys.
-
-// Map is a generic map that can have mixed key and value types and so can represent any AMQP map
-type Map map[interface{}]interface{}
-
-// List is a generic list that can hold mixed values and can represent any AMQP list.
-//
-type List []interface{}
-
-// Symbol is a string that is encoded as an AMQP symbol
-type Symbol string
-
-// Binary is a string that is encoded as an AMQP binary.
-// It is a string rather than a byte[] because byte[] is not hashable and can't be used as
-// a map key, AMQP frequently uses binary types as map keys. It can convert to and from []byte
-type Binary string
-
-// GoString for Map prints values with their types, useful for debugging.
-func (m Map) GoString() string {
-	out := &bytes.Buffer{}
-	fmt.Fprintf(out, "%T{", m)
-	i := len(m)
-	for k, v := range m {
-		fmt.Fprintf(out, "%T(%#v): %T(%#v)", k, k, v, v)
-		i--
-		if i > 0 {
-			fmt.Fprint(out, ", ")
-		}
-	}
-	fmt.Fprint(out, "}")
-	return out.String()
-}
-
-// GoString for List prints values with their types, useful for debugging.
-func (l List) GoString() string {
-	out := &bytes.Buffer{}
-	fmt.Fprintf(out, "%T{", l)
-	for i := 0; i < len(l); i++ {
-		fmt.Fprintf(out, "%T(%#v)", l[i], l[i])
-		if i == len(l)-1 {
-			fmt.Fprint(out, ", ")
-		}
-	}
-	fmt.Fprint(out, "}")
-	return out.String()
-}
-
-// pnTime converts Go time.Time to Proton millisecond Unix time.
-func pnTime(t time.Time) C.pn_timestamp_t {
-	secs := t.Unix()
-	// Note: sub-second accuracy is not guaraunteed if the Unix time in
-	// nanoseconds cannot be represented by an int64 (sometime around year 2260)
-	msecs := (t.UnixNano() % int64(time.Second)) / int64(time.Millisecond)
-	return C.pn_timestamp_t(secs*1000 + msecs)
-}
-
-// goTime converts a pn_timestamp_t to a Go time.Time.
-func goTime(t C.pn_timestamp_t) time.Time {
-	secs := int64(t) / 1000
-	nsecs := (int64(t) % 1000) * int64(time.Millisecond)
-	return time.Unix(secs, nsecs)
-}
-
-func goBytes(cBytes C.pn_bytes_t) (bytes []byte) {
-	if cBytes.start != nil {
-		bytes = C.GoBytes(unsafe.Pointer(cBytes.start), C.int(cBytes.size))
-	}
-	return
-}
-
-func goString(cBytes C.pn_bytes_t) (str string) {
-	if cBytes.start != nil {
-		str = C.GoStringN(cBytes.start, C.int(cBytes.size))
-	}
-	return
-}
-
-func pnBytes(b []byte) C.pn_bytes_t {
-	if len(b) == 0 {
-		return C.pn_bytes_t{0, nil}
-	} else {
-		return C.pn_bytes_t{C.size_t(len(b)), (*C.char)(unsafe.Pointer(&b[0]))}
-	}
-}
-
-func cPtr(b []byte) *C.char {
-	if len(b) == 0 {
-		return nil
-	}
-	return (*C.char)(unsafe.Pointer(&b[0]))
-}
-
-func cLen(b []byte) C.size_t {
-	return C.size_t(len(b))
-}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/132820cb/proton-c/bindings/go/src/qpid.apache.org/proton/uid.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/proton/uid.go b/proton-c/bindings/go/src/qpid.apache.org/proton/uid.go
deleted file mode 100644
index de80846..0000000
--- a/proton-c/bindings/go/src/qpid.apache.org/proton/uid.go
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
-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.
-*/
-
-// Generating unique IDs for various things.
-
-package proton
-
-import (
-	"strconv"
-	"sync/atomic"
-)
-
-// A simple atomic counter to generate unique 64 bit IDs.
-type UidCounter struct{ count uint64 }
-
-// NextInt gets the next uint64 value from the atomic counter.
-func (uc *UidCounter) NextInt() uint64 {
-	return atomic.AddUint64(&uc.count, 1)
-}
-
-// Next gets the next integer value encoded as a base32 string, safe for NUL terminated C strings.
-func (uc *UidCounter) Next() string {
-	return strconv.FormatUint(uc.NextInt(), 32)
-}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/132820cb/proton-c/bindings/go/src/qpid.apache.org/proton/unmarshal.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/proton/unmarshal.go b/proton-c/bindings/go/src/qpid.apache.org/proton/unmarshal.go
deleted file mode 100644
index f904aae..0000000
--- a/proton-c/bindings/go/src/qpid.apache.org/proton/unmarshal.go
+++ /dev/null
@@ -1,552 +0,0 @@
-/*
-Licensed to the Apache Software Foundation (ASF) under one
-oor 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.
-*/
-
-package proton
-
-// #include <proton/codec.h>
-import "C"
-
-import (
-	"bytes"
-	"fmt"
-	"io"
-	"qpid.apache.org/proton/internal"
-	"reflect"
-	"unsafe"
-)
-
-const minDecode = 1024
-
-// Error returned if AMQP data cannot be unmarshaled as the desired Go type.
-type BadUnmarshal struct {
-	// The name of the AMQP type.
-	AMQPType string
-	// The Go type.
-	GoType reflect.Type
-}
-
-func newBadUnmarshal(pnType C.pn_type_t, v interface{}) *BadUnmarshal {
-	return &BadUnmarshal{pnTypeString(pnType), reflect.TypeOf(v)}
-}
-
-func (e BadUnmarshal) Error() string {
-	if e.GoType.Kind() != reflect.Ptr {
-		return fmt.Sprintf("proton: cannot unmarshal to type %s, not a pointer", e.GoType)
-	} else {
-		return fmt.Sprintf("proton: cannot unmarshal AMQP %s to %s", e.AMQPType, e.GoType)
-	}
-}
-
-//
-// Decoding from a pn_data_t
-//
-// NOTE: we use panic() to signal a decoding error, simplifies decoding logic.
-// We recover() at the highest possible level - i.e. in the exported Unmarshal or Decode.
-//
-
-// Decoder decodes AMQP values from an io.Reader.
-//
-type Decoder struct {
-	reader io.Reader
-	buffer bytes.Buffer
-}
-
-// NewDecoder returns a new decoder that reads from r.
-//
-// The decoder has it's own buffer and may read more data than required for the
-// AMQP values requested.  Use Buffered to see if there is data left in the
-// buffer.
-//
-func NewDecoder(r io.Reader) *Decoder {
-	return &Decoder{r, bytes.Buffer{}}
-}
-
-// Buffered returns a reader of the data remaining in the Decoder's buffer. The
-// reader is valid until the next call to Decode.
-//
-func (d *Decoder) Buffered() io.Reader {
-	return bytes.NewReader(d.buffer.Bytes())
-}
-
-// Decode reads the next AMQP value from the Reader and stores it in the value pointed to by v.
-//
-// See the documentation for Unmarshal for details about the conversion of AMQP into a Go value.
-//
-func (d *Decoder) Decode(v interface{}) (err error) {
-	defer internal.DoRecover(&err)
-	data := C.pn_data(0)
-	defer C.pn_data_free(data)
-	var n int
-	for n == 0 && err == nil {
-		n = unmarshal(data, d.buffer.Bytes(), v)
-		if n == 0 { // n == 0 means not enough data, read more
-			err = d.more()
-			if err != nil {
-				return
-			}
-		}
-	}
-	d.buffer.Next(n)
-	return
-}
-
-/*
-Unmarshal decodes AMQP-encoded bytes and stores the result in the value pointed to by v.
-Types are converted as follows:
-
- +---------------------------+----------------------------------------------------------------------+
- |To Go types                |From AMQP types                                                       |
- +===========================+======================================================================+
- |bool                       |bool                                                                  |
- +---------------------------+----------------------------------------------------------------------+
- |int, int8, int16,          |Equivalent or smaller signed integer type: char, byte, short, int,    |
- |int32, int64               |long.                                                                 |
- +---------------------------+----------------------------------------------------------------------+
- |uint, uint8, uint16,       |Equivalent or smaller unsigned integer type: char, ubyte, ushort,     |
- |uint32, uint64 types       |uint, ulong                                                           |
- +---------------------------+----------------------------------------------------------------------+
- |float32, float64           |Equivalent or smaller float or double.                                |
- +---------------------------+----------------------------------------------------------------------+
- |string, []byte             |string, symbol or binary.                                             |
- +---------------------------+----------------------------------------------------------------------+
- |Symbol                     |symbol                                                                |
- +---------------------------+----------------------------------------------------------------------+
- |map[K]T                    |map, provided all keys and values can unmarshal to types K, T         |
- +---------------------------+----------------------------------------------------------------------+
- |Map                        |map, any AMQP map                                                     |
- +---------------------------+----------------------------------------------------------------------+
- |interface{}                |Any AMQP value can be unmarshaled to an interface{} as follows:       |
- |                           +------------------------+---------------------------------------------+
- |                           |AMQP Type               |Go Type in interface{}                       |
- |                           +========================+=============================================+
- |                           |bool                    |bool                                         |
- |                           +------------------------+---------------------------------------------+
- |                           |char                    |unint8                                       |
- |                           +------------------------+---------------------------------------------+
- |                           |byte,short,int,long     |int8,int16,int32,int64                       |
- |                           +------------------------+---------------------------------------------+
- |                           |ubyte,ushort,uint,ulong |uint8,uint16,uint32,uint64                   |
- |                           +------------------------+---------------------------------------------+
- |                           |float, double           |float32, float64                             |
- |                           +------------------------+---------------------------------------------+
- |                           |string                  |string                                       |
- |                           +------------------------+---------------------------------------------+
- |                           |symbol                  |Symbol                                       |
- |                           +------------------------+---------------------------------------------+
- |                           |binary                  |Binary                                       |
- |                           +------------------------+---------------------------------------------+
- |                           |nulll                   |nil                                          |
- |                           +------------------------+---------------------------------------------+
- |                           |map                     |Map                                          |
- |                           +------------------------+---------------------------------------------+
- |                           |list                    |List                                         |
- +---------------------------+------------------------+---------------------------------------------+
-
-The following Go types cannot be unmarshaled: complex64/128, uintptr, function, interface, channel.
-
-TODO types
-
-AMQP: timestamp, decimal32/64/128, uuid, described, array.
-
-Go: array, struct.
-
-Maps: currently we cannot unmarshal AMQP maps with unhashable key types, need an alternate
-representation for those.
-*/
-func Unmarshal(bytes []byte, v interface{}) (n int, err error) {
-	defer internal.DoRecover(&err)
-	data := C.pn_data(0)
-	defer C.pn_data_free(data)
-	n = unmarshal(data, bytes, v)
-	if n == 0 {
-		err = internal.Errorf("not enough data")
-	}
-	return
-}
-
-// more reads more data when we can't parse a complete AMQP type
-func (d *Decoder) more() error {
-	var readSize int64 = minDecode
-	if int64(d.buffer.Len()) > readSize { // Grow by doubling
-		readSize = int64(d.buffer.Len())
-	}
-	var n int64
-	n, err := d.buffer.ReadFrom(io.LimitReader(d.reader, readSize))
-	if n == 0 && err == nil { // ReadFrom won't report io.EOF, just returns 0
-		err = io.EOF
-	}
-	return err
-}
-
-// unmarshal decodes from bytes and converts into the value pointed to by v.
-// Used by Unmarshal and Decode
-//
-// Returns the number of bytes decoded or 0 if not enough data.
-//
-func unmarshal(data *C.pn_data_t, bytes []byte, v interface{}) (n int) {
-	n = decode(data, bytes)
-	if n == 0 {
-		return 0
-	}
-	get(data, v)
-	return
-}
-
-// get value from data into value pointed at by v.
-func get(data *C.pn_data_t, v interface{}) {
-	pnType := C.pn_data_type(data)
-
-	switch v := v.(type) {
-	case *bool:
-		switch pnType {
-		case C.PN_BOOL:
-			*v = bool(C.pn_data_get_bool(data))
-		default:
-			panic(newBadUnmarshal(pnType, v))
-		}
-	case *int8:
-		switch pnType {
-		case C.PN_CHAR:
-			*v = int8(C.pn_data_get_char(data))
-		case C.PN_BYTE:
-			*v = int8(C.pn_data_get_byte(data))
-		default:
-			panic(newBadUnmarshal(pnType, v))
-		}
-	case *uint8:
-		switch pnType {
-		case C.PN_CHAR:
-			*v = uint8(C.pn_data_get_char(data))
-		case C.PN_UBYTE:
-			*v = uint8(C.pn_data_get_ubyte(data))
-		default:
-			panic(newBadUnmarshal(pnType, v))
-		}
-	case *int16:
-		switch pnType {
-		case C.PN_CHAR:
-			*v = int16(C.pn_data_get_char(data))
-		case C.PN_BYTE:
-			*v = int16(C.pn_data_get_byte(data))
-		case C.PN_SHORT:
-			*v = int16(C.pn_data_get_short(data))
-		default:
-			panic(newBadUnmarshal(pnType, v))
-		}
-	case *uint16:
-		switch pnType {
-		case C.PN_CHAR:
-			*v = uint16(C.pn_data_get_char(data))
-		case C.PN_UBYTE:
-			*v = uint16(C.pn_data_get_ubyte(data))
-		case C.PN_USHORT:
-			*v = uint16(C.pn_data_get_ushort(data))
-		default:
-			panic(newBadUnmarshal(pnType, v))
-		}
-	case *int32:
-		switch pnType {
-		case C.PN_CHAR:
-			*v = int32(C.pn_data_get_char(data))
-		case C.PN_BYTE:
-			*v = int32(C.pn_data_get_byte(data))
-		case C.PN_SHORT:
-			*v = int32(C.pn_data_get_short(data))
-		case C.PN_INT:
-			*v = int32(C.pn_data_get_int(data))
-		default:
-			panic(newBadUnmarshal(pnType, v))
-		}
-	case *uint32:
-		switch pnType {
-		case C.PN_CHAR:
-			*v = uint32(C.pn_data_get_char(data))
-		case C.PN_UBYTE:
-			*v = uint32(C.pn_data_get_ubyte(data))
-		case C.PN_USHORT:
-			*v = uint32(C.pn_data_get_ushort(data))
-		case C.PN_UINT:
-			*v = uint32(C.pn_data_get_uint(data))
-		default:
-			panic(newBadUnmarshal(pnType, v))
-		}
-
-	case *int64:
-		switch pnType {
-		case C.PN_CHAR:
-			*v = int64(C.pn_data_get_char(data))
-		case C.PN_BYTE:
-			*v = int64(C.pn_data_get_byte(data))
-		case C.PN_SHORT:
-			*v = int64(C.pn_data_get_short(data))
-		case C.PN_INT:
-			*v = int64(C.pn_data_get_int(data))
-		case C.PN_LONG:
-			*v = int64(C.pn_data_get_long(data))
-		default:
-			panic(newBadUnmarshal(pnType, v))
-		}
-
-	case *uint64:
-		switch pnType {
-		case C.PN_CHAR:
-			*v = uint64(C.pn_data_get_char(data))
-		case C.PN_UBYTE:
-			*v = uint64(C.pn_data_get_ubyte(data))
-		case C.PN_USHORT:
-			*v = uint64(C.pn_data_get_ushort(data))
-		case C.PN_ULONG:
-			*v = uint64(C.pn_data_get_ulong(data))
-		default:
-			panic(newBadUnmarshal(pnType, v))
-		}
-
-	case *int:
-		switch pnType {
-		case C.PN_CHAR:
-			*v = int(C.pn_data_get_char(data))
-		case C.PN_BYTE:
-			*v = int(C.pn_data_get_byte(data))
-		case C.PN_SHORT:
-			*v = int(C.pn_data_get_short(data))
-		case C.PN_INT:
-			*v = int(C.pn_data_get_int(data))
-		case C.PN_LONG:
-			if unsafe.Sizeof(0) == 8 {
-				*v = int(C.pn_data_get_long(data))
-			} else {
-				panic(newBadUnmarshal(pnType, v))
-			}
-		default:
-			panic(newBadUnmarshal(pnType, v))
-		}
-
-	case *uint:
-		switch pnType {
-		case C.PN_CHAR:
-			*v = uint(C.pn_data_get_char(data))
-		case C.PN_UBYTE:
-			*v = uint(C.pn_data_get_ubyte(data))
-		case C.PN_USHORT:
-			*v = uint(C.pn_data_get_ushort(data))
-		case C.PN_UINT:
-			*v = uint(C.pn_data_get_uint(data))
-		case C.PN_ULONG:
-			if unsafe.Sizeof(0) == 8 {
-				*v = uint(C.pn_data_get_ulong(data))
-			} else {
-				panic(newBadUnmarshal(pnType, v))
-			}
-		default:
-			panic(newBadUnmarshal(pnType, v))
-		}
-
-	case *float32:
-		switch pnType {
-		case C.PN_FLOAT:
-			*v = float32(C.pn_data_get_float(data))
-		default:
-			panic(newBadUnmarshal(pnType, v))
-		}
-
-	case *float64:
-		switch pnType {
-		case C.PN_FLOAT:
-			*v = float64(C.pn_data_get_float(data))
-		case C.PN_DOUBLE:
-			*v = float64(C.pn_data_get_double(data))
-		default:
-			panic(newBadUnmarshal(pnType, v))
-		}
-
-	case *string:
-		switch pnType {
-		case C.PN_STRING:
-			*v = goString(C.pn_data_get_string(data))
-		case C.PN_SYMBOL:
-			*v = goString(C.pn_data_get_symbol(data))
-		case C.PN_BINARY:
-			*v = goString(C.pn_data_get_binary(data))
-		default:
-			panic(newBadUnmarshal(pnType, v))
-		}
-
-	case *[]byte:
-		switch pnType {
-		case C.PN_STRING:
-			*v = goBytes(C.pn_data_get_string(data))
-		case C.PN_SYMBOL:
-			*v = goBytes(C.pn_data_get_symbol(data))
-		case C.PN_BINARY:
-			*v = goBytes(C.pn_data_get_binary(data))
-		default:
-			panic(newBadUnmarshal(pnType, v))
-		}
-
-	case *Binary:
-		switch pnType {
-		case C.PN_BINARY:
-			*v = Binary(goBytes(C.pn_data_get_binary(data)))
-		default:
-			panic(newBadUnmarshal(pnType, v))
-		}
-
-	case *Symbol:
-		switch pnType {
-		case C.PN_SYMBOL:
-			*v = Symbol(goBytes(C.pn_data_get_symbol(data)))
-		default:
-			panic(newBadUnmarshal(pnType, v))
-		}
-
-	case *interface{}:
-		getInterface(data, v)
-
-	default:
-		if reflect.TypeOf(v).Kind() != reflect.Ptr {
-			panic(newBadUnmarshal(pnType, v))
-		}
-		switch reflect.TypeOf(v).Elem().Kind() {
-		case reflect.Map:
-			getMap(data, v)
-		case reflect.Slice:
-			getList(data, v)
-		default:
-			panic(newBadUnmarshal(pnType, v))
-		}
-	}
-	err := dataError("unmarshaling", data)
-	if err != nil {
-		panic(err)
-	}
-	return
-}
-
-// Getting into an interface is driven completely by the AMQP type, since the interface{}
-// target is type-neutral.
-func getInterface(data *C.pn_data_t, v *interface{}) {
-	pnType := C.pn_data_type(data)
-	switch pnType {
-	case C.PN_NULL:
-		*v = nil
-	case C.PN_BOOL:
-		*v = bool(C.pn_data_get_bool(data))
-	case C.PN_UBYTE:
-		*v = uint8(C.pn_data_get_ubyte(data))
-	case C.PN_BYTE:
-		*v = int8(C.pn_data_get_byte(data))
-	case C.PN_USHORT:
-		*v = uint16(C.pn_data_get_ushort(data))
-	case C.PN_SHORT:
-		*v = int16(C.pn_data_get_short(data))
-	case C.PN_UINT:
-		*v = uint32(C.pn_data_get_uint(data))
-	case C.PN_INT:
-		*v = int32(C.pn_data_get_int(data))
-	case C.PN_CHAR:
-		*v = uint8(C.pn_data_get_char(data))
-	case C.PN_ULONG:
-		*v = uint64(C.pn_data_get_ulong(data))
-	case C.PN_LONG:
-		*v = int64(C.pn_data_get_long(data))
-	case C.PN_FLOAT:
-		*v = float32(C.pn_data_get_float(data))
-	case C.PN_DOUBLE:
-		*v = float64(C.pn_data_get_double(data))
-	case C.PN_BINARY:
-		*v = Binary(goBytes(C.pn_data_get_binary(data)))
-	case C.PN_STRING:
-		*v = goString(C.pn_data_get_string(data))
-	case C.PN_SYMBOL:
-		*v = Symbol(goString(C.pn_data_get_symbol(data)))
-	case C.PN_MAP:
-		m := make(Map)
-		get(data, &m)
-		*v = m // FIXME aconway 2015-03-13: avoid the copy?
-	case C.PN_LIST:
-		l := make(List, 0)
-		get(data, &l)
-		*v = l // FIXME aconway 2015-03-13: avoid the copy?
-	default:
-		panic(newBadUnmarshal(pnType, v))
-	}
-}
-
-// get into map pointed at by v
-func getMap(data *C.pn_data_t, v interface{}) {
-	pnType := C.pn_data_type(data)
-	if pnType != C.PN_MAP {
-		panic(newBadUnmarshal(pnType, v))
-	}
-	mapValue := reflect.ValueOf(v).Elem()
-	mapValue.Set(reflect.MakeMap(mapValue.Type())) // Clear the map
-	count := int(C.pn_data_get_map(data))
-	if bool(C.pn_data_enter(data)) {
-		for i := 0; i < count/2; i++ {
-			if bool(C.pn_data_next(data)) {
-				key := reflect.New(mapValue.Type().Key())
-				get(data, key.Interface())
-				if bool(C.pn_data_next(data)) {
-					val := reflect.New(mapValue.Type().Elem())
-					get(data, val.Interface())
-					mapValue.SetMapIndex(key.Elem(), val.Elem())
-				}
-			}
-		}
-		C.pn_data_exit(data)
-	}
-}
-
-func getList(data *C.pn_data_t, v interface{}) {
-	pnType := C.pn_data_type(data)
-	if pnType != C.PN_LIST {
-		panic(newBadUnmarshal(pnType, v))
-	}
-	count := int(C.pn_data_get_list(data))
-	listValue := reflect.MakeSlice(reflect.TypeOf(v).Elem(), count, count)
-	if bool(C.pn_data_enter(data)) {
-		for i := 0; i < count; i++ {
-			if bool(C.pn_data_next(data)) {
-				val := reflect.New(listValue.Type().Elem())
-				get(data, val.Interface())
-				listValue.Index(i).Set(val.Elem())
-			}
-		}
-		C.pn_data_exit(data)
-	}
-	// FIXME aconway 2015-04-09: avoid the copy?
-	reflect.ValueOf(v).Elem().Set(listValue)
-}
-
-// decode from bytes.
-// Return bytes decoded or 0 if we could not decode a complete object.
-//
-func decode(data *C.pn_data_t, bytes []byte) int {
-	if len(bytes) == 0 {
-		return 0
-	}
-	n := int(C.pn_data_decode(data, cPtr(bytes), cLen(bytes)))
-	if n == int(C.PN_UNDERFLOW) {
-		C.pn_error_clear(C.pn_data_error(data))
-		return 0
-	} else if n <= 0 {
-		panic(internal.Errorf("unmarshal %s", internal.PnErrorCode(n)))
-	}
-	return n
-}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/132820cb/proton-c/bindings/go/src/qpid.apache.org/proton/url.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/proton/url.go b/proton-c/bindings/go/src/qpid.apache.org/proton/url.go
deleted file mode 100644
index 5bac6ac..0000000
--- a/proton-c/bindings/go/src/qpid.apache.org/proton/url.go
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
-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.
-*/
-
-package proton
-
-/*
-#include <stdlib.h>
-#include <string.h>
-#include <proton/url.h>
-
-// Helper function for setting URL fields.
-typedef void (*setter_fn)(pn_url_t* url, const char* value);
-inline void	set(pn_url_t *url, setter_fn s, const char* value) {
-  s(url, value);
-}
-*/
-import "C"
-
-import (
-	"net"
-	"net/url"
-	"qpid.apache.org/proton/internal"
-	"unsafe"
-)
-
-const (
-	amqp  string = "amqp"
-	amqps        = "amqps"
-)
-
-// ParseUrl parses an AMQP URL string and returns a net/url.Url.
-//
-// It is more forgiving than net/url.Parse and allows most of the parts of the
-// URL to be missing, assuming AMQP defaults.
-//
-func ParseURL(s string) (u *url.URL, err error) {
-	cstr := C.CString(s)
-	defer C.free(unsafe.Pointer(cstr))
-	pnUrl := C.pn_url_parse(cstr)
-	if pnUrl == nil {
-		return nil, internal.Errorf("bad URL %#v", s)
-	}
-	defer C.pn_url_free(pnUrl)
-
-	scheme := C.GoString(C.pn_url_get_scheme(pnUrl))
-	username := C.GoString(C.pn_url_get_username(pnUrl))
-	password := C.GoString(C.pn_url_get_password(pnUrl))
-	host := C.GoString(C.pn_url_get_host(pnUrl))
-	port := C.GoString(C.pn_url_get_port(pnUrl))
-	path := C.GoString(C.pn_url_get_path(pnUrl))
-
-	if err != nil {
-		return nil, internal.Errorf("bad URL %#v: %s", s, err)
-	}
-	if scheme == "" {
-		scheme = amqp
-	}
-	if port == "" {
-		if scheme == amqps {
-			port = amqps
-		} else {
-			port = amqp
-		}
-	}
-	var user *url.Userinfo
-	if password != "" {
-		user = url.UserPassword(username, password)
-	} else if username != "" {
-		user = url.User(username)
-	}
-
-	u = &url.URL{
-		Scheme: scheme,
-		User:   user,
-		Host:   net.JoinHostPort(host, port),
-		Path:   path,
-	}
-
-	return u, nil
-}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/132820cb/proton-c/bindings/go/src/qpid.apache.org/proton/url_test.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/proton/url_test.go b/proton-c/bindings/go/src/qpid.apache.org/proton/url_test.go
deleted file mode 100644
index 7315511..0000000
--- a/proton-c/bindings/go/src/qpid.apache.org/proton/url_test.go
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
-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.
-*/
-
-package proton
-
-import (
-	"fmt"
-)
-
-func ExampleParseURL() {
-	for _, s := range []string{
-		"amqp://username:password@host:1234/path",
-		"host:1234",
-		"host",
-		":1234",
-		"host/path",
-		"amqps://host",
-		"",
-	} {
-		u, err := ParseURL(s)
-		if err != nil {
-			fmt.Println(err)
-		} else {
-			fmt.Println(u)
-		}
-	}
-	// Output:
-	// amqp://username:password@host:1234/path
-	// amqp://host:1234
-	// amqp://host:amqp
-	// amqp://:1234
-	// amqp://host:amqp/path
-	// amqps://host:amqps
-	// proton: bad URL ""
-}


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


[33/50] [abbrv] qpid-proton git commit: Merge branch 'PROTON-885-flaper87' into PROTON-885

Posted by ac...@apache.org.
Merge branch 'PROTON-885-flaper87' into PROTON-885


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/d98fa576
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/d98fa576
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/d98fa576

Branch: refs/heads/cjansen-cpp-client
Commit: d98fa576aa288b9e05976c17273e8be0d78cb50e
Parents: 585b306 786ba2a
Author: Ken Giusti <kg...@apache.org>
Authored: Wed May 20 19:01:27 2015 -0400
Committer: Ken Giusti <kg...@apache.org>
Committed: Wed May 20 19:01:27 2015 -0400

----------------------------------------------------------------------
 LICENSE                                         |   5 +
 proton-c/bindings/python/PYZMQ_LICENSE.BSD      |  32 ++++
 proton-c/bindings/python/setup.py               | 188 ++++++++++++++++++-
 proton-c/bindings/python/setuputils/__init__.py |   0
 proton-c/bindings/python/setuputils/bundle.py   |  84 +++++++++
 proton-c/bindings/python/setuputils/log.py      |  46 +++++
 proton-c/bindings/python/setuputils/misc.py     | 137 ++++++++++++++
 7 files changed, 490 insertions(+), 2 deletions(-)
----------------------------------------------------------------------



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


[10/50] [abbrv] qpid-proton git commit: PROTON-868: Removed commented out code accidentally committed

Posted by ac...@apache.org.
PROTON-868: Removed commented out code accidentally committed


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/57f82738
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/57f82738
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/57f82738

Branch: refs/heads/cjansen-cpp-client
Commit: 57f82738ed1c0cc54ffd2cb61e4cf651fb780ae6
Parents: 0edb24d
Author: Andrew Stitcher <as...@apache.org>
Authored: Tue May 12 14:22:54 2015 -0400
Committer: Andrew Stitcher <as...@apache.org>
Committed: Tue May 12 14:22:54 2015 -0400

----------------------------------------------------------------------
 proton-c/src/sasl/none_sasl.c | 11 -----------
 1 file changed, 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/57f82738/proton-c/src/sasl/none_sasl.c
----------------------------------------------------------------------
diff --git a/proton-c/src/sasl/none_sasl.c b/proton-c/src/sasl/none_sasl.c
index 15d8476..663c3a1 100644
--- a/proton-c/src/sasl/none_sasl.c
+++ b/proton-c/src/sasl/none_sasl.c
@@ -23,17 +23,6 @@
 
 #include "engine/engine-internal.h"
 
-#if 0
-// TODO: skeleton to produce PLAIN init frame
-void pn_sasl_plain(pni_sasl_t *sasl, const char *username, const char *password)
-{
-  if (!sasl) return;
-
-  const char *user = username ? username : "";
-  const char *pass = password ? password : "";
-
-}
-#endif
 static const char ANONYMOUS[] = "ANONYMOUS";
 static const char PLAIN[] = "PLAIN";
 


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


[12/50] [abbrv] qpid-proton git commit: PROTON-877: Finished moving all outcome processing to output side - Also removed now unused halt boolean

Posted by ac...@apache.org.
PROTON-877: Finished moving all outcome processing to output side
- Also removed now unused halt boolean


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/460c7870
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/460c7870
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/460c7870

Branch: refs/heads/cjansen-cpp-client
Commit: 460c78700acdb7f5c0bc516bb57b94d496614958
Parents: 8900500
Author: Andrew Stitcher <as...@apache.org>
Authored: Tue May 12 15:39:08 2015 -0400
Committer: Andrew Stitcher <as...@apache.org>
Committed: Tue May 12 15:39:08 2015 -0400

----------------------------------------------------------------------
 proton-c/src/sasl/cyrus_sasl.c    | 6 +++---
 proton-c/src/sasl/sasl-internal.h | 1 -
 proton-c/src/sasl/sasl.c          | 9 ++++-----
 3 files changed, 7 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/460c7870/proton-c/src/sasl/cyrus_sasl.c
----------------------------------------------------------------------
diff --git a/proton-c/src/sasl/cyrus_sasl.c b/proton-c/src/sasl/cyrus_sasl.c
index 1b3caf0..4add4ad 100644
--- a/proton-c/src/sasl/cyrus_sasl.c
+++ b/proton-c/src/sasl/cyrus_sasl.c
@@ -209,9 +209,9 @@ void pni_process_challenge(pn_transport_t *transport, const pn_bytes_t *recv)
         default:
             pni_check_sasl_result(cyrus_conn, result, transport);
 
-            // Failed somehow
-            sasl->halt = true;
-            pn_transport_close_tail(transport);
+            // Failed somehow - equivalent to failing authentication
+            sasl->outcome = PN_SASL_AUTH;
+            pni_sasl_set_desired_state(transport, SASL_RECVED_OUTCOME);
             break;
     }
 }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/460c7870/proton-c/src/sasl/sasl-internal.h
----------------------------------------------------------------------
diff --git a/proton-c/src/sasl/sasl-internal.h b/proton-c/src/sasl/sasl-internal.h
index 956d4af..da180e4 100644
--- a/proton-c/src/sasl/sasl-internal.h
+++ b/proton-c/src/sasl/sasl-internal.h
@@ -70,7 +70,6 @@ struct pni_sasl_t {
   bool client;
   bool input_bypass;
   bool output_bypass;
-  bool halt;
 };
 
 void pni_split_mechs(char *mechlist, const char* included_mechs, char *mechs[], int *count);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/460c7870/proton-c/src/sasl/sasl.c
----------------------------------------------------------------------
diff --git a/proton-c/src/sasl/sasl.c b/proton-c/src/sasl/sasl.c
index f32e255..c425490 100644
--- a/proton-c/src/sasl/sasl.c
+++ b/proton-c/src/sasl/sasl.c
@@ -375,7 +375,6 @@ pn_sasl_t *pn_sasl(pn_transport_t *transport)
     sasl->last_state = SASL_NONE;
     sasl->input_bypass = false;
     sasl->output_bypass = false;
-    sasl->halt = false;
 
     transport->sasl = sasl;
   }
@@ -398,9 +397,8 @@ static void pni_sasl_force_anonymous(pn_transport_t *transport)
         pni_process_mechanisms(transport, "ANONYMOUS")) {
       pni_sasl_set_desired_state(transport, SASL_PRETEND_OUTCOME);
     } else {
-      sasl->last_state = SASL_RECVED_OUTCOME;
-      sasl->halt = true;
-      pn_transport_close_tail(transport);
+      sasl->outcome = PN_SASL_PERM;
+      pni_sasl_set_desired_state(transport, SASL_RECVED_OUTCOME);
     }
   }
 }
@@ -512,7 +510,8 @@ ssize_t pn_sasl_input(pn_transport_t *transport, const char *bytes, size_t avail
   pn_sasl_process(transport);
 
   pni_sasl_t *sasl = transport->sasl;
-  ssize_t n = pn_dispatcher_input(transport, bytes, available, false, &sasl->halt);
+  bool dummy = false;
+  ssize_t n = pn_dispatcher_input(transport, bytes, available, false, &dummy);
 
   if (n==0 && pni_sasl_is_final_input_state(sasl)) {
     return PN_EOS;


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


[15/50] [abbrv] qpid-proton git commit: Add testresults to .gitignore

Posted by ac...@apache.org.
Add testresults to .gitignore


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/96fdc65c
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/96fdc65c
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/96fdc65c

Branch: refs/heads/cjansen-cpp-client
Commit: 96fdc65cb67997e42e95940095880731cae71d4b
Parents: 132820c
Author: Dominic Evans <do...@uk.ibm.com>
Authored: Wed May 13 13:57:37 2015 +0100
Committer: Dominic Evans <do...@uk.ibm.com>
Committed: Wed May 13 13:57:37 2015 +0100

----------------------------------------------------------------------
 .gitignore | 3 +++
 1 file changed, 3 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/96fdc65c/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 2b509c6..45dd364 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,3 +31,6 @@ proton-c/build
 
 # Executables built by go binding tests
 proton-c/bindings/go/bin
+
+# Testresults from the jenkins build script
+testresults


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


[07/50] [abbrv] qpid-proton git commit: NO-JIRA: set initial transport frame size to 512

Posted by ac...@apache.org.
NO-JIRA: set initial transport frame size to 512

- Added a configuration file named config.h where various parameters
  should be configurable (like transport initial frame buffer size, pnin
          the future _data initial size, etc.)
- Added config.h to the CmakeLists.txt so that it shows up also in the
  Proton.sln Windows solution
- Set initial transport frame buffer size to 512 instead of 4K

Closes #25


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/1fe0aa24
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/1fe0aa24
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/1fe0aa24

Branch: refs/heads/cjansen-cpp-client
Commit: 1fe0aa244f48032e8a60addd7efb20a438118607
Parents: 520f0d8
Author: dcristoloveanu <dc...@microsoft.com>
Authored: Mon May 11 10:30:30 2015 -0700
Committer: Dominic Evans <do...@uk.ibm.com>
Committed: Tue May 12 11:38:06 2015 +0100

----------------------------------------------------------------------
 proton-c/CMakeLists.txt            |  2 ++
 proton-c/src/config.h              | 26 ++++++++++++++++++++++++++
 proton-c/src/transport/transport.c |  3 ++-
 3 files changed, 30 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1fe0aa24/proton-c/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/CMakeLists.txt b/proton-c/CMakeLists.txt
index 6ab9695..1347f16 100644
--- a/proton-c/CMakeLists.txt
+++ b/proton-c/CMakeLists.txt
@@ -342,6 +342,8 @@ set (qpid-proton-core
   src/messenger/transform.c
   src/selectable.c
 
+  src/config.h
+
   ${CMAKE_CURRENT_BINARY_DIR}/src/encodings.h
   ${CMAKE_CURRENT_BINARY_DIR}/src/protocol.h
   )

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1fe0aa24/proton-c/src/config.h
----------------------------------------------------------------------
diff --git a/proton-c/src/config.h b/proton-c/src/config.h
new file mode 100644
index 0000000..9bc5b27
--- /dev/null
+++ b/proton-c/src/config.h
@@ -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.
+*
+*/
+
+#ifndef  _PROTON_SRC_CONFIG_H 
+#define  _PROTON_SRC_CONFIG_H 
+
+#define TRANSPORT_INITIAL_FRAME_SIZE    (512) /* bytes */
+
+#endif /*  _PROTON_SRC_CONFIG_H */

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/1fe0aa24/proton-c/src/transport/transport.c
----------------------------------------------------------------------
diff --git a/proton-c/src/transport/transport.c b/proton-c/src/transport/transport.c
index 46d6364..c0269d9 100644
--- a/proton-c/src/transport/transport.c
+++ b/proton-c/src/transport/transport.c
@@ -30,6 +30,7 @@
 #include "proton/event.h"
 #include "platform.h"
 #include "platform_fmt.h"
+#include "config.h"
 #include "../log_private.h"
 
 #include <stdlib.h>
@@ -349,7 +350,7 @@ static void pn_transport_initialize(void *object)
   transport->scratch = pn_string(NULL);
   transport->args = pn_data(16);
   transport->output_args = pn_data(16);
-  transport->frame = pn_buffer(4*1024);
+  transport->frame = pn_buffer(TRANSPORT_INITIAL_FRAME_SIZE);
   transport->input_frames_ct = 0;
   transport->output_frames_ct = 0;
 


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


[26/50] [abbrv] qpid-proton git commit: PROTON-861: expose the subject from peer certificate

Posted by ac...@apache.org.
PROTON-861: expose the subject from peer certificate


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/894a463b
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/894a463b
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/894a463b

Branch: refs/heads/cjansen-cpp-client
Commit: 894a463bf720ce15148059b6bb79f040f8ce8af2
Parents: 1e4042a
Author: Gordon Sim <gs...@redhat.com>
Authored: Thu May 14 14:54:23 2015 +0100
Committer: Gordon Sim <gs...@redhat.com>
Committed: Fri May 15 17:28:44 2015 +0100

----------------------------------------------------------------------
 proton-c/bindings/python/proton/__init__.py |  7 ++++++-
 proton-c/include/proton/ssl.h               |  8 ++++++++
 proton-c/src/ssl/openssl.c                  | 25 ++++++++++++++++++++++++
 3 files changed, 39 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/894a463b/proton-c/bindings/python/proton/__init__.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/proton/__init__.py b/proton-c/bindings/python/proton/__init__.py
index bc639e3..a4e01f8 100644
--- a/proton-c/bindings/python/proton/__init__.py
+++ b/proton-c/bindings/python/proton/__init__.py
@@ -3459,7 +3459,8 @@ class SSL(object):
       obj._ssl = pn_ssl( transport._impl )
       if obj._ssl is None:
         raise SSLUnavailable()
-      pn_ssl_init( obj._ssl, domain._domain, session_id )
+      if domain:
+        pn_ssl_init( obj._ssl, domain._domain, session_id )
       transport._ssl = obj
     return transport._ssl
 
@@ -3475,6 +3476,10 @@ class SSL(object):
       return name
     return None
 
+  @property
+  def remote_subject(self):
+    return pn_ssl_get_remote_subject( self._ssl )
+
   RESUME_UNKNOWN = PN_SSL_RESUME_UNKNOWN
   RESUME_NEW = PN_SSL_RESUME_NEW
   RESUME_REUSED = PN_SSL_RESUME_REUSED

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/894a463b/proton-c/include/proton/ssl.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/ssl.h b/proton-c/include/proton/ssl.h
index 0ac4aef..87e7025 100644
--- a/proton-c/include/proton/ssl.h
+++ b/proton-c/include/proton/ssl.h
@@ -318,6 +318,14 @@ PN_EXTERN int pn_ssl_set_peer_hostname( pn_ssl_t *ssl, const char *hostname);
  */
 PN_EXTERN int pn_ssl_get_peer_hostname( pn_ssl_t *ssl, char *hostname, size_t *bufsize );
 
+/** Get the subject from the peers certificate.
+ *
+ * @param[in] ssl the ssl client/server to query.
+ * @return A null terminated string representing the full subject,
+ * which is valid until the ssl object is destroyed.
+ */
+PN_EXTERN const char* pn_ssl_get_remote_subject(pn_ssl_t *ssl);
+
 /** @} */
 
 #ifdef __cplusplus

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/894a463b/proton-c/src/ssl/openssl.c
----------------------------------------------------------------------
diff --git a/proton-c/src/ssl/openssl.c b/proton-c/src/ssl/openssl.c
index 2bbdda0..02a16fc 100644
--- a/proton-c/src/ssl/openssl.c
+++ b/proton-c/src/ssl/openssl.c
@@ -111,6 +111,8 @@ struct pni_ssl_t {
   bool ssl_closed;      // shutdown complete, or SSL error
   bool read_blocked;    // SSL blocked until more network data is read
   bool write_blocked;   // SSL blocked until data is written to network
+
+  char *subject;
 };
 
 static inline pn_transport_t *get_transport_internal(pn_ssl_t *ssl)
@@ -780,6 +782,7 @@ void pn_ssl_free(pn_transport_t *transport)
   if (ssl->peer_hostname) free((void *)ssl->peer_hostname);
   if (ssl->inbuf) free((void *)ssl->inbuf);
   if (ssl->outbuf) free((void *)ssl->outbuf);
+  if (ssl->subject) free(ssl->subject);
   free(ssl);
 }
 
@@ -1179,6 +1182,7 @@ static int init_ssl_socket(pn_transport_t* transport, pni_ssl_t *ssl)
     BIO_set_ssl_mode(ssl->bio_ssl, 1);  // client mode
     ssl_log( transport, "Client SSL socket created." );
   }
+  ssl->subject = NULL;
   return 0;
 }
 
@@ -1249,6 +1253,27 @@ int pn_ssl_get_peer_hostname(pn_ssl_t *ssl0, char *hostname, size_t *bufsize)
   return 0;
 }
 
+const char* pn_ssl_get_remote_subject(pn_ssl_t *ssl0)
+{
+  pni_ssl_t *ssl = get_ssl_internal(ssl0);
+  if (!ssl || !ssl->ssl) return NULL;
+  if (!ssl->subject) {
+    X509 *cert = SSL_get_peer_certificate(ssl->ssl);
+    if (!cert) return NULL;
+    X509_NAME *subject = X509_get_subject_name(cert);
+    if (!subject) return NULL;
+
+    BIO *out = BIO_new(BIO_s_mem());
+    X509_NAME_print_ex(out, subject, 0, XN_FLAG_RFC2253);
+    int len = BIO_number_written(out);
+    ssl->subject = (char*) malloc(len+1);
+    ssl->subject[len] = 0;
+    BIO_read(out, ssl->subject, len);
+    BIO_free(out);
+  }
+  return ssl->subject;
+}
+
 static ssize_t process_input_done(pn_transport_t *transport, unsigned int layer, const char *input_data, size_t len)
 {
   return PN_EOS;


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


[48/50] [abbrv] qpid-proton git commit: PROTON-865: Added basic Terminus, Broker.cpp example

Posted by ac...@apache.org.
PROTON-865: Added basic Terminus, Broker.cpp example


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/e8acc1e5
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/e8acc1e5
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/e8acc1e5

Branch: refs/heads/cjansen-cpp-client
Commit: e8acc1e5f58975dc9d1d99d779f5e3c77289a4b1
Parents: 3c0c90f
Author: Clifford Jansen <cl...@apache.org>
Authored: Mon May 11 19:29:53 2015 -0700
Committer: Alan Conway <ac...@redhat.com>
Committed: Tue Jun 2 14:46:15 2015 -0400

----------------------------------------------------------------------
 proton-c/bindings/cpp/CMakeLists.txt            |   4 +
 proton-c/bindings/cpp/examples/Broker.cpp       | 193 +++++++++++++++++++
 .../cpp/include/proton/cpp/Connection.h         |   1 +
 .../bindings/cpp/include/proton/cpp/Endpoint.h  |  11 ++
 .../bindings/cpp/include/proton/cpp/Handle.h    |   4 +
 proton-c/bindings/cpp/include/proton/cpp/Link.h |   6 +
 .../bindings/cpp/include/proton/cpp/Receiver.h  |   1 +
 .../bindings/cpp/include/proton/cpp/Sender.h    |   1 +
 .../bindings/cpp/include/proton/cpp/Terminus.h  |  81 ++++++++
 proton-c/bindings/cpp/src/Connection.cpp        |   4 +
 proton-c/bindings/cpp/src/ConnectionImpl.cpp    |  16 +-
 proton-c/bindings/cpp/src/ConnectionImpl.h      |   3 +-
 proton-c/bindings/cpp/src/ContainerImpl.cpp     |   2 +
 proton-c/bindings/cpp/src/Link.cpp              |  31 ++-
 proton-c/bindings/cpp/src/Receiver.cpp          |   2 +
 proton-c/bindings/cpp/src/Sender.cpp            |   3 +
 proton-c/bindings/cpp/src/Terminus.cpp          | 102 ++++++++++
 17 files changed, 448 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e8acc1e5/proton-c/bindings/cpp/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/CMakeLists.txt b/proton-c/bindings/cpp/CMakeLists.txt
index ba35cb1..54d8ddd 100644
--- a/proton-c/bindings/cpp/CMakeLists.txt
+++ b/proton-c/bindings/cpp/CMakeLists.txt
@@ -37,6 +37,7 @@ set (qpid-proton-cpp-core
     src/Event.cpp
     src/Handler.cpp
     src/Link.cpp
+    src/Terminus.cpp
     src/Acceptor.cpp
     src/Url.cpp
     src/Message.cpp
@@ -99,6 +100,9 @@ add_executable (SimpleRecv examples/SimpleRecv.cpp)
 target_link_libraries (SimpleRecv qpid-proton-cpp)
 add_executable (SimpleSend examples/SimpleSend.cpp)
 target_link_libraries (SimpleSend qpid-proton-cpp)
+add_executable (Broker examples/Broker.cpp)
+target_link_libraries (Broker qpid-proton-cpp)
+
 
 install (TARGETS qpid-proton-cpp
   EXPORT  proton

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e8acc1e5/proton-c/bindings/cpp/examples/Broker.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/examples/Broker.cpp b/proton-c/bindings/cpp/examples/Broker.cpp
new file mode 100644
index 0000000..7d5214d
--- /dev/null
+++ b/proton-c/bindings/cpp/examples/Broker.cpp
@@ -0,0 +1,193 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "proton/cpp/Container.h"
+#include "proton/cpp/MessagingHandler.h"
+
+#include <iostream>
+#include <deque>
+#include <map>
+#include <list>
+
+
+using namespace proton::reactor;
+
+std::string generateUuid(){
+    throw "TODO: platform neutral uuid";
+}
+
+class Queue {
+  public:
+    bool dynamic;
+    typedef std::deque<Message> MsgQ;
+    typedef std::list<Sender> List;
+    MsgQ queue;
+    List consumers;
+
+    Queue(bool dyn = false) : dynamic(dyn), queue(MsgQ()), consumers(List()) {}
+
+    void subscribe(Sender &c) {
+        consumers.push_back(c);
+    }
+
+    bool unsubscribe(Sender &c) {
+        consumers.remove(c);
+        return (consumers.size() == 0 && (dynamic || queue.size() == 0));
+    }
+
+    void publish(Message &m) {
+        queue.push_back(m);
+        dispatch(0);
+    }
+
+    void dispatch(Sender *s) {
+        while (deliverTo(s)) {
+        }
+    }
+
+    bool deliverTo(Sender *consumer) {
+        // deliver to single consumer if supplied, else all consumers
+        int count = consumer ? 1 : consumers.size();
+        if (!count) return false;
+        bool result = false;
+        List::iterator it = consumers.begin();
+        if (!consumer && count) consumer = &*it;
+
+        while (queue.size()) {
+            if (consumer->getCredit()) {
+                consumer->send(queue.front());
+                queue.pop_front();
+                result = true;
+            }
+            if (--count)
+                it++;
+            else
+                return result;
+        }
+        return false;
+    }
+};
+
+class Broker : public MessagingHandler {
+  private:
+    std::string url;
+    typedef std::map<std::string, Queue *> QMap;
+    QMap queues;
+  public:
+
+    Broker(const std::string &s) : url(s), queues(QMap()) {}
+
+    void onStart(Event &e) {
+        e.getContainer().listen(url);
+    }
+
+    Queue &queue(std::string &address) {
+        QMap::iterator it = queues.find(address);
+        if (it == queues.end()) {
+            queues[address] = new Queue();
+            return *queues[address];
+        }
+        else {
+            return *it->second;
+        }
+    }
+
+    void onLinkOpening(Event &e) {
+        Link lnk = e.getLink();
+        if (lnk.isSender()) {
+            Sender sender(lnk);
+            Terminus remoteSource(lnk.getRemoteSource());
+            if (remoteSource.isDynamic()) {
+                std::string address = generateUuid();
+                lnk.getSource().setAddress(address);
+                Queue *q = new Queue(true);
+                queues[address] = q;
+                q->subscribe(sender);
+            }
+            else {
+                std::string address = remoteSource.getAddress();
+                if (!address.empty()) {
+                    lnk.getSource().setAddress(address);
+                    queue(address).subscribe(sender);
+                }
+            }
+        }
+        else {
+            std::string address = lnk.getRemoteTarget().getAddress();
+            if (!address.empty())
+                lnk.getTarget().setAddress(address);
+        }
+    }
+
+    void unsubscribe (Sender &lnk) {
+        std::string address = lnk.getSource().getAddress();
+        QMap::iterator it = queues.find(address);
+        if (it != queues.end() && it->second->unsubscribe(lnk)) {
+            delete it->second;
+            queues.erase(it);
+        }
+    }
+
+    void onLinkClosing(Event &e) {
+        Link lnk = e.getLink();
+        if (lnk.isSender()) {
+            Sender s(lnk);
+            unsubscribe(s);
+        }
+    }
+
+    void onConnectionClosing(Event &e) {
+        removeStaleConsumers(e.getConnection());
+    }
+
+    void onDisconnected(Event &e) {
+        removeStaleConsumers(e.getConnection());
+    }
+
+    void removeStaleConsumers(Connection &connection) {
+        Link l = connection.getLinkHead(Endpoint::REMOTE_ACTIVE);
+        while (l) {
+            if (l.isSender()) {
+                Sender s(l);
+                unsubscribe(s);
+            }
+            l = l.getNext(Endpoint::REMOTE_ACTIVE);
+        }
+    }
+
+    void onSendable(Event &e) {
+        Link lnk = e.getLink();
+        Sender sender(lnk);
+        std::string addr = lnk.getSource().getAddress();
+        queue(addr).dispatch(&sender);
+    }
+
+    void onMessage(Event &e) {
+        std::string addr = e.getLink().getTarget().getAddress();
+        Message msg = e.getMessage();
+        queue(addr).publish(msg);
+    }
+};
+
+int main(int argc, char **argv) {
+    Broker hw("localhost:5672");
+    Container(hw).run();
+}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e8acc1e5/proton-c/bindings/cpp/include/proton/cpp/Connection.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Connection.h b/proton-c/bindings/cpp/include/proton/cpp/Connection.h
index 7d97ebb..86abbe6 100644
--- a/proton-c/bindings/cpp/include/proton/cpp/Connection.h
+++ b/proton-c/bindings/cpp/include/proton/cpp/Connection.h
@@ -57,6 +57,7 @@ class Connection : public Endpoint, public Handle<ConnectionImpl>
     PROTON_CPP_EXTERN Container &getContainer();
     PROTON_CPP_EXTERN std::string getHostname();
     virtual PROTON_CPP_EXTERN Connection &getConnection();
+    PROTON_CPP_EXTERN Link getLinkHead(Endpoint::State mask);
   private:
    friend class PrivateImplRef<Connection>;
    friend class Connector;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e8acc1e5/proton-c/bindings/cpp/include/proton/cpp/Endpoint.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Endpoint.h b/proton-c/bindings/cpp/include/proton/cpp/Endpoint.h
index 9992eff..fc1a712 100644
--- a/proton-c/bindings/cpp/include/proton/cpp/Endpoint.h
+++ b/proton-c/bindings/cpp/include/proton/cpp/Endpoint.h
@@ -22,6 +22,7 @@
  *
  */
 #include "proton/cpp/ImportExport.h"
+#include "proton/connection.h"
 
 namespace proton {
 namespace reactor {
@@ -33,6 +34,16 @@ class Transport;
 class Endpoint
 {
   public:
+    enum {
+        LOCAL_UNINIT = PN_LOCAL_UNINIT,
+        REMOTE_UNINIT = PN_REMOTE_UNINIT,
+        LOCAL_ACTIVE = PN_LOCAL_ACTIVE,
+        REMOTE_ACTIVE = PN_REMOTE_ACTIVE,
+        LOCAL_CLOSED = PN_LOCAL_CLOSED,
+        REMOTE_CLOSED  = PN_REMOTE_CLOSED
+    };
+    typedef int State;
+
     // TODO: getCondition, getRemoteCondition, updateCondition, get/setHandler
     virtual PROTON_CPP_EXTERN Connection &getConnection() = 0;
     Transport PROTON_CPP_EXTERN &getTransport();

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e8acc1e5/proton-c/bindings/cpp/include/proton/cpp/Handle.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Handle.h b/proton-c/bindings/cpp/include/proton/cpp/Handle.h
index 632e30e..77b7814 100644
--- a/proton-c/bindings/cpp/include/proton/cpp/Handle.h
+++ b/proton-c/bindings/cpp/include/proton/cpp/Handle.h
@@ -51,6 +51,10 @@ template <class T> class Handle {
     /** Operator ! supports idiom if (!handle) { do_if_handle_is_null(); } */
     PROTON_CPP_INLINE_EXTERN bool operator !() const { return !impl; }
 
+    /** Operator ==  equal if they point to same non-null object*/
+    PROTON_CPP_INLINE_EXTERN bool operator ==(const Handle<T>& other) const { return impl == other.impl; }
+    PROTON_CPP_INLINE_EXTERN bool operator !=(const Handle<T>& other) const { return impl != other.impl; }
+
     void swap(Handle<T>& h) { T* t = h.impl; h.impl = impl; impl = t; }
 
   private:

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e8acc1e5/proton-c/bindings/cpp/include/proton/cpp/Link.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Link.h b/proton-c/bindings/cpp/include/proton/cpp/Link.h
index 21b1ca2..265d80d 100644
--- a/proton-c/bindings/cpp/include/proton/cpp/Link.h
+++ b/proton-c/bindings/cpp/include/proton/cpp/Link.h
@@ -24,6 +24,7 @@
 #include "proton/cpp/ImportExport.h"
 #include "proton/cpp/ProtonHandle.h"
 #include "proton/cpp/Endpoint.h"
+#include "proton/cpp/Terminus.h"
 #include "proton/types.h"
 #include <string>
 
@@ -45,8 +46,13 @@ class Link : public Endpoint, public ProtonHandle<pn_link_t>
     PROTON_CPP_EXTERN bool isSender();
     PROTON_CPP_EXTERN bool isReceiver();
     PROTON_CPP_EXTERN int getCredit();
+    PROTON_CPP_EXTERN Terminus getSource();
+    PROTON_CPP_EXTERN Terminus getTarget();
+    PROTON_CPP_EXTERN Terminus getRemoteSource();
+    PROTON_CPP_EXTERN Terminus getRemoteTarget();
     PROTON_CPP_EXTERN pn_link_t *getPnLink() const;
     virtual PROTON_CPP_EXTERN Connection &getConnection();
+    PROTON_CPP_EXTERN Link getNext(Endpoint::State mask);
   protected:
     virtual void verifyType(pn_link_t *l);
   private:

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e8acc1e5/proton-c/bindings/cpp/include/proton/cpp/Receiver.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Receiver.h b/proton-c/bindings/cpp/include/proton/cpp/Receiver.h
index 197cfb1..c904dc9 100644
--- a/proton-c/bindings/cpp/include/proton/cpp/Receiver.h
+++ b/proton-c/bindings/cpp/include/proton/cpp/Receiver.h
@@ -37,6 +37,7 @@ class Receiver : public Link
   public:
     PROTON_CPP_EXTERN Receiver(pn_link_t *lnk);
     PROTON_CPP_EXTERN Receiver();
+    PROTON_CPP_EXTERN Receiver(const Link& c);
   protected:
     virtual void verifyType(pn_link_t *l);
 };

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e8acc1e5/proton-c/bindings/cpp/include/proton/cpp/Sender.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Sender.h b/proton-c/bindings/cpp/include/proton/cpp/Sender.h
index fa8cce8..9b8683d 100644
--- a/proton-c/bindings/cpp/include/proton/cpp/Sender.h
+++ b/proton-c/bindings/cpp/include/proton/cpp/Sender.h
@@ -39,6 +39,7 @@ class Sender : public Link
   public:
     PROTON_CPP_EXTERN Sender(pn_link_t *lnk);
     PROTON_CPP_EXTERN Sender();
+    PROTON_CPP_EXTERN Sender(const Link& c);
     PROTON_CPP_EXTERN void send(Message &m);
   protected:
     virtual void verifyType(pn_link_t *l);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e8acc1e5/proton-c/bindings/cpp/include/proton/cpp/Terminus.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Terminus.h b/proton-c/bindings/cpp/include/proton/cpp/Terminus.h
new file mode 100644
index 0000000..092fcc1
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/Terminus.h
@@ -0,0 +1,81 @@
+#ifndef PROTON_CPP_TERMINUS_H
+#define PROTON_CPP_TERMINUS_H
+
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/cpp/ImportExport.h"
+#include "proton/cpp/Link.h"
+
+#include "proton/link.h"
+#include <string>
+
+namespace proton {
+namespace reactor {
+
+class Link;
+
+class Terminus : public ProtonHandle<pn_terminus_t>
+{
+    enum Type {
+        TYPE_UNSPECIFIED = PN_UNSPECIFIED,
+        SOURCE = PN_SOURCE,
+        TARGET = PN_TARGET,
+        COORDINATOR = PN_COORDINATOR
+    };
+    enum ExpiryPolicy {
+        NONDURABLE = PN_NONDURABLE,
+        CONFIGURATION = PN_CONFIGURATION,
+        DELIVERIES = PN_DELIVERIES
+    };
+    enum DistributionMode {
+        MODE_UNSPECIFIED = PN_DIST_MODE_UNSPECIFIED,
+        COPY = PN_DIST_MODE_COPY,
+        MOVE = PN_DIST_MODE_MOVE
+    };
+
+  public:
+    PROTON_CPP_EXTERN Terminus();
+    PROTON_CPP_EXTERN ~Terminus();
+    PROTON_CPP_EXTERN Terminus(const Terminus&);
+    PROTON_CPP_EXTERN Terminus& operator=(const Terminus&);
+    PROTON_CPP_EXTERN pn_terminus_t *getPnTerminus();
+    PROTON_CPP_EXTERN Type getType();
+    PROTON_CPP_EXTERN void setType(Type);
+    PROTON_CPP_EXTERN ExpiryPolicy getExpiryPolicy();
+    PROTON_CPP_EXTERN void setExpiryPolicy(ExpiryPolicy);
+    PROTON_CPP_EXTERN DistributionMode getDistributionMode();
+    PROTON_CPP_EXTERN void setDistributionMode(DistributionMode);
+    PROTON_CPP_EXTERN std::string getAddress();
+    PROTON_CPP_EXTERN void setAddress(std::string &);
+    PROTON_CPP_EXTERN bool isDynamic();
+    PROTON_CPP_EXTERN void setDynamic(bool);
+
+  private:
+    Link *link;
+    PROTON_CPP_EXTERN Terminus(pn_terminus_t *, Link *);
+    friend class Link;
+    friend class ProtonImplRef<Terminus>;
+};
+
+
+}} // namespace proton::reactor
+
+#endif  /*!PROTON_CPP_TERMINUS_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e8acc1e5/proton-c/bindings/cpp/src/Connection.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Connection.cpp b/proton-c/bindings/cpp/src/Connection.cpp
index 49d171e..1db8fbc 100644
--- a/proton-c/bindings/cpp/src/Connection.cpp
+++ b/proton-c/bindings/cpp/src/Connection.cpp
@@ -66,4 +66,8 @@ Connection &Connection::getConnection() {
 
 Container &Connection::getContainer() { return impl->getContainer(); }
 
+Link Connection::getLinkHead(Endpoint::State mask) {
+    return impl->getLinkHead(mask);
+}
+
 }} // namespace proton::reactor

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e8acc1e5/proton-c/bindings/cpp/src/ConnectionImpl.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/ConnectionImpl.cpp b/proton-c/bindings/cpp/src/ConnectionImpl.cpp
index be01f8d..9cadffe 100644
--- a/proton-c/bindings/cpp/src/ConnectionImpl.cpp
+++ b/proton-c/bindings/cpp/src/ConnectionImpl.cpp
@@ -41,10 +41,12 @@ void ConnectionImpl::decref(ConnectionImpl *impl) {
         delete impl;
 }
 
-ConnectionImpl::ConnectionImpl(Container &c) : container(c), refCount(0), override(0), transport(0), defaultSession(0),
-                                               pnConnection(pn_reactor_connection(container.getReactor(), NULL)),
+ConnectionImpl::ConnectionImpl(Container &c, pn_connection_t *pnConn) : container(c), refCount(0), override(0), transport(0), defaultSession(0),
+                                               pnConnection(pnConn),
                                                reactorReference(this)
 {
+    if (!pnConnection)
+        pnConnection = pn_reactor_connection(container.getReactor(), NULL);
     setConnectionContext(pnConnection, this);
 }
 
@@ -110,12 +112,14 @@ Connection &ConnectionImpl::getReactorReference(pn_connection_t *conn) {
         Container container(getContainerContext(reactor));
         if (!container)  // can't be one created by our container
             throw ProtonException(MSG("Unknown Proton connection specifier"));
-        Connection connection(container);
-        impl = connection.impl;
-        setConnectionContext(conn, impl);
-        impl->reactorReference = connection;
+        impl = new ConnectionImpl(container, conn);
     }
     return impl->reactorReference;
 }
 
+Link ConnectionImpl::getLinkHead(Endpoint::State mask) {
+    return Link(pn_link_head(pnConnection, mask));
+}
+
+
 }} // namespace proton::reactor

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e8acc1e5/proton-c/bindings/cpp/src/ConnectionImpl.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/ConnectionImpl.h b/proton-c/bindings/cpp/src/ConnectionImpl.h
index ad8d71e..11b5765 100644
--- a/proton-c/bindings/cpp/src/ConnectionImpl.h
+++ b/proton-c/bindings/cpp/src/ConnectionImpl.h
@@ -39,7 +39,7 @@ class Container;
 class ConnectionImpl : public Endpoint
 {
   public:
-    PROTON_CPP_EXTERN ConnectionImpl(Container &c);
+    PROTON_CPP_EXTERN ConnectionImpl(Container &c, pn_connection_t *pnConn = 0);
     PROTON_CPP_EXTERN ~ConnectionImpl();
     PROTON_CPP_EXTERN Transport &getTransport();
     PROTON_CPP_EXTERN Handler *getOverride();
@@ -49,6 +49,7 @@ class ConnectionImpl : public Endpoint
     PROTON_CPP_EXTERN pn_connection_t *getPnConnection();
     PROTON_CPP_EXTERN Container &getContainer();
     PROTON_CPP_EXTERN std::string getHostname();
+    PROTON_CPP_EXTERN Link getLinkHead(Endpoint::State mask);
     virtual PROTON_CPP_EXTERN Connection &getConnection();
     static Connection &getReactorReference(pn_connection_t *);
     static ConnectionImpl *getImpl(const Connection &c) { return c.impl; }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e8acc1e5/proton-c/bindings/cpp/src/ContainerImpl.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/ContainerImpl.cpp b/proton-c/bindings/cpp/src/ContainerImpl.cpp
index d1339f0..1cabf6c 100644
--- a/proton-c/bindings/cpp/src/ContainerImpl.cpp
+++ b/proton-c/bindings/cpp/src/ContainerImpl.cpp
@@ -122,6 +122,8 @@ class OverrideHandler : public Handler
             ConnectionImpl *cimpl = getConnectionContext(conn);
             if (cimpl)
                 cimpl->reactorDetach();
+            // TODO: remember all connections and do reactorDetach of zombies connections
+            // not pn_connection_release'd at PN_REACTOR_FINAL.
         }
     }
 };

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e8acc1e5/proton-c/bindings/cpp/src/Link.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Link.cpp b/proton-c/bindings/cpp/src/Link.cpp
index 3356b38..aab01d9 100644
--- a/proton-c/bindings/cpp/src/Link.cpp
+++ b/proton-c/bindings/cpp/src/Link.cpp
@@ -33,12 +33,6 @@
 namespace proton {
 namespace reactor {
 
-namespace {
-
-static inline void throwIfNull(pn_link_t *l) { if (!l) throw ProtonException(MSG("Disassociated link")); }
-
-}
-
 template class ProtonHandle<pn_link_t>;
 typedef ProtonImplRef<Link> PI;
 
@@ -67,12 +61,10 @@ void Link::verifyType(pn_link_t *l) {} // Generic link can be sender or receiver
 pn_link_t *Link::getPnLink() const { return impl; }
 
 void Link::open() {
-    throwIfNull(impl);
     pn_link_open(impl);
 }
 
 void Link::close() {
-    throwIfNull(impl);
     pn_link_close(impl);
 }
 
@@ -85,15 +77,34 @@ bool Link::isReceiver() {
 }
 
 int Link::getCredit() {
-    throwIfNull(impl);
     return pn_link_credit(impl);
 }
 
+Terminus Link::getSource() {
+    return Terminus(pn_link_source(impl), this);
+}
+
+Terminus Link::getTarget() {
+    return Terminus(pn_link_target(impl), this);
+}
+
+Terminus Link::getRemoteSource() {
+    return Terminus(pn_link_remote_source(impl), this);
+}
+
+Terminus Link::getRemoteTarget() {
+    return Terminus(pn_link_remote_target(impl), this);
+}
+
 Connection &Link::getConnection() {
-    throwIfNull(impl);
     pn_session_t *s = pn_link_session(impl);
     pn_connection_t *c = pn_session_connection(s);
     return ConnectionImpl::getReactorReference(c);
 }
 
+Link Link::getNext(Endpoint::State mask) {
+
+    return Link(pn_link_next(impl, (pn_state_t) mask));
+}
+
 }} // namespace proton::reactor

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e8acc1e5/proton-c/bindings/cpp/src/Receiver.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Receiver.cpp b/proton-c/bindings/cpp/src/Receiver.cpp
index 557e736..ad9a6d1 100644
--- a/proton-c/bindings/cpp/src/Receiver.cpp
+++ b/proton-c/bindings/cpp/src/Receiver.cpp
@@ -34,6 +34,8 @@ namespace reactor {
 Receiver::Receiver(pn_link_t *lnk) : Link(lnk) {}
 Receiver::Receiver() : Link(0) {}
 
+Receiver::Receiver(const Link& c) : Link(c.getPnLink()) {}
+
 void Receiver::verifyType(pn_link_t *lnk) {
     if (lnk && pn_link_is_sender(lnk))
         throw ProtonException(MSG("Creating receiver with sender context"));

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e8acc1e5/proton-c/bindings/cpp/src/Sender.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Sender.cpp b/proton-c/bindings/cpp/src/Sender.cpp
index 74d4b0f..c521ad1 100644
--- a/proton-c/bindings/cpp/src/Sender.cpp
+++ b/proton-c/bindings/cpp/src/Sender.cpp
@@ -46,6 +46,9 @@ void Sender::verifyType(pn_link_t *lnk) {
         throw ProtonException(MSG("Creating sender with receiver context"));
 }
 
+Sender::Sender(const Link& c) : Link(c.getPnLink()) {}
+
+
 namespace{
 // revisit if thread safety required
 uint64_t tagCounter = 0;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/e8acc1e5/proton-c/bindings/cpp/src/Terminus.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Terminus.cpp b/proton-c/bindings/cpp/src/Terminus.cpp
new file mode 100644
index 0000000..f66979e
--- /dev/null
+++ b/proton-c/bindings/cpp/src/Terminus.cpp
@@ -0,0 +1,102 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "proton/cpp/Link.h"
+#include "proton/link.h"
+
+namespace proton {
+namespace reactor {
+
+template class ProtonHandle<pn_terminus_t>;
+typedef ProtonImplRef<Terminus> PI;
+
+// Note: the pn_terminus_t is not ref counted.  We count the parent link.
+
+Terminus::Terminus() : link(0) {
+    impl = 0;
+}
+
+Terminus::Terminus(pn_terminus_t *p, Link *l) : link(l) {
+    impl = p;
+    pn_incref(link->getPnLink());
+}
+Terminus::Terminus(const Terminus& c) : ProtonHandle<pn_terminus_t>() {
+    impl = c.impl;
+    link = c.link;
+    pn_incref(link->getPnLink());
+}
+Terminus& Terminus::operator=(const Terminus& c) {
+    if (impl == c.impl) return *this;
+    if (impl) pn_decref(link->getPnLink());
+    impl = c.impl;
+    link = c.link;
+    pn_incref(link->getPnLink());
+    return *this;
+}
+Terminus::~Terminus() {
+    if (impl)
+        pn_decref(link->getPnLink());
+}
+
+pn_terminus_t *Terminus::getPnTerminus() { return impl; }
+
+Terminus::Type Terminus::getType() {
+    return (Type) pn_terminus_get_type(impl);
+}
+
+void Terminus::setType(Type type) {
+    pn_terminus_set_type(impl, (pn_terminus_type_t) type);
+}
+
+Terminus::ExpiryPolicy Terminus::getExpiryPolicy() {
+    return (ExpiryPolicy) pn_terminus_get_type(impl);
+}
+
+void Terminus::setExpiryPolicy(ExpiryPolicy policy) {
+    pn_terminus_set_expiry_policy(impl, (pn_expiry_policy_t) policy);
+}
+
+Terminus::DistributionMode Terminus::getDistributionMode() {
+    return (DistributionMode) pn_terminus_get_type(impl);
+}
+
+void Terminus::setDistributionMode(DistributionMode mode) {
+    pn_terminus_set_distribution_mode(impl, (pn_distribution_mode_t) mode);
+}
+
+std::string Terminus::getAddress() {
+    const char *addr = pn_terminus_get_address(impl);
+    return addr ? std::string(addr) : std::string();
+}
+
+void Terminus::setAddress(std::string &addr) {
+    pn_terminus_set_address(impl, addr.c_str());
+}
+
+bool Terminus::isDynamic() {
+    return (Type) pn_terminus_is_dynamic(impl);
+}
+
+void Terminus::setDynamic(bool d) {
+    pn_terminus_set_dynamic(impl, d);
+}
+
+}} // namespace proton::reactor


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


[36/50] [abbrv] qpid-proton git commit: NO-JIRA: Fix SSL tests to correctly create server transports.

Posted by ac...@apache.org.
NO-JIRA: Fix SSL tests to correctly create server transports.


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/3bd4aba5
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/3bd4aba5
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/3bd4aba5

Branch: refs/heads/cjansen-cpp-client
Commit: 3bd4aba5f71ae30fafeaa02e1a28dd8d3714a520
Parents: e349a02
Author: Andrew Stitcher <as...@apache.org>
Authored: Fri May 22 18:43:54 2015 -0400
Committer: Andrew Stitcher <as...@apache.org>
Committed: Fri May 22 18:45:34 2015 -0400

----------------------------------------------------------------------
 tests/python/proton_tests/ssl.py | 62 +++++++++++++++++------------------
 1 file changed, 31 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3bd4aba5/tests/python/proton_tests/ssl.py
----------------------------------------------------------------------
diff --git a/tests/python/proton_tests/ssl.py b/tests/python/proton_tests/ssl.py
index f5fae3f..d502e23 100644
--- a/tests/python/proton_tests/ssl.py
+++ b/tests/python/proton_tests/ssl.py
@@ -51,13 +51,13 @@ class SslTest(common.Test):
     class SslTestConnection(object):
         """ Represents a single SSL connection.
         """
-        def __init__(self, domain=None, session_details=None):
+        def __init__(self, domain=None, mode=Transport.CLIENT, session_details=None):
             if not common.isSSLPresent():
                 raise Skipped("No SSL libraries found.")
 
             self.ssl = None
             self.domain = domain
-            self.transport = Transport()
+            self.transport = Transport(mode)
             self.connection = Connection()
             self.transport.bind(self.connection)
             if domain:
@@ -84,7 +84,7 @@ class SslTest(common.Test):
         """ By default, both the server and the client support anonymous
         ciphers - they should connect without need for a certificate.
         """
-        server = SslTest.SslTestConnection( self.server_domain )
+        server = SslTest.SslTestConnection( self.server_domain, mode=Transport.SERVER )
         client = SslTest.SslTestConnection( self.client_domain )
 
         # check that no SSL connection exists
@@ -113,7 +113,7 @@ class SslTest(common.Test):
         self.client_domain.set_trusted_ca_db(self._testpath("ca-certificate.pem"))
         self.client_domain.set_peer_authentication( SSLDomain.VERIFY_PEER )
 
-        server = SslTest.SslTestConnection( self.server_domain )
+        server = SslTest.SslTestConnection( self.server_domain, mode=Transport.SERVER )
         client = SslTest.SslTestConnection( self.client_domain )
 
         client.connection.open()
@@ -135,7 +135,7 @@ class SslTest(common.Test):
         self.server_domain.set_credentials(self._testpath("server-certificate.pem"),
                                            self._testpath("server-private-key.pem"),
                                            "server-password")
-        server = SslTest.SslTestConnection( self.server_domain )
+        server = SslTest.SslTestConnection( self.server_domain, mode=Transport.SERVER )
         client = SslTest.SslTestConnection( self.client_domain )
 
         client.connection.open()
@@ -156,7 +156,7 @@ class SslTest(common.Test):
         self.client_domain.set_trusted_ca_db(self._testpath("ca-certificate.pem"))
         self.client_domain.set_peer_authentication( SSLDomain.VERIFY_PEER )
 
-        server = SslTest.SslTestConnection( self.server_domain )
+        server = SslTest.SslTestConnection( self.server_domain, mode=Transport.SERVER )
         client = SslTest.SslTestConnection( self.client_domain )
 
         client.connection.open()
@@ -178,7 +178,7 @@ class SslTest(common.Test):
         self.server_domain.set_trusted_ca_db(self._testpath("ca-certificate.pem"))
         self.server_domain.set_peer_authentication( SSLDomain.VERIFY_PEER,
                                                     self._testpath("ca-certificate.pem") )
-        server = SslTest.SslTestConnection( self.server_domain )
+        server = SslTest.SslTestConnection( self.server_domain, mode=Transport.SERVER )
 
         # give the client a certificate, but let's not require server authentication
         self.client_domain.set_credentials(self._testpath("client-certificate.pem"),
@@ -206,7 +206,7 @@ class SslTest(common.Test):
         self.server_domain.set_trusted_ca_db(self._testpath("ca-certificate.pem"))
         self.server_domain.set_peer_authentication( SSLDomain.VERIFY_PEER,
                                                     self._testpath("ca-certificate.pem") )
-        server = SslTest.SslTestConnection( self.server_domain )
+        server = SslTest.SslTestConnection( self.server_domain, mode=Transport.SERVER )
 
         self.client_domain.set_credentials(self._testpath("bad-server-certificate.pem"),
                                            self._testpath("bad-server-private-key.pem"),
@@ -234,7 +234,7 @@ class SslTest(common.Test):
         self.server_domain.set_trusted_ca_db(self._testpath("ca-certificate.pem"))
         self.server_domain.set_peer_authentication( SSLDomain.VERIFY_PEER,
                                                     self._testpath("ca-certificate.pem") )
-        server = SslTest.SslTestConnection( self.server_domain )
+        server = SslTest.SslTestConnection( self.server_domain, mode=Transport.SERVER )
 
         self.client_domain.set_peer_authentication( SSLDomain.ANONYMOUS_PEER )
         client = SslTest.SslTestConnection( self.client_domain )
@@ -263,7 +263,7 @@ class SslTest(common.Test):
         self.client_domain.set_trusted_ca_db(self._testpath("ca-certificate.pem"))
         self.client_domain.set_peer_authentication( SSLDomain.VERIFY_PEER )
 
-        server = SslTest.SslTestConnection( self.server_domain )
+        server = SslTest.SslTestConnection( self.server_domain, mode=Transport.SERVER )
         client = SslTest.SslTestConnection( self.client_domain )
 
         client.connection.open()
@@ -288,7 +288,7 @@ class SslTest(common.Test):
         self.client_domain.set_trusted_ca_db(self._testpath("ca-certificate.pem"))
         self.client_domain.set_peer_authentication( SSLDomain.VERIFY_PEER )
 
-        server = SslTest.SslTestConnection( self.server_domain )
+        server = SslTest.SslTestConnection( self.server_domain, mode=Transport.SERVER )
         client = SslTest.SslTestConnection( self.client_domain )
 
         client.connection.open()
@@ -311,7 +311,7 @@ class SslTest(common.Test):
         self.client_domain.set_trusted_ca_db(self._testpath("ca-certificate.pem"))
         self.client_domain.set_peer_authentication( SSLDomain.VERIFY_PEER )
 
-        server = SslTest.SslTestConnection( self.server_domain )
+        server = SslTest.SslTestConnection( self.server_domain, mode=Transport.SERVER )
         client = SslTest.SslTestConnection( self.client_domain )
 
         client.connection.open()
@@ -329,7 +329,7 @@ class SslTest(common.Test):
         self.client_domain.set_peer_authentication( SSLDomain.ANONYMOUS_PEER )
 
         client = SslTest.SslTestConnection( self.client_domain )
-        server = SslTest.SslTestConnection( self.server_domain )
+        server = SslTest.SslTestConnection( self.server_domain, mode=Transport.SERVER )
 
         client.connection.open()
         server.connection.open()
@@ -350,7 +350,7 @@ class SslTest(common.Test):
                                                     self._testpath("ca-certificate.pem") )
         # allow unsecured clients on this connection
         self.server_domain.allow_unsecured_client()
-        server = SslTest.SslTestConnection( self.server_domain )
+        server = SslTest.SslTestConnection( self.server_domain, mode=Transport.SERVER )
 
         # non-ssl connection
         client = SslTest.SslTestConnection()
@@ -385,7 +385,7 @@ class SslTest(common.Test):
 
         # client uses ssl. Server should detect this.
         client = SslTest.SslTestConnection( self.client_domain )
-        server = SslTest.SslTestConnection( self.server_domain )
+        server = SslTest.SslTestConnection( self.server_domain, mode=Transport.SERVER )
 
         client.connection.open()
         server.connection.open()
@@ -404,7 +404,7 @@ class SslTest(common.Test):
                                            "server-password")
         self.server_domain.set_trusted_ca_db(self._testpath("ca-certificate.pem"))
         self.server_domain.set_peer_authentication( SSLDomain.ANONYMOUS_PEER )
-        server = SslTest.SslTestConnection( self.server_domain )
+        server = SslTest.SslTestConnection( self.server_domain, mode=Transport.SERVER )
 
         # non-ssl connection
         client = SslTest.SslTestConnection()
@@ -431,8 +431,8 @@ class SslTest(common.Test):
         # details will be used in initial and subsequent connections to allow session to be resumed
         initial_session_details = SSLSessionDetails("my-session-id")
 
-        server = SslTest.SslTestConnection( self.server_domain )
-        client = SslTest.SslTestConnection( self.client_domain, initial_session_details )
+        server = SslTest.SslTestConnection( self.server_domain, mode=Transport.SERVER )
+        client = SslTest.SslTestConnection( self.client_domain, session_details=initial_session_details )
 
         # bring up the connection and store its state
         client.connection.open()
@@ -450,9 +450,9 @@ class SslTest(common.Test):
         del server
 
         # now create a new set of connections, use last session id
-        server = SslTest.SslTestConnection( self.server_domain )
+        server = SslTest.SslTestConnection( self.server_domain, mode=Transport.SERVER )
         # provide the details of the last session, allowing it to be resumed
-        client = SslTest.SslTestConnection( self.client_domain, initial_session_details )
+        client = SslTest.SslTestConnection( self.client_domain, session_details=initial_session_details )
 
         #client.transport.trace(Transport.TRACE_DRV)
         #server.transport.trace(Transport.TRACE_DRV)
@@ -477,8 +477,8 @@ class SslTest(common.Test):
         del client
         del server
 
-        server = SslTest.SslTestConnection( self.server_domain )
-        client = SslTest.SslTestConnection( self.client_domain, SSLSessionDetails("some-other-session-id") )
+        server = SslTest.SslTestConnection( self.server_domain, mode=Transport.SERVER )
+        client = SslTest.SslTestConnection( self.client_domain, session_details=SSLSessionDetails("some-other-session-id") )
 
         client.connection.open()
         server.connection.open()
@@ -509,7 +509,7 @@ class SslTest(common.Test):
         self.client_domain.set_peer_authentication( SSLDomain.VERIFY_PEER )
 
         max_count = 100
-        sessions = [(SslTest.SslTestConnection( self.server_domain ),
+        sessions = [(SslTest.SslTestConnection( self.server_domain, mode=Transport.SERVER ),
                      SslTest.SslTestConnection( self.client_domain )) for x in
                     range(max_count)]
         for s in sessions:
@@ -543,7 +543,7 @@ class SslTest(common.Test):
         self.client_domain.set_trusted_ca_db(self._testpath("ca-certificate.pem"))
         self.client_domain.set_peer_authentication( SSLDomain.VERIFY_PEER_NAME )
 
-        server = SslTest.SslTestConnection( self.server_domain )
+        server = SslTest.SslTestConnection( self.server_domain, mode=Transport.SERVER )
         client = SslTest.SslTestConnection( self.client_domain )
 
         client.ssl.peer_hostname = "a1.good.server.domain.com"
@@ -561,7 +561,7 @@ class SslTest(common.Test):
         self.client_domain.set_trusted_ca_db(self._testpath("ca-certificate.pem"))
         self.client_domain.set_peer_authentication( SSLDomain.VERIFY_PEER_NAME )
 
-        server = SslTest.SslTestConnection( self.server_domain )
+        server = SslTest.SslTestConnection( self.server_domain, mode=Transport.SERVER )
         client = SslTest.SslTestConnection( self.client_domain )
 
         client.ssl.peer_hostname = "A1.Good.Server.domain.comX"
@@ -589,7 +589,7 @@ class SslTest(common.Test):
         self.client_domain.set_trusted_ca_db(self._testpath("ca-certificate.pem"))
         self.client_domain.set_peer_authentication( SSLDomain.VERIFY_PEER_NAME )
 
-        server = SslTest.SslTestConnection( self.server_domain )
+        server = SslTest.SslTestConnection( self.server_domain, mode=Transport.SERVER )
         client = SslTest.SslTestConnection( self.client_domain )
 
         client.ssl.peer_hostname = "alternate.Name.one.com"
@@ -606,7 +606,7 @@ class SslTest(common.Test):
         self.client_domain.set_trusted_ca_db(self._testpath("ca-certificate.pem"))
         self.client_domain.set_peer_authentication( SSLDomain.VERIFY_PEER_NAME )
 
-        server = SslTest.SslTestConnection( self.server_domain )
+        server = SslTest.SslTestConnection( self.server_domain, mode=Transport.SERVER )
         client = SslTest.SslTestConnection( self.client_domain )
 
         client.ssl.peer_hostname = "ANOTHER.NAME.COM"
@@ -623,7 +623,7 @@ class SslTest(common.Test):
         self.client_domain.set_trusted_ca_db(self._testpath("ca-certificate.pem"))
         self.client_domain.set_peer_authentication( SSLDomain.VERIFY_PEER_NAME )
 
-        server = SslTest.SslTestConnection( self.server_domain )
+        server = SslTest.SslTestConnection( self.server_domain, mode=Transport.SERVER )
         client = SslTest.SslTestConnection( self.client_domain )
 
         client.ssl.peer_hostname = "SOME.PREfix.domain.COM"
@@ -640,7 +640,7 @@ class SslTest(common.Test):
         self.client_domain.set_trusted_ca_db(self._testpath("ca-certificate.pem"))
         self.client_domain.set_peer_authentication( SSLDomain.VERIFY_PEER_NAME )
 
-        server = SslTest.SslTestConnection( self.server_domain )
+        server = SslTest.SslTestConnection( self.server_domain, mode=Transport.SERVER )
         client = SslTest.SslTestConnection( self.client_domain )
 
         client.ssl.peer_hostname = "FOO.PREfixZZZ.domain.com"
@@ -657,7 +657,7 @@ class SslTest(common.Test):
         self.client_domain.set_trusted_ca_db(self._testpath("ca-certificate.pem"))
         self.client_domain.set_peer_authentication( SSLDomain.VERIFY_PEER_NAME )
 
-        server = SslTest.SslTestConnection( self.server_domain )
+        server = SslTest.SslTestConnection( self.server_domain, mode=Transport.SERVER )
         client = SslTest.SslTestConnection( self.client_domain )
 
         client.ssl.peer_hostname = "FOO.PREfi.domain.com"
@@ -678,7 +678,7 @@ class SslTest(common.Test):
         self.client_domain.set_trusted_ca_db(self._testpath("ca-certificate.pem"))
         self.client_domain.set_peer_authentication( SSLDomain.VERIFY_PEER_NAME )
 
-        server = SslTest.SslTestConnection( self.server_domain )
+        server = SslTest.SslTestConnection( self.server_domain, mode=Transport.SERVER )
         client = SslTest.SslTestConnection( self.client_domain )
 
         client.ssl.peer_hostname = "PREfix.domain.COM"


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


[49/50] [abbrv] qpid-proton git commit: PROTON-865: Blocking sender functionality and handler per connection

Posted by ac...@apache.org.
PROTON-865: Blocking sender functionality and handler per connection


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/d56c5d76
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/d56c5d76
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/d56c5d76

Branch: refs/heads/cjansen-cpp-client
Commit: d56c5d7664334af3126e1509bef5791593a08c35
Parents: e8acc1e
Author: Clifford Jansen <cl...@apache.org>
Authored: Wed May 20 07:54:03 2015 -0700
Committer: Alan Conway <ac...@redhat.com>
Committed: Tue Jun 2 14:46:15 2015 -0400

----------------------------------------------------------------------
 proton-c/bindings/cpp/CMakeLists.txt            |   7 +
 .../cpp/examples/HelloWorldBlocking.cpp         |  65 +++++++
 .../cpp/include/proton/cpp/BlockingConnection.h |  67 +++++++
 .../cpp/include/proton/cpp/BlockingLink.h       |  59 +++++++
 .../cpp/include/proton/cpp/BlockingSender.h     |  54 ++++++
 .../cpp/include/proton/cpp/Connection.h         |   2 +-
 .../bindings/cpp/include/proton/cpp/Container.h |  15 +-
 .../bindings/cpp/include/proton/cpp/Delivery.h  |   4 +-
 .../bindings/cpp/include/proton/cpp/Duration.h  |  56 ++++++
 proton-c/bindings/cpp/include/proton/cpp/Link.h |   1 +
 .../cpp/include/proton/cpp/MessagingAdapter.h   |   3 -
 .../cpp/include/proton/cpp/MessagingHandler.h   |   6 +
 .../bindings/cpp/include/proton/cpp/Sender.h    |   3 +-
 .../cpp/include/proton/cpp/WaitCondition.h      |  45 +++++
 proton-c/bindings/cpp/src/Connection.cpp        |   4 +-
 proton-c/bindings/cpp/src/ConnectionImpl.cpp    |  28 ++-
 proton-c/bindings/cpp/src/ConnectionImpl.h      |   3 +-
 proton-c/bindings/cpp/src/Container.cpp         |  25 ++-
 proton-c/bindings/cpp/src/ContainerImpl.cpp     | 175 +++++++++++--------
 proton-c/bindings/cpp/src/ContainerImpl.h       |  24 ++-
 proton-c/bindings/cpp/src/Duration.cpp          |  55 ++++++
 proton-c/bindings/cpp/src/Link.cpp              |   4 +
 proton-c/bindings/cpp/src/MessagingAdapter.cpp  |   6 +-
 proton-c/bindings/cpp/src/MessagingHandler.cpp  |  57 +++++-
 proton-c/bindings/cpp/src/Sender.cpp            |   3 +-
 .../cpp/src/blocking/BlockingConnection.cpp     |  62 +++++++
 .../cpp/src/blocking/BlockingConnectionImpl.cpp | 124 +++++++++++++
 .../cpp/src/blocking/BlockingConnectionImpl.h   |  63 +++++++
 .../bindings/cpp/src/blocking/BlockingLink.cpp  |  86 +++++++++
 .../cpp/src/blocking/BlockingSender.cpp         |  66 +++++++
 30 files changed, 1060 insertions(+), 112 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d56c5d76/proton-c/bindings/cpp/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/CMakeLists.txt b/proton-c/bindings/cpp/CMakeLists.txt
index 54d8ddd..34123ed 100644
--- a/proton-c/bindings/cpp/CMakeLists.txt
+++ b/proton-c/bindings/cpp/CMakeLists.txt
@@ -40,6 +40,7 @@ set (qpid-proton-cpp-core
     src/Terminus.cpp
     src/Acceptor.cpp
     src/Url.cpp
+    src/Duration.cpp
     src/Message.cpp
     src/MessagingAdapter.cpp
     src/MessagingEvent.cpp
@@ -55,6 +56,10 @@ set (qpid-proton-cpp-core
     src/Logger.cpp
     src/contexts.cpp
     src/exceptions.cpp
+    src/blocking/BlockingConnection.cpp
+    src/blocking/BlockingConnectionImpl.cpp
+    src/blocking/BlockingLink.cpp
+    src/blocking/BlockingSender.cpp
   )
 
 #set_source_files_properties (
@@ -102,6 +107,8 @@ add_executable (SimpleSend examples/SimpleSend.cpp)
 target_link_libraries (SimpleSend qpid-proton-cpp)
 add_executable (Broker examples/Broker.cpp)
 target_link_libraries (Broker qpid-proton-cpp)
+add_executable (HelloWorldBlocking examples/HelloWorldBlocking.cpp)
+target_link_libraries (HelloWorldBlocking qpid-proton-cpp)
 
 
 install (TARGETS qpid-proton-cpp

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d56c5d76/proton-c/bindings/cpp/examples/HelloWorldBlocking.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/examples/HelloWorldBlocking.cpp b/proton-c/bindings/cpp/examples/HelloWorldBlocking.cpp
new file mode 100644
index 0000000..a3f729c
--- /dev/null
+++ b/proton-c/bindings/cpp/examples/HelloWorldBlocking.cpp
@@ -0,0 +1,65 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "proton/cpp/Container.h"
+#include "proton/cpp/MessagingHandler.h"
+#include "proton/cpp/BlockingSender.h"
+
+#include <iostream>
+
+
+using namespace proton::reactor;
+
+class HelloWorldBlocking : public MessagingHandler {
+  private:
+    std::string server;
+    std::string address;
+  public:
+
+    HelloWorldBlocking(const std::string &s, const std::string &addr) : server(s), address(addr) {}
+
+    void onStart(Event &e) {
+        Connection conn = e.getContainer().connect(server);
+        e.getContainer().createReceiver(conn, address);
+    }
+
+    void onMessage(Event &e) {
+        std::string body = e.getMessage().getBody();
+        std::cout << body << std::endl;
+        e.getConnection().close();
+    }
+
+};
+
+int main(int argc, char **argv) {
+    std::string url("localhost:5672");
+    std::string addr("examples");
+    BlockingConnection conn = BlockingConnection(url);
+    BlockingSender sender = conn.createSender(addr);
+    Message m;
+    m.setBody("Hello World!");
+    sender.send(m);
+    conn.close();
+
+    // Temporary hack until blocking receiver available
+    HelloWorldBlocking hw("localhost:5672", "examples");
+    Container(hw).run();
+}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d56c5d76/proton-c/bindings/cpp/include/proton/cpp/BlockingConnection.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/BlockingConnection.h b/proton-c/bindings/cpp/include/proton/cpp/BlockingConnection.h
new file mode 100644
index 0000000..aa268db
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/BlockingConnection.h
@@ -0,0 +1,67 @@
+#ifndef PROTON_CPP_BLOCKINGCONNECTION_H
+#define PROTON_CPP_BLOCKINGCONNECTION_H
+
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/cpp/ImportExport.h"
+#include "proton/cpp/Handle.h"
+#include "proton/cpp/Endpoint.h"
+#include "proton/cpp/Container.h"
+#include "proton/cpp/Duration.h"
+#include "proton/cpp/MessagingHandler.h"
+#include "proton/types.h"
+#include <string>
+
+struct pn_connection_t;
+
+namespace proton {
+namespace reactor {
+
+class Container;
+class BlockingConnectionImpl;
+class SslDomain;
+class BlockingSender;
+class WaitCondition;
+
+class BlockingConnection : public Handle<BlockingConnectionImpl>
+{
+  public:
+    PROTON_CPP_EXTERN BlockingConnection();
+    PROTON_CPP_EXTERN BlockingConnection(const BlockingConnection& c);
+    PROTON_CPP_EXTERN BlockingConnection& operator=(const BlockingConnection& c);
+    PROTON_CPP_EXTERN ~BlockingConnection();
+
+    PROTON_CPP_EXTERN BlockingConnection(std::string &url, Duration = Duration::FOREVER,
+                                         SslDomain *ssld=0, Container *c=0);
+    PROTON_CPP_EXTERN void close();
+
+    PROTON_CPP_EXTERN BlockingSender createSender(std::string &address, Handler *h=0);
+    PROTON_CPP_EXTERN void wait(WaitCondition &condition);
+    PROTON_CPP_EXTERN void wait(WaitCondition &condition, std::string &msg, Duration timeout=Duration::FOREVER);
+    PROTON_CPP_EXTERN Duration getTimeout();
+  private:
+    friend class PrivateImplRef<BlockingConnection>;
+};
+
+
+}} // namespace proton::reactor
+
+#endif  /*!PROTON_CPP_BLOCKINGCONNECTION_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d56c5d76/proton-c/bindings/cpp/include/proton/cpp/BlockingLink.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/BlockingLink.h b/proton-c/bindings/cpp/include/proton/cpp/BlockingLink.h
new file mode 100644
index 0000000..7f84ce8
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/BlockingLink.h
@@ -0,0 +1,59 @@
+#ifndef PROTON_CPP_BLOCKINGLINK_H
+#define PROTON_CPP_BLOCKINGLINK_H
+
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/cpp/ImportExport.h"
+#include "proton/cpp/Handle.h"
+#include "proton/cpp/Endpoint.h"
+#include "proton/cpp/Container.h"
+#include "proton/cpp/Duration.h"
+#include "proton/cpp/MessagingHandler.h"
+#include "proton/cpp/BlockingConnection.h"
+#include "proton/types.h"
+#include <string>
+
+namespace proton {
+namespace reactor {
+
+class BlockingConnection;
+
+class BlockingLink
+{
+  public:
+    PROTON_CPP_EXTERN void close();
+    ~BlockingLink();
+  protected:
+    PROTON_CPP_EXTERN BlockingLink(BlockingConnection *c, pn_link_t *l);
+    PROTON_CPP_EXTERN void waitForClosed(Duration timeout=Duration::SECOND);
+  private:
+    BlockingConnection connection;
+    Link link;
+    void checkClosed();
+    friend class BlockingConnection;
+    friend class BlockingSender;
+    friend class BlockingReceiver;
+};
+
+
+}} // namespace proton::reactor
+
+#endif  /*!PROTON_CPP_BLOCKINGLINK_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d56c5d76/proton-c/bindings/cpp/include/proton/cpp/BlockingSender.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/BlockingSender.h b/proton-c/bindings/cpp/include/proton/cpp/BlockingSender.h
new file mode 100644
index 0000000..d4ddeae
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/BlockingSender.h
@@ -0,0 +1,54 @@
+#ifndef PROTON_CPP_BLOCKINGSENDER_H
+#define PROTON_CPP_BLOCKINGSENDER_H
+
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/cpp/ImportExport.h"
+#include "proton/cpp/Handle.h"
+#include "proton/cpp/Endpoint.h"
+#include "proton/cpp/Container.h"
+#include "proton/cpp/Duration.h"
+#include "proton/cpp/MessagingHandler.h"
+#include "proton/cpp/BlockingLink.h"
+#include "proton/types.h"
+#include "proton/delivery.h"
+#include <string>
+
+namespace proton {
+namespace reactor {
+
+class BlockingConnection;
+class BlockingLink;
+
+class BlockingSender : public BlockingLink
+{
+  public:
+    PROTON_CPP_EXTERN Delivery send(Message &msg);
+    PROTON_CPP_EXTERN Delivery send(Message &msg, Duration timeout);
+  private:
+    PROTON_CPP_EXTERN BlockingSender(BlockingConnection &c, Sender &l);
+    friend class BlockingConnection;
+};
+
+
+}} // namespace proton::reactor
+
+#endif  /*!PROTON_CPP_BLOCKINGSENDER_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d56c5d76/proton-c/bindings/cpp/include/proton/cpp/Connection.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Connection.h b/proton-c/bindings/cpp/include/proton/cpp/Connection.h
index 86abbe6..f3397ce 100644
--- a/proton-c/bindings/cpp/include/proton/cpp/Connection.h
+++ b/proton-c/bindings/cpp/include/proton/cpp/Connection.h
@@ -47,7 +47,7 @@ class Connection : public Endpoint, public Handle<ConnectionImpl>
     PROTON_CPP_EXTERN Connection& operator=(const Connection& c);
     PROTON_CPP_EXTERN ~Connection();
 
-    PROTON_CPP_EXTERN Connection(Container &c);
+    PROTON_CPP_EXTERN Connection(Container &c, Handler *h = 0);
     PROTON_CPP_EXTERN Transport &getTransport();
     PROTON_CPP_EXTERN Handler *getOverride();
     PROTON_CPP_EXTERN void setOverride(Handler *h);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d56c5d76/proton-c/bindings/cpp/include/proton/cpp/Container.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Container.h b/proton-c/bindings/cpp/include/proton/cpp/Container.h
index d596ab1..1d7284d 100644
--- a/proton-c/bindings/cpp/include/proton/cpp/Container.h
+++ b/proton-c/bindings/cpp/include/proton/cpp/Container.h
@@ -24,6 +24,7 @@
 #include "proton/cpp/ImportExport.h"
 #include "proton/cpp/Handle.h"
 #include "proton/cpp/Acceptor.h"
+#include "proton/cpp/Duration.h"
 #include <proton/reactor.h>
 #include <string>
 
@@ -39,6 +40,7 @@ class MessagingHandler;
 class Sender;
 class Receiver;
 class Link;
+ class Handler;
 
 class Container : public Handle<ContainerImpl>
 {
@@ -48,17 +50,24 @@ class Container : public Handle<ContainerImpl>
     PROTON_CPP_EXTERN Container& operator=(const Container& c);
     PROTON_CPP_EXTERN ~Container();
 
+    PROTON_CPP_EXTERN Container();
     PROTON_CPP_EXTERN Container(MessagingHandler &mhandler);
-    PROTON_CPP_EXTERN Connection connect(std::string &host);
+    PROTON_CPP_EXTERN Connection connect(std::string &host, Handler *h=0);
     PROTON_CPP_EXTERN void run();
+    PROTON_CPP_EXTERN void start();
+    PROTON_CPP_EXTERN bool process();
+    PROTON_CPP_EXTERN void stop();
+    PROTON_CPP_EXTERN void wakeup();
+    PROTON_CPP_EXTERN bool isQuiesced();
     PROTON_CPP_EXTERN pn_reactor_t *getReactor();
-    PROTON_CPP_EXTERN pn_handler_t *getGlobalHandler();
-    PROTON_CPP_EXTERN Sender createSender(Connection &connection, std::string &addr);
+    PROTON_CPP_EXTERN Sender createSender(Connection &connection, std::string &addr, Handler *h=0);
     PROTON_CPP_EXTERN Sender createSender(std::string &url);
     PROTON_CPP_EXTERN Receiver createReceiver(Connection &connection, std::string &addr);
     PROTON_CPP_EXTERN Receiver createReceiver(const std::string &url);
     PROTON_CPP_EXTERN Acceptor listen(const std::string &url);
     PROTON_CPP_EXTERN std::string getContainerId();
+    PROTON_CPP_EXTERN Duration getTimeout();
+    PROTON_CPP_EXTERN void setTimeout(Duration timeout);
   private:
    friend class PrivateImplRef<Container>;
 };

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d56c5d76/proton-c/bindings/cpp/include/proton/cpp/Delivery.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Delivery.h b/proton-c/bindings/cpp/include/proton/cpp/Delivery.h
index a1965f6..8171dd5 100644
--- a/proton-c/bindings/cpp/include/proton/cpp/Delivery.h
+++ b/proton-c/bindings/cpp/include/proton/cpp/Delivery.h
@@ -22,9 +22,11 @@
  *
  */
 #include "proton/cpp/ImportExport.h"
-#include "proton/cpp/Link.h"
+#include "proton/cpp/ProtonHandle.h"
 
 #include "ProtonImplRef.h"
+
+#include "proton/delivery.h"
 #include "proton/disposition.h"
 
 namespace proton {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d56c5d76/proton-c/bindings/cpp/include/proton/cpp/Duration.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Duration.h b/proton-c/bindings/cpp/include/proton/cpp/Duration.h
new file mode 100644
index 0000000..d5aca03
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/Duration.h
@@ -0,0 +1,56 @@
+#ifndef PROTON_CPP_DURATION_H
+#define PROTON_CPP_DURATION_H
+
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "proton/cpp/ImportExport.h"
+#include "proton/types.h"
+
+namespace proton {
+namespace reactor {
+
+/**   \ingroup C++
+ * A duration is a time in milliseconds.
+ */
+class Duration
+{
+  public:
+    PROTON_CPP_EXTERN explicit Duration(uint64_t milliseconds);
+    PROTON_CPP_EXTERN uint64_t getMilliseconds() const;
+    PROTON_CPP_EXTERN static const Duration FOREVER;
+    PROTON_CPP_EXTERN static const Duration IMMEDIATE;
+    PROTON_CPP_EXTERN static const Duration SECOND;
+    PROTON_CPP_EXTERN static const Duration MINUTE;
+  private:
+    uint64_t milliseconds;
+};
+
+PROTON_CPP_EXTERN Duration operator*(const Duration& duration,
+                                         uint64_t multiplier);
+PROTON_CPP_EXTERN Duration operator*(uint64_t multiplier,
+                                         const Duration& duration);
+PROTON_CPP_EXTERN bool operator==(const Duration& a, const Duration& b);
+PROTON_CPP_EXTERN bool operator!=(const Duration& a, const Duration& b);
+
+}} // namespace proton::reactor
+
+#endif  /*!PROTON_CPP_DURATION_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d56c5d76/proton-c/bindings/cpp/include/proton/cpp/Link.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Link.h b/proton-c/bindings/cpp/include/proton/cpp/Link.h
index 265d80d..391e5fc 100644
--- a/proton-c/bindings/cpp/include/proton/cpp/Link.h
+++ b/proton-c/bindings/cpp/include/proton/cpp/Link.h
@@ -50,6 +50,7 @@ class Link : public Endpoint, public ProtonHandle<pn_link_t>
     PROTON_CPP_EXTERN Terminus getTarget();
     PROTON_CPP_EXTERN Terminus getRemoteSource();
     PROTON_CPP_EXTERN Terminus getRemoteTarget();
+    PROTON_CPP_EXTERN std::string getName();
     PROTON_CPP_EXTERN pn_link_t *getPnLink() const;
     virtual PROTON_CPP_EXTERN Connection &getConnection();
     PROTON_CPP_EXTERN Link getNext(Endpoint::State mask);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d56c5d76/proton-c/bindings/cpp/include/proton/cpp/MessagingAdapter.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/MessagingAdapter.h b/proton-c/bindings/cpp/include/proton/cpp/MessagingAdapter.h
index 36a92e4..280df5b 100644
--- a/proton-c/bindings/cpp/include/proton/cpp/MessagingAdapter.h
+++ b/proton-c/bindings/cpp/include/proton/cpp/MessagingAdapter.h
@@ -71,9 +71,6 @@ class MessagingAdapter : public MessagingHandler
     PROTON_CPP_EXTERN virtual void onTransportTailClosed(Event &e);
   private:
     MessagingHandler &delegate;  // The handler for generated MessagingEvent's
-    bool autoSettle;
-    bool autoAccept;
-    bool peerCloseIsError;
 };
 
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d56c5d76/proton-c/bindings/cpp/include/proton/cpp/MessagingHandler.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/MessagingHandler.h b/proton-c/bindings/cpp/include/proton/cpp/MessagingHandler.h
index 4f00681..c6d8f72 100644
--- a/proton-c/bindings/cpp/include/proton/cpp/MessagingHandler.h
+++ b/proton-c/bindings/cpp/include/proton/cpp/MessagingHandler.h
@@ -30,6 +30,7 @@ namespace proton {
 namespace reactor {
 
 class Event;
+class MessagingAdapter;
 
 class PROTON_CPP_EXTERN MessagingHandler : public ProtonHandler , public Acking
 {
@@ -80,9 +81,14 @@ class PROTON_CPP_EXTERN MessagingHandler : public ProtonHandler , public Acking
     bool autoSettle;
     bool autoAccept;
     bool peerCloseIsError;
+    MessagingAdapter *messagingAdapter;
+    Handler *flowController;
+    PROTON_CPP_EXTERN MessagingHandler(bool rawHandler, int prefetch=10, bool autoAccept=true, bool autoSettle=true,
+                                       bool peerCloseIsError=false);
   private:
     friend class ContainerImpl;
     friend class MessagingAdapter;
+    void createHelpers();
 };
 
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d56c5d76/proton-c/bindings/cpp/include/proton/cpp/Sender.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Sender.h b/proton-c/bindings/cpp/include/proton/cpp/Sender.h
index 9b8683d..c63161c 100644
--- a/proton-c/bindings/cpp/include/proton/cpp/Sender.h
+++ b/proton-c/bindings/cpp/include/proton/cpp/Sender.h
@@ -22,6 +22,7 @@
  *
  */
 #include "proton/cpp/ImportExport.h"
+#include "proton/cpp/Delivery.h"
 #include "proton/cpp/Link.h"
 #include "proton/cpp/Message.h"
 
@@ -40,7 +41,7 @@ class Sender : public Link
     PROTON_CPP_EXTERN Sender(pn_link_t *lnk);
     PROTON_CPP_EXTERN Sender();
     PROTON_CPP_EXTERN Sender(const Link& c);
-    PROTON_CPP_EXTERN void send(Message &m);
+    PROTON_CPP_EXTERN Delivery send(Message &m);
   protected:
     virtual void verifyType(pn_link_t *l);
 };

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d56c5d76/proton-c/bindings/cpp/include/proton/cpp/WaitCondition.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/WaitCondition.h b/proton-c/bindings/cpp/include/proton/cpp/WaitCondition.h
new file mode 100644
index 0000000..f4c7cb5
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/WaitCondition.h
@@ -0,0 +1,45 @@
+#ifndef PROTON_CPP_WAITCONDITION_H
+#define PROTON_CPP_WAITCONDITION_H
+
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/cpp/ImportExport.h"
+
+namespace proton {
+namespace reactor {
+
+// Interface class to indicates that an expected contion has been
+// achieved, i.e. for BlockingConnection.wait()
+
+class WaitCondition
+{
+  public:
+    PROTON_CPP_EXTERN virtual ~WaitCondition();
+
+    // Overide this member function to indicate whether an expected
+    // condition is achieved and requires no further waiting.
+    virtual bool achieved() = 0;
+};
+
+
+}} // namespace proton::reactor
+
+#endif  /*!PROTON_CPP_WAITCONDITION_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d56c5d76/proton-c/bindings/cpp/src/Connection.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Connection.cpp b/proton-c/bindings/cpp/src/Connection.cpp
index 1db8fbc..67e7d0c 100644
--- a/proton-c/bindings/cpp/src/Connection.cpp
+++ b/proton-c/bindings/cpp/src/Connection.cpp
@@ -42,8 +42,8 @@ Connection::Connection(const Connection& c) : Handle<ConnectionImpl>() { PI::cop
 Connection& Connection::operator=(const Connection& c) { return PI::assign(*this, c); }
 Connection::~Connection() { PI::dtor(*this); }
 
-Connection::Connection(Container &c) {
-    ConnectionImpl *cimpl = new ConnectionImpl(c);
+Connection::Connection(Container &c, Handler *h) {
+    ConnectionImpl *cimpl = new ConnectionImpl(c, h);
     PI::ctor(*this, cimpl);
 }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d56c5d76/proton-c/bindings/cpp/src/ConnectionImpl.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/ConnectionImpl.cpp b/proton-c/bindings/cpp/src/ConnectionImpl.cpp
index 9cadffe..f7cc5f9 100644
--- a/proton-c/bindings/cpp/src/ConnectionImpl.cpp
+++ b/proton-c/bindings/cpp/src/ConnectionImpl.cpp
@@ -25,6 +25,8 @@
 #include "proton/cpp/Transport.h"
 #include "Msg.h"
 #include "contexts.h"
+#include "PrivateImplRef.h"
+#include "ContainerImpl.h"
 
 #include "proton/connection.h"
 
@@ -41,12 +43,25 @@ void ConnectionImpl::decref(ConnectionImpl *impl) {
         delete impl;
 }
 
-ConnectionImpl::ConnectionImpl(Container &c, pn_connection_t *pnConn) : container(c), refCount(0), override(0), transport(0), defaultSession(0),
-                                               pnConnection(pnConn),
-                                               reactorReference(this)
+ConnectionImpl::ConnectionImpl(Container &c, pn_connection_t &pnConn)
+    : container(c), refCount(0), override(0), transport(0), defaultSession(0),
+      pnConnection(&pnConn), reactorReference(this)
 {
-    if (!pnConnection)
-        pnConnection = pn_reactor_connection(container.getReactor(), NULL);
+    setConnectionContext(pnConnection, this);
+}
+
+ConnectionImpl::ConnectionImpl(Container &c, Handler *handler)
+    : container(c), refCount(0), override(0), transport(0), defaultSession(0),
+      reactorReference(this)
+{
+    pn_handler_t *chandler = 0;
+    if (handler) {
+        ContainerImpl *containerImpl = PrivateImplRef<Container>::get(c);
+        chandler = containerImpl->wrapHandler(handler);
+    }
+    pnConnection = pn_reactor_connection(container.getReactor(), chandler);
+    if (chandler)
+        pn_decref(chandler);
     setConnectionContext(pnConnection, this);
 }
 
@@ -112,7 +127,7 @@ Connection &ConnectionImpl::getReactorReference(pn_connection_t *conn) {
         Container container(getContainerContext(reactor));
         if (!container)  // can't be one created by our container
             throw ProtonException(MSG("Unknown Proton connection specifier"));
-        impl = new ConnectionImpl(container, conn);
+        impl = new ConnectionImpl(container, *conn);
     }
     return impl->reactorReference;
 }
@@ -121,5 +136,4 @@ Link ConnectionImpl::getLinkHead(Endpoint::State mask) {
     return Link(pn_link_head(pnConnection, mask));
 }
 
-
 }} // namespace proton::reactor

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d56c5d76/proton-c/bindings/cpp/src/ConnectionImpl.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/ConnectionImpl.h b/proton-c/bindings/cpp/src/ConnectionImpl.h
index 11b5765..48210a3 100644
--- a/proton-c/bindings/cpp/src/ConnectionImpl.h
+++ b/proton-c/bindings/cpp/src/ConnectionImpl.h
@@ -39,7 +39,8 @@ class Container;
 class ConnectionImpl : public Endpoint
 {
   public:
-    PROTON_CPP_EXTERN ConnectionImpl(Container &c, pn_connection_t *pnConn = 0);
+    PROTON_CPP_EXTERN ConnectionImpl(Container &c, pn_connection_t &pnConn);
+    PROTON_CPP_EXTERN ConnectionImpl(Container &c, Handler *h = 0);
     PROTON_CPP_EXTERN ~ConnectionImpl();
     PROTON_CPP_EXTERN Transport &getTransport();
     PROTON_CPP_EXTERN Handler *getOverride();

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d56c5d76/proton-c/bindings/cpp/src/Container.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Container.cpp b/proton-c/bindings/cpp/src/Container.cpp
index 4eccb15..e72f484 100644
--- a/proton-c/bindings/cpp/src/Container.cpp
+++ b/proton-c/bindings/cpp/src/Container.cpp
@@ -53,17 +53,23 @@ Container::Container(MessagingHandler &mhandler) {
     PI::ctor(*this, cimpl);
 }
 
-Connection Container::connect(std::string &host) { return impl->connect(host); }
+Container::Container() {
+    ContainerImpl *cimpl = new ContainerImpl();
+    PI::ctor(*this, cimpl);
+}
 
-pn_reactor_t *Container::getReactor() { return impl->getReactor(); }
+Connection Container::connect(std::string &host, Handler *h) { return impl->connect(host, h); }
 
-pn_handler_t *Container::getGlobalHandler() { return impl->getGlobalHandler(); }
+pn_reactor_t *Container::getReactor() { return impl->getReactor(); }
 
 std::string Container::getContainerId() { return impl->getContainerId(); }
 
+Duration Container::getTimeout() { return impl->getTimeout(); }
+void Container::setTimeout(Duration timeout) { impl->setTimeout(timeout); }
+
 
-Sender Container::createSender(Connection &connection, std::string &addr) {
-    return impl->createSender(connection, addr);
+Sender Container::createSender(Connection &connection, std::string &addr, Handler *h) {
+    return impl->createSender(connection, addr, h);
 }
 
 Sender Container::createSender(std::string &urlString) {
@@ -83,8 +89,11 @@ Acceptor Container::listen(const std::string &urlString) {
 }
 
 
-void Container::run() {
-    impl->run();
-}
+void Container::run() { impl->run(); }
+void Container::start() { impl->start(); }
+bool Container::process() { return impl->process(); }
+void Container::stop() { impl->stop(); }
+void Container::wakeup() { impl->wakeup(); }
+bool Container::isQuiesced() { return impl->isQuiesced(); }
 
 }} // namespace proton::reactor

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d56c5d76/proton-c/bindings/cpp/src/ContainerImpl.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/ContainerImpl.cpp b/proton-c/bindings/cpp/src/ContainerImpl.cpp
index 1cabf6c..1424dbb 100644
--- a/proton-c/bindings/cpp/src/ContainerImpl.cpp
+++ b/proton-c/bindings/cpp/src/ContainerImpl.cpp
@@ -116,41 +116,19 @@ class OverrideHandler : public Handler
         pn_handler_dispatch(baseHandler, cevent, (pn_event_type_t) type);
 
         if (conn && type == PN_CONNECTION_FINAL) {
-            //  TODO:  this must be the last acation of the last handler looking at
+            //  TODO:  this must be the last action of the last handler looking at
             //  connection events. Better: generate a custom FINAL event (or task).  Or move to
             //  separate event streams per connection as part of multi threading support.
             ConnectionImpl *cimpl = getConnectionContext(conn);
             if (cimpl)
                 cimpl->reactorDetach();
-            // TODO: remember all connections and do reactorDetach of zombies connections
-            // not pn_connection_release'd at PN_REACTOR_FINAL.
+            // TODO: remember all connections and do reactorDetach of zombie connections
+            // not yet pn_connection_release'd at PN_REACTOR_FINAL.
         }
     }
 };
 
 
-class CFlowController : public ProtonHandler
-{
-  public:
-    pn_handler_t *flowcontroller;
-
-    CFlowController(int window) : flowcontroller(pn_flowcontroller(window)) {}
-    ~CFlowController() {
-        pn_decref(flowcontroller);
-    }
-
-    void redirect(Event &e) {
-        ProtonEvent *pne = dynamic_cast<ProtonEvent *>(&e);
-        pn_handler_dispatch(flowcontroller, pne->getPnEvent(), (pn_event_type_t) pne->getType());
-    }
-
-    virtual void onLinkLocalOpen(Event &e) { redirect(e); }
-    virtual void onLinkRemoteOpen(Event &e) { redirect(e); }
-    virtual void onLinkFlow(Event &e) { redirect(e); }
-    virtual void onDelivery(Event &e) { redirect(e); }
-};
-
-
 namespace {
 
 // TODO: configurable policy.  SessionPerConnection for now.
@@ -165,7 +143,6 @@ Session getDefaultSession(pn_connection_t *conn, pn_session_t **ses) {
 
 struct InboundContext {
     ContainerImpl *containerImpl;
-    Container containerRef;  // create only once for all inbound events
     Handler *cppHandler;
 };
 
@@ -174,11 +151,6 @@ ContainerImpl *getContainerImpl(pn_handler_t *c_handler) {
     return ctxt->containerImpl;
 }
 
-Container &getContainerRef(pn_handler_t *c_handler) {
-    struct InboundContext *ctxt = (struct InboundContext *) pn_handler_mem(c_handler);
-    return ctxt->containerRef;
-}
-
 Handler &getCppHandler(pn_handler_t *c_handler) {
     struct InboundContext *ctxt = (struct InboundContext *) pn_handler_mem(c_handler);
     return *ctxt->cppHandler;
@@ -186,21 +158,19 @@ Handler &getCppHandler(pn_handler_t *c_handler) {
 
 void cpp_handler_dispatch(pn_handler_t *c_handler, pn_event_t *cevent, pn_event_type_t type)
 {
-    MessagingEvent mevent(cevent, type, getContainerRef(c_handler));
+    Container c(getContainerImpl(c_handler)); // Ref counted per event, but when is the last event if stop() never called?
+    MessagingEvent mevent(cevent, type, c);
     mevent.dispatch(getCppHandler(c_handler));
 }
 
 void cpp_handler_cleanup(pn_handler_t *c_handler)
 {
-    struct InboundContext *ctxt = (struct InboundContext *) pn_handler_mem(c_handler);
-    ctxt->containerRef.~Container();
 }
 
 pn_handler_t *cpp_handler(ContainerImpl *c, Handler *h)
 {
     pn_handler_t *handler = pn_handler_new(cpp_handler_dispatch, sizeof(struct InboundContext), cpp_handler_cleanup);
     struct InboundContext *ctxt = (struct InboundContext *) pn_handler_mem(handler);
-    new (&ctxt->containerRef) Container(c);
     ctxt->containerImpl = c;
     ctxt->cppHandler = h;
     return handler;
@@ -220,18 +190,29 @@ void ContainerImpl::decref(ContainerImpl *impl) {
         delete impl;
 }
 
-ContainerImpl::ContainerImpl(MessagingHandler &mhandler) :
-    reactor(0), globalHandler(0), messagingHandler(mhandler), containerId(generateUuid()),
+ContainerImpl::ContainerImpl(Handler &h) :
+    reactor(0), handler(&h), messagingAdapter(0),
+    overrideHandler(0), flowController(0), containerId(generateUuid()),
     refCount(0)
-{
-}
+{}
+
+ContainerImpl::ContainerImpl() :
+    reactor(0), handler(0), messagingAdapter(0),
+    overrideHandler(0), flowController(0), containerId(generateUuid()),
+    refCount(0)
+{}
 
-ContainerImpl::~ContainerImpl() {}
+ContainerImpl::~ContainerImpl() {
+    delete overrideHandler;
+    delete flowController;
+    delete messagingAdapter;
+    pn_reactor_free(reactor);
+}
 
-Connection ContainerImpl::connect(std::string &host) {
-    if (!reactor) throw ProtonException(MSG("Container not initialized"));
+Connection ContainerImpl::connect(std::string &host, Handler *h) {
+    if (!reactor) throw ProtonException(MSG("Container not started"));
     Container cntnr(this);
-    Connection connection(cntnr);
+    Connection connection(cntnr, handler);
     Connector *connector = new Connector(connection);
     // Connector self-deletes depending on reconnect logic
     connector->setAddress(host);  // TODO: url vector
@@ -242,15 +223,36 @@ Connection ContainerImpl::connect(std::string &host) {
 
 pn_reactor_t *ContainerImpl::getReactor() { return reactor; }
 
-pn_handler_t *ContainerImpl::getGlobalHandler() { return globalHandler; }
 
 std::string ContainerImpl::getContainerId() { return containerId; }
 
+Duration ContainerImpl::getTimeout() {
+    pn_millis_t tmo = pn_reactor_get_timeout(reactor);
+    if (tmo == PN_MILLIS_MAX)
+        return Duration::FOREVER;
+    return Duration(tmo);
+}
 
-Sender ContainerImpl::createSender(Connection &connection, std::string &addr) {
+void ContainerImpl::setTimeout(Duration timeout) {
+    if (timeout == Duration::FOREVER || timeout.getMilliseconds() > PN_MILLIS_MAX)
+        pn_reactor_set_timeout(reactor, PN_MILLIS_MAX);
+    else {
+        pn_millis_t tmo = timeout.getMilliseconds();
+        pn_reactor_set_timeout(reactor, tmo);
+    }
+}
+
+
+Sender ContainerImpl::createSender(Connection &connection, std::string &addr, Handler *h) {
+    if (!reactor) throw ProtonException(MSG("Container not started"));
     Session session = getDefaultSession(connection.getPnConnection(), &getImpl(connection)->defaultSession);
     Sender snd = session.createSender(containerId  + '-' + addr);
-    pn_terminus_set_address(pn_link_target(snd.getPnLink()), addr.c_str());
+    pn_link_t *lnk = snd.getPnLink();
+    pn_terminus_set_address(pn_link_target(lnk), addr.c_str());
+    if (h) {
+        pn_record_t *record = pn_link_attachments(lnk);
+        pn_record_set_handler(record, wrapHandler(h));
+    }
     snd.open();
 
     ConnectionImpl *connImpl = getImpl(connection);
@@ -258,7 +260,8 @@ Sender ContainerImpl::createSender(Connection &connection, std::string &addr) {
 }
 
 Sender ContainerImpl::createSender(std::string &urlString) {
-    Connection conn = connect(urlString);
+    if (!reactor) throw ProtonException(MSG("Container not started"));
+    Connection conn = connect(urlString, 0);
     Session session = getDefaultSession(conn.getPnConnection(), &getImpl(conn)->defaultSession);
     std::string path = Url(urlString).getPath();
     Sender snd = session.createSender(containerId + '-' + path);
@@ -270,6 +273,7 @@ Sender ContainerImpl::createSender(std::string &urlString) {
 }
 
 Receiver ContainerImpl::createReceiver(Connection &connection, std::string &addr) {
+    if (!reactor) throw ProtonException(MSG("Container not started"));
     ConnectionImpl *connImpl = getImpl(connection);
     Session session = getDefaultSession(connImpl->pnConnection, &connImpl->defaultSession);
     Receiver rcv = session.createReceiver(containerId + '-' + addr);
@@ -279,8 +283,9 @@ Receiver ContainerImpl::createReceiver(Connection &connection, std::string &addr
 }
 
 Receiver ContainerImpl::createReceiver(const std::string &urlString) {
+    if (!reactor) throw ProtonException(MSG("Container not started"));
     // TODO: const cleanup of API
-    Connection conn = connect(const_cast<std::string &>(urlString));
+    Connection conn = connect(const_cast<std::string &>(urlString), 0);
     Session session = getDefaultSession(conn.getPnConnection(), &getImpl(conn)->defaultSession);
     std::string path = Url(urlString).getPath();
     Receiver rcv = session.createReceiver(containerId + '-' + path);
@@ -298,50 +303,76 @@ Acceptor ContainerImpl::acceptor(const std::string &host, const std::string &por
 }
 
 Acceptor ContainerImpl::listen(const std::string &urlString) {
+    if (!reactor) throw ProtonException(MSG("Container not started"));
     Url url(urlString);
     // TODO: SSL
     return acceptor(url.getHost(), url.getPort());
 }
 
 
-void ContainerImpl::run() {
+pn_handler_t *ContainerImpl::wrapHandler(Handler *h) {
+    return cpp_handler(this, h);
+}
+
+
+void ContainerImpl::initializeReactor() {
+    if (reactor) throw ProtonException(MSG("Container already running"));
     reactor = pn_reactor();
 
     // Set our context on the reactor
     setContainerContext(reactor, this);
 
-    int prefetch = messagingHandler.prefetch;
-    Handler *flowController = 0;
-
-    // Set the reactor's main/default handler (see note below)
-    if (prefetch) {
-        flowController = new CFlowController(prefetch);
-        messagingHandler.addChildHandler(*flowController);
+    if (handler) {
+        pn_handler_t *cppHandler = cpp_handler(this, handler);
+        pn_reactor_set_handler(reactor, cppHandler);
+        pn_decref(cppHandler);
     }
-    MessagingAdapter messagingAdapter(messagingHandler);
-    messagingHandler.addChildHandler(messagingAdapter);
-    pn_handler_t *cppHandler = cpp_handler(this, &messagingHandler);
-    pn_reactor_set_handler(reactor, cppHandler);
 
     // Set our own global handler that "subclasses" the existing one
-    pn_handler_t *cGlobalHandler = pn_reactor_get_global_handler(reactor);
-    pn_incref(cGlobalHandler);
-    OverrideHandler overrideHandler(cGlobalHandler);
-    pn_handler_t *cppGlobalHandler = cpp_handler(this, &overrideHandler);
+    pn_handler_t *globalHandler = pn_reactor_get_global_handler(reactor);
+    overrideHandler = new OverrideHandler(globalHandler);
+    pn_handler_t *cppGlobalHandler = cpp_handler(this, overrideHandler);
     pn_reactor_set_global_handler(reactor, cppGlobalHandler);
+    pn_decref(cppGlobalHandler);
 
     // Note: we have just set up the following 4/5 handlers that see events in this order:
     // messagingHandler (Proton C events), pn_flowcontroller (optional), messagingAdapter,
-    // messagingHandler (Messaging events from the messagingAdapter), connector override,
-    // the reactor's default globalhandler (pn_iohandler)
+    // messagingHandler (Messaging events from the messagingAdapter, i.e. the delegate),
+    // connector override, the reactor's default globalhandler (pn_iohandler)
+}
+
+void ContainerImpl::run() {
+    initializeReactor();
     pn_reactor_run(reactor);
+}
 
-    pn_decref(cppHandler);
-    pn_decref(cppGlobalHandler);
-    pn_decref(cGlobalHandler);
-    pn_reactor_free(reactor);
-    reactor = 0;
-    delete(flowController);
+void ContainerImpl::start() {
+    initializeReactor();
+    pn_reactor_start(reactor);
+}
+
+bool ContainerImpl::process() {
+    if (!reactor) throw ProtonException(MSG("Container not started"));
+    bool result = pn_reactor_process(reactor);
+    // TODO: check errors
+    return result;
+}
+
+void ContainerImpl::stop() {
+    if (!reactor) throw ProtonException(MSG("Container not started"));
+    pn_reactor_stop(reactor);
+    // TODO: check errors
+}
+
+void ContainerImpl::wakeup() {
+    if (!reactor) throw ProtonException(MSG("Container not started"));
+    pn_reactor_wakeup(reactor);
+    // TODO: check errors
+}
+
+bool ContainerImpl::isQuiesced() {
+    if (!reactor) throw ProtonException(MSG("Container not started"));
+    return pn_reactor_quiesced(reactor);
 }
 
 }} // namespace proton::reactor

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d56c5d76/proton-c/bindings/cpp/src/ContainerImpl.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/ContainerImpl.h b/proton-c/bindings/cpp/src/ContainerImpl.h
index f7b5b9e..65a6651 100644
--- a/proton-c/bindings/cpp/src/ContainerImpl.h
+++ b/proton-c/bindings/cpp/src/ContainerImpl.h
@@ -25,6 +25,7 @@
 #include "proton/cpp/MessagingHandler.h"
 #include "proton/cpp/Connection.h"
 #include "proton/cpp/Link.h"
+#include "proton/cpp/Duration.h"
 
 #include "proton/reactor.h"
 
@@ -40,26 +41,37 @@ class Acceptor;
 class ContainerImpl
 {
   public:
-    PROTON_CPP_EXTERN ContainerImpl(MessagingHandler &mhandler);
+    PROTON_CPP_EXTERN ContainerImpl(Handler &h);
+    PROTON_CPP_EXTERN ContainerImpl();
     PROTON_CPP_EXTERN ~ContainerImpl();
-    PROTON_CPP_EXTERN Connection connect(std::string &host);
+    PROTON_CPP_EXTERN Connection connect(std::string &host, Handler *h);
     PROTON_CPP_EXTERN void run();
     PROTON_CPP_EXTERN pn_reactor_t *getReactor();
-    PROTON_CPP_EXTERN pn_handler_t *getGlobalHandler();
-    PROTON_CPP_EXTERN Sender createSender(Connection &connection, std::string &addr);
+    PROTON_CPP_EXTERN Sender createSender(Connection &connection, std::string &addr, Handler *h);
     PROTON_CPP_EXTERN Sender createSender(std::string &url);
     PROTON_CPP_EXTERN Receiver createReceiver(Connection &connection, std::string &addr);
     PROTON_CPP_EXTERN Receiver createReceiver(const std::string &url);
     PROTON_CPP_EXTERN Acceptor listen(const std::string &url);
     PROTON_CPP_EXTERN std::string getContainerId();
+    PROTON_CPP_EXTERN Duration getTimeout();
+    PROTON_CPP_EXTERN void setTimeout(Duration timeout);
+    void start();
+    bool process();
+    void stop();
+    void wakeup();
+    bool isQuiesced();
+    pn_handler_t *wrapHandler(Handler *h);
     static void incref(ContainerImpl *);
     static void decref(ContainerImpl *);
   private:
     void dispatch(pn_event_t *event, pn_event_type_t type);
     Acceptor acceptor(const std::string &host, const std::string &port);
+    void initializeReactor();
     pn_reactor_t *reactor;
-    pn_handler_t *globalHandler;
-    MessagingHandler &messagingHandler;
+    Handler *handler;
+    MessagingAdapter *messagingAdapter;
+    Handler *overrideHandler;
+    Handler *flowController;
     std::string containerId;
     int refCount;
 };

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d56c5d76/proton-c/bindings/cpp/src/Duration.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Duration.cpp b/proton-c/bindings/cpp/src/Duration.cpp
new file mode 100644
index 0000000..f4155d9
--- /dev/null
+++ b/proton-c/bindings/cpp/src/Duration.cpp
@@ -0,0 +1,55 @@
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/cpp/Duration.h"
+#include <limits>
+
+namespace proton {
+namespace reactor {
+
+Duration::Duration(uint64_t ms) : milliseconds(ms) {}
+uint64_t Duration::getMilliseconds() const { return milliseconds; }
+
+Duration operator*(const Duration& duration, uint64_t multiplier)
+{
+    return Duration(duration.getMilliseconds() * multiplier);
+}
+
+Duration operator*(uint64_t multiplier, const Duration& duration)
+{
+    return Duration(duration.getMilliseconds() * multiplier);
+}
+
+bool operator==(const Duration& a, const Duration& b)
+{
+    return a.getMilliseconds() == b.getMilliseconds();
+}
+
+bool operator!=(const Duration& a, const Duration& b)
+{
+    return a.getMilliseconds() != b.getMilliseconds();
+}
+
+const Duration Duration::FOREVER(std::numeric_limits<uint64_t>::max());
+const Duration Duration::IMMEDIATE(0);
+const Duration Duration::SECOND(1000);
+const Duration Duration::MINUTE(SECOND * 60);
+
+}} // namespace proton::reactor

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d56c5d76/proton-c/bindings/cpp/src/Link.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Link.cpp b/proton-c/bindings/cpp/src/Link.cpp
index aab01d9..59cf039 100644
--- a/proton-c/bindings/cpp/src/Link.cpp
+++ b/proton-c/bindings/cpp/src/Link.cpp
@@ -96,6 +96,10 @@ Terminus Link::getRemoteTarget() {
     return Terminus(pn_link_remote_target(impl), this);
 }
 
+std::string Link::getName() {
+    return std::string(pn_link_name(impl));
+}
+
 Connection &Link::getConnection() {
     pn_session_t *s = pn_link_session(impl);
     pn_connection_t *c = pn_session_connection(s);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d56c5d76/proton-c/bindings/cpp/src/MessagingAdapter.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/MessagingAdapter.cpp b/proton-c/bindings/cpp/src/MessagingAdapter.cpp
index f2916db..625485e 100644
--- a/proton-c/bindings/cpp/src/MessagingAdapter.cpp
+++ b/proton-c/bindings/cpp/src/MessagingAdapter.cpp
@@ -32,14 +32,12 @@
 
 namespace proton {
 namespace reactor {
-
 MessagingAdapter::MessagingAdapter(MessagingHandler &delegate_) :
-    autoSettle(delegate_.autoSettle),
-    autoAccept(delegate_.autoAccept),
-    peerCloseIsError(delegate_.peerCloseIsError),
+    MessagingHandler(true, delegate_.prefetch, delegate_.autoSettle, delegate_.autoAccept, delegate_.peerCloseIsError),
     delegate(delegate_)
 {};
 
+
 MessagingAdapter::~MessagingAdapter(){};
 
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d56c5d76/proton-c/bindings/cpp/src/MessagingHandler.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/MessagingHandler.cpp b/proton-c/bindings/cpp/src/MessagingHandler.cpp
index 7a4a5cb..925186a 100644
--- a/proton-c/bindings/cpp/src/MessagingHandler.cpp
+++ b/proton-c/bindings/cpp/src/MessagingHandler.cpp
@@ -26,11 +26,64 @@
 namespace proton {
 namespace reactor {
 
+namespace {
+class CFlowController : public ProtonHandler
+{
+  public:
+    pn_handler_t *flowcontroller;
+
+    CFlowController(int window) : flowcontroller(pn_flowcontroller(window)) {}
+    ~CFlowController() {
+        pn_decref(flowcontroller);
+    }
+
+    void redirect(Event &e) {
+        ProtonEvent *pne = dynamic_cast<ProtonEvent *>(&e);
+        pn_handler_dispatch(flowcontroller, pne->getPnEvent(), (pn_event_type_t) pne->getType());
+    }
+
+    virtual void onLinkLocalOpen(Event &e) { redirect(e); }
+    virtual void onLinkRemoteOpen(Event &e) { redirect(e); }
+    virtual void onLinkFlow(Event &e) { redirect(e); }
+    virtual void onDelivery(Event &e) { redirect(e); }
+};
+
+} // namespace
+
+
+
+
 MessagingHandler::MessagingHandler(int prefetch0, bool autoAccept0, bool autoSettle0, bool peerCloseIsError0) :
     prefetch(prefetch0), autoAccept(autoAccept0), autoSettle(autoSettle0), peerCloseIsError(peerCloseIsError0)
-{}
+{
+    createHelpers();
+}
+
+MessagingHandler::MessagingHandler(bool rawHandler, int prefetch0, bool autoAccept0, bool autoSettle0,
+                                   bool peerCloseIsError0) :
+    prefetch(prefetch0), autoAccept(autoAccept0), autoSettle(autoSettle0), peerCloseIsError(peerCloseIsError0)
+{
+    if (rawHandler) {
+        flowController = 0;
+        messagingAdapter = 0;
+    } else {
+        createHelpers();
+    }
+}
+
+void MessagingHandler::createHelpers() {
+    if (prefetch > 0) {
+        flowController = new CFlowController(prefetch);
+        addChildHandler(*flowController);
+    }
+    messagingAdapter = new MessagingAdapter(*this);
+    addChildHandler(*messagingAdapter);
+}
 
-MessagingHandler::~MessagingHandler(){};
+MessagingHandler::~MessagingHandler(){
+    delete flowController;
+    delete messagingAdapter;
+};
 
 void MessagingHandler::onAbort(Event &e) { onUnhandled(e); }
 void MessagingHandler::onAccepted(Event &e) { onUnhandled(e); }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d56c5d76/proton-c/bindings/cpp/src/Sender.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Sender.cpp b/proton-c/bindings/cpp/src/Sender.cpp
index c521ad1..c8f962e 100644
--- a/proton-c/bindings/cpp/src/Sender.cpp
+++ b/proton-c/bindings/cpp/src/Sender.cpp
@@ -54,7 +54,7 @@ namespace{
 uint64_t tagCounter = 0;
 }
 
-void Sender::send(Message &message) {
+Delivery Sender::send(Message &message) {
     char tag[8];
     void *ptr = &tag;
     uint64_t id = ++tagCounter;
@@ -67,6 +67,7 @@ void Sender::send(Message &message) {
     pn_link_advance(link);
     if (pn_link_snd_settle_mode(link) == PN_SND_SETTLED)
         pn_delivery_settle(dlv);
+    return Delivery(dlv);
 }
 
 }} // namespace proton::reactor

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d56c5d76/proton-c/bindings/cpp/src/blocking/BlockingConnection.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/blocking/BlockingConnection.cpp b/proton-c/bindings/cpp/src/blocking/BlockingConnection.cpp
new file mode 100644
index 0000000..3fb6010
--- /dev/null
+++ b/proton-c/bindings/cpp/src/blocking/BlockingConnection.cpp
@@ -0,0 +1,62 @@
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/cpp/Container.h"
+#include "proton/cpp/BlockingConnection.h"
+#include "proton/cpp/BlockingSender.h"
+#include "proton/cpp/MessagingHandler.h"
+#include "proton/cpp/exceptions.h"
+#include "Msg.h"
+#include "BlockingConnectionImpl.h"
+#include "PrivateImplRef.h"
+
+namespace proton {
+namespace reactor {
+
+template class Handle<BlockingConnectionImpl>;
+typedef PrivateImplRef<BlockingConnection> PI;
+
+BlockingConnection::BlockingConnection() {PI::ctor(*this, 0); }
+
+BlockingConnection::BlockingConnection(const BlockingConnection& c) : Handle<BlockingConnectionImpl>() { PI::copy(*this, c); }
+
+BlockingConnection& BlockingConnection::operator=(const BlockingConnection& c) { return PI::assign(*this, c); }
+BlockingConnection::~BlockingConnection() { PI::dtor(*this); }
+
+BlockingConnection::BlockingConnection(std::string &url, Duration d, SslDomain *ssld, Container *c) {
+    BlockingConnectionImpl *cimpl = new BlockingConnectionImpl(url, d,ssld, c);
+    PI::ctor(*this, cimpl);
+}
+
+void BlockingConnection::close() { impl->close(); }
+
+void BlockingConnection::wait(WaitCondition &cond) { return impl->wait(cond); }
+void BlockingConnection::wait(WaitCondition &cond, std::string &msg, Duration timeout) {
+    return impl->wait(cond, msg, timeout);
+}
+
+BlockingSender BlockingConnection::createSender(std::string &address, Handler *h) {
+    Sender sender = impl->container.createSender(impl->connection, address, h);
+    return BlockingSender(*this, sender);
+}
+
+Duration BlockingConnection::getTimeout() { return impl->getTimeout(); }
+
+}} // namespace proton::reactor

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d56c5d76/proton-c/bindings/cpp/src/blocking/BlockingConnectionImpl.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/blocking/BlockingConnectionImpl.cpp b/proton-c/bindings/cpp/src/blocking/BlockingConnectionImpl.cpp
new file mode 100644
index 0000000..bdda697
--- /dev/null
+++ b/proton-c/bindings/cpp/src/blocking/BlockingConnectionImpl.cpp
@@ -0,0 +1,124 @@
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/cpp/Container.h"
+#include "proton/cpp/MessagingHandler.h"
+#include "proton/cpp/Duration.h"
+#include "proton/cpp/exceptions.h"
+#include "proton/cpp/WaitCondition.h"
+#include "BlockingConnectionImpl.h"
+#include "Msg.h"
+#include "contexts.h"
+
+#include "proton/connection.h"
+
+namespace proton {
+namespace reactor {
+
+WaitCondition::~WaitCondition() {}
+
+
+void BlockingConnectionImpl::incref(BlockingConnectionImpl *impl) {
+    impl->refCount++;
+}
+
+void BlockingConnectionImpl::decref(BlockingConnectionImpl *impl) {
+    impl->refCount--;
+    if (impl->refCount == 0)
+        delete impl;
+}
+
+namespace {
+struct ConnectionOpening : public WaitCondition {
+    ConnectionOpening(pn_connection_t *c) : pnConnection(c) {}
+    bool achieved() { return (pn_connection_state(pnConnection) & PN_REMOTE_UNINIT); }
+    pn_connection_t *pnConnection;
+};
+
+struct ConnectionClosed : public WaitCondition {
+    ConnectionClosed(pn_connection_t *c) : pnConnection(c) {}
+    bool achieved() { return !(pn_connection_state(pnConnection) & PN_REMOTE_ACTIVE); }
+    pn_connection_t *pnConnection;
+};
+
+}
+
+
+BlockingConnectionImpl::BlockingConnectionImpl(std::string &u, Duration timeout0, SslDomain *ssld, Container *c)
+    : url(u), timeout(timeout0), refCount(0)
+{
+    if (c)
+        container = *c;
+    container.start();
+    container.setTimeout(timeout);
+    // Create connection and send the connection events here
+    connection = container.connect(url, static_cast<Handler *>(this));
+    ConnectionOpening cond(connection.getPnConnection());
+    wait(cond);
+}
+
+BlockingConnectionImpl::~BlockingConnectionImpl() {
+    container = Container();
+}
+
+void BlockingConnectionImpl::close() {
+    connection.close();
+    ConnectionClosed cond(connection.getPnConnection());
+    wait(cond);
+}
+
+void BlockingConnectionImpl::wait(WaitCondition &condition) {
+    std::string empty;
+    wait(condition, empty, timeout);
+}
+
+void BlockingConnectionImpl::wait(WaitCondition &condition, std::string &msg, Duration waitTimeout) {
+    if (waitTimeout == Duration::FOREVER) {
+        while (!condition.achieved()) {
+            container.process();
+        }
+    }
+
+    pn_reactor_t *reactor = container.getReactor();
+    pn_millis_t origTimeout = pn_reactor_get_timeout(reactor);
+    pn_reactor_set_timeout(reactor, waitTimeout.getMilliseconds());
+    try {
+        pn_timestamp_t now = pn_reactor_mark(reactor);
+        pn_timestamp_t deadline = now + waitTimeout.getMilliseconds();
+        while (!condition.achieved()) {
+            container.process();
+            if (deadline < pn_reactor_mark(reactor)) {
+                std::string txt = "Connection timed out";
+                if (!msg.empty())
+                    txt += ": " + msg;
+                // TODO: proper Timeout exception
+                throw ProtonException(MSG(txt));
+            }
+        }
+    } catch (...) {
+        pn_reactor_set_timeout(reactor, origTimeout);
+        throw;
+    }
+    pn_reactor_set_timeout(reactor, origTimeout);
+}
+
+
+
+}} // namespace proton::reactor

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d56c5d76/proton-c/bindings/cpp/src/blocking/BlockingConnectionImpl.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/blocking/BlockingConnectionImpl.h b/proton-c/bindings/cpp/src/blocking/BlockingConnectionImpl.h
new file mode 100644
index 0000000..5f263ab
--- /dev/null
+++ b/proton-c/bindings/cpp/src/blocking/BlockingConnectionImpl.h
@@ -0,0 +1,63 @@
+#ifndef PROTON_CPP_CONNECTIONIMPL_H
+#define PROTON_CPP_CONNECTIONIMPL_H
+
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/cpp/ImportExport.h"
+#include "proton/cpp/Endpoint.h"
+#include "proton/cpp/Container.h"
+#include "proton/types.h"
+#include <string>
+
+struct pn_connection_t;
+
+namespace proton {
+namespace reactor {
+
+class Handler;
+class Container;
+class SslDomain;
+
+ class BlockingConnectionImpl : public MessagingHandler
+{
+  public:
+    PROTON_CPP_EXTERN BlockingConnectionImpl(std::string &url, Duration d, SslDomain *ssld, Container *c);
+    PROTON_CPP_EXTERN ~BlockingConnectionImpl();
+    PROTON_CPP_EXTERN void close();
+    PROTON_CPP_EXTERN void wait(WaitCondition &condition);
+    PROTON_CPP_EXTERN void wait(WaitCondition &condition, std::string &msg, Duration timeout);
+    PROTON_CPP_EXTERN pn_connection_t *getPnBlockingConnection();
+    Duration getTimeout() { return timeout; }
+    static void incref(BlockingConnectionImpl *);
+    static void decref(BlockingConnectionImpl *);
+  private:
+    friend class BlockingConnection;
+    Container container;
+    Connection connection;
+    std::string url;
+    Duration timeout;
+    int refCount;
+};
+
+
+}} // namespace proton::reactor
+
+#endif  /*!PROTON_CPP_CONNECTIONIMPL_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d56c5d76/proton-c/bindings/cpp/src/blocking/BlockingLink.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/blocking/BlockingLink.cpp b/proton-c/bindings/cpp/src/blocking/BlockingLink.cpp
new file mode 100644
index 0000000..5a572ae
--- /dev/null
+++ b/proton-c/bindings/cpp/src/blocking/BlockingLink.cpp
@@ -0,0 +1,86 @@
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/cpp/BlockingLink.h"
+#include "proton/cpp/BlockingConnection.h"
+#include "proton/cpp/MessagingHandler.h"
+#include "proton/cpp/WaitCondition.h"
+#include "proton/cpp/exceptions.h"
+#include "Msg.h"
+
+
+namespace proton {
+namespace reactor {
+
+namespace {
+struct LinkOpened : public WaitCondition {
+    LinkOpened(pn_link_t *l) : pnLink(l) {}
+    bool achieved() { return !(pn_link_state(pnLink) & PN_REMOTE_UNINIT); }
+    pn_link_t *pnLink;
+};
+
+struct LinkClosed : public WaitCondition {
+    LinkClosed(pn_link_t *l) : pnLink(l) {}
+    bool achieved() { return (pn_link_state(pnLink) & PN_REMOTE_CLOSED); }
+    pn_link_t *pnLink;
+};
+
+struct LinkNotOpen : public WaitCondition {
+    LinkNotOpen(pn_link_t *l) : pnLink(l) {}
+    bool achieved() { return !(pn_link_state(pnLink) & PN_REMOTE_ACTIVE); }
+    pn_link_t *pnLink;
+};
+
+
+} // namespace
+
+
+BlockingLink::BlockingLink(BlockingConnection *c, pn_link_t *pnl) : connection(*c), link(pnl) {
+    std::string msg = "Opening link " + link.getName();
+    LinkOpened linkOpened(link.getPnLink());
+    connection.wait(linkOpened, msg);
+}
+
+BlockingLink::~BlockingLink() {}
+
+void BlockingLink::waitForClosed(Duration timeout) {
+    std::string msg = "Closing link " + link.getName();
+    LinkClosed linkClosed(link.getPnLink());
+    connection.wait(linkClosed, msg);
+    checkClosed();
+}
+
+void BlockingLink::checkClosed() {
+    pn_link_t * pnLink = link.getPnLink();
+    if (pn_link_state(pnLink) & PN_REMOTE_CLOSED) {
+        link.close();
+        // TODO: LinkDetached exception
+        throw ProtonException(MSG("Link detached"));
+    }
+}
+
+void BlockingLink::close() {
+    link.close();
+    std::string msg = "Closing link " + link.getName();
+    LinkNotOpen linkNotOpen(link.getPnLink());
+    connection.wait(linkNotOpen, msg);
+}
+
+}} // namespace proton::reactor

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d56c5d76/proton-c/bindings/cpp/src/blocking/BlockingSender.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/blocking/BlockingSender.cpp b/proton-c/bindings/cpp/src/blocking/BlockingSender.cpp
new file mode 100644
index 0000000..dc6b9bd
--- /dev/null
+++ b/proton-c/bindings/cpp/src/blocking/BlockingSender.cpp
@@ -0,0 +1,66 @@
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/cpp/BlockingSender.h"
+#include "proton/cpp/BlockingConnection.h"
+#include "proton/cpp/WaitCondition.h"
+#include "proton/cpp/exceptions.h"
+#include "Msg.h"
+
+
+namespace proton {
+namespace reactor {
+
+namespace {
+struct DeliverySettled : public WaitCondition {
+    DeliverySettled(pn_delivery_t *d) : pnDelivery(d) {}
+    bool achieved() { return pn_delivery_settled(pnDelivery); }
+    pn_delivery_t *pnDelivery;
+};
+
+} // namespace
+
+
+BlockingSender::BlockingSender(BlockingConnection &c, Sender &l) : BlockingLink(&c, l.getPnLink()) {
+    std::string ta = link.getTarget().getAddress();
+    std::string rta = link.getRemoteTarget().getAddress();
+    if (ta.empty() || ta.compare(rta) != 0) {
+        waitForClosed();
+        link.close();
+        std::string txt = "Failed to open sender " + link.getName() + ", target does not match";
+        throw ProtonException(MSG("Container not started"));
+    }
+}
+
+Delivery BlockingSender::send(Message &msg, Duration timeout) {
+    Sender snd = link;
+    Delivery dlv = snd.send(msg);
+    std::string txt = "Sending on sender " + link.getName();
+    DeliverySettled cond(dlv.getPnDelivery());
+    connection.wait(cond, txt, timeout);
+    return dlv;
+}
+
+Delivery BlockingSender::send(Message &msg) {
+    // Use default timeout
+    return send(msg, connection.getTimeout());
+}
+
+}} // namespace proton::reactor


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


[38/50] [abbrv] qpid-proton git commit: PROTON-885: add pthreads option to swig command

Posted by ac...@apache.org.
PROTON-885: add pthreads option to swig command


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/0b7718c7
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/0b7718c7
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/0b7718c7

Branch: refs/heads/cjansen-cpp-client
Commit: 0b7718c74a8fc905cc209b4859408feae5805029
Parents: a3fc3ff
Author: Ken Giusti <kg...@apache.org>
Authored: Tue May 26 16:58:13 2015 -0400
Committer: Ken Giusti <kg...@apache.org>
Committed: Tue May 26 17:17:00 2015 -0400

----------------------------------------------------------------------
 proton-c/bindings/python/setuputils/misc.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0b7718c7/proton-c/bindings/python/setuputils/misc.py
----------------------------------------------------------------------
diff --git a/proton-c/bindings/python/setuputils/misc.py b/proton-c/bindings/python/setuputils/misc.py
index 3ebb160..8978371 100644
--- a/proton-c/bindings/python/setuputils/misc.py
+++ b/proton-c/bindings/python/setuputils/misc.py
@@ -30,7 +30,7 @@ def settings_from_prefix(prefix=None):
     settings['libraries'] = []
     settings['include_dirs'] = []
     settings['library_dirs'] = []
-    settings['swig_opts'] = []
+    settings['swig_opts'] = ['-threads']
     settings['runtime_library_dirs'] = []
     settings['extra_link_args'] = []
 


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


[46/50] [abbrv] qpid-proton git commit: PROTON-865: Message properties, Acking and Delivery

Posted by ac...@apache.org.
PROTON-865: Message properties, Acking and Delivery


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/3c0c90f7
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/3c0c90f7
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/3c0c90f7

Branch: refs/heads/cjansen-cpp-client
Commit: 3c0c90f74c053657d04cd7ba6f357f851c101999
Parents: 648f7b3
Author: Clifford Jansen <cl...@apache.org>
Authored: Thu May 7 07:06:43 2015 -0700
Committer: Alan Conway <ac...@redhat.com>
Committed: Tue Jun 2 14:46:14 2015 -0400

----------------------------------------------------------------------
 proton-c/bindings/cpp/CMakeLists.txt            |   2 +
 .../bindings/cpp/include/proton/cpp/Acking.h    |  44 ++++
 .../bindings/cpp/include/proton/cpp/Delivery.h  |  61 +++++
 .../bindings/cpp/include/proton/cpp/Message.h   |  44 ++++
 .../cpp/include/proton/cpp/MessagingAdapter.h   |   3 +-
 .../cpp/include/proton/cpp/MessagingHandler.h   |  15 +-
 proton-c/bindings/cpp/src/Acking.cpp            |  49 ++++
 proton-c/bindings/cpp/src/ContainerImpl.cpp     |   5 +-
 proton-c/bindings/cpp/src/ContainerImpl.h       |   2 +-
 proton-c/bindings/cpp/src/Delivery.cpp          |  57 +++++
 proton-c/bindings/cpp/src/Message.cpp           | 234 ++++++++++++++++++-
 proton-c/bindings/cpp/src/MessagingAdapter.cpp  |  15 +-
 proton-c/bindings/cpp/src/MessagingHandler.cpp  |   9 +-
 13 files changed, 521 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3c0c90f7/proton-c/bindings/cpp/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/CMakeLists.txt b/proton-c/bindings/cpp/CMakeLists.txt
index 68baad7..ba35cb1 100644
--- a/proton-c/bindings/cpp/CMakeLists.txt
+++ b/proton-c/bindings/cpp/CMakeLists.txt
@@ -48,6 +48,8 @@ set (qpid-proton-cpp-core
     src/Receiver.cpp
     src/Sender.cpp
     src/Session.cpp
+    src/Delivery.cpp
+    src/Acking.cpp
     src/Transport.cpp
     src/Logger.cpp
     src/contexts.cpp

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3c0c90f7/proton-c/bindings/cpp/include/proton/cpp/Acking.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Acking.h b/proton-c/bindings/cpp/include/proton/cpp/Acking.h
new file mode 100644
index 0000000..d40d7d4
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/Acking.h
@@ -0,0 +1,44 @@
+#ifndef PROTON_CPP_ACKING_H
+#define PROTON_CPP_ACKING_H
+
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "proton/cpp/ImportExport.h"
+#include "proton/cpp/Delivery.h"
+
+namespace proton {
+namespace reactor {
+
+
+class Acking
+{
+  public:
+    PROTON_CPP_EXTERN virtual void accept(Delivery &d);
+    PROTON_CPP_EXTERN virtual void reject(Delivery &d);
+    PROTON_CPP_EXTERN virtual void release(Delivery &d, bool delivered=true);
+    PROTON_CPP_EXTERN virtual void settle(Delivery &d, Delivery::state s = Delivery::REJECTED);
+};
+
+
+}} // namespace proton::reactor
+
+#endif  /*!PROTON_CPP_ACKING_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3c0c90f7/proton-c/bindings/cpp/include/proton/cpp/Delivery.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Delivery.h b/proton-c/bindings/cpp/include/proton/cpp/Delivery.h
new file mode 100644
index 0000000..a1965f6
--- /dev/null
+++ b/proton-c/bindings/cpp/include/proton/cpp/Delivery.h
@@ -0,0 +1,61 @@
+#ifndef PROTON_CPP_DELIVERY_H
+#define PROTON_CPP_DELIVERY_H
+
+/*
+ *
+ * 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.
+ *
+ */
+#include "proton/cpp/ImportExport.h"
+#include "proton/cpp/Link.h"
+
+#include "ProtonImplRef.h"
+#include "proton/disposition.h"
+
+namespace proton {
+namespace reactor {
+
+class Delivery : public ProtonHandle<pn_delivery_t>
+{
+  public:
+
+    enum state {
+        NONE = 0,
+        RECEIVED = PN_RECEIVED,
+        ACCEPTED = PN_ACCEPTED,
+        REJECTED = PN_REJECTED,
+        RELEASED = PN_RELEASED,
+        MODIFIED = PN_MODIFIED
+    };  // AMQP spec 3.4 Delivery State
+
+    PROTON_CPP_EXTERN Delivery(pn_delivery_t *d);
+    PROTON_CPP_EXTERN Delivery();
+    PROTON_CPP_EXTERN ~Delivery();
+    PROTON_CPP_EXTERN Delivery(const Delivery&);
+    PROTON_CPP_EXTERN Delivery& operator=(const Delivery&);
+    PROTON_CPP_EXTERN bool settled();
+    PROTON_CPP_EXTERN void settle();
+    PROTON_CPP_EXTERN pn_delivery_t *getPnDelivery();
+  private:
+    friend class ProtonImplRef<Delivery>;
+};
+
+
+}} // namespace proton::reactor
+
+#endif  /*!PROTON_CPP_DELIVERY_H*/

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3c0c90f7/proton-c/bindings/cpp/include/proton/cpp/Message.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/Message.h b/proton-c/bindings/cpp/include/proton/cpp/Message.h
index ae29ca2..590fdd8 100644
--- a/proton-c/bindings/cpp/include/proton/cpp/Message.h
+++ b/proton-c/bindings/cpp/include/proton/cpp/Message.h
@@ -43,8 +43,52 @@ class Message : public ProtonHandle<pn_message_t>
 
     PROTON_CPP_EXTERN void setId(uint64_t id);
     PROTON_CPP_EXTERN uint64_t getId();
+    PROTON_CPP_EXTERN void setId(const std::string &id);
+    PROTON_CPP_EXTERN std::string getStringId();
+    PROTON_CPP_EXTERN void setId(const char *p, size_t len);
+    PROTON_CPP_EXTERN size_t getId(const char **p);
+    // TODO: UUID version
     PROTON_CPP_EXTERN pn_type_t getIdType();
 
+    PROTON_CPP_EXTERN void setUserId(const std::string &id);
+    PROTON_CPP_EXTERN std::string getUserId();
+
+    PROTON_CPP_EXTERN void setAddress(const std::string &addr);
+    PROTON_CPP_EXTERN std::string getAddress();
+
+    PROTON_CPP_EXTERN void setSubject(const std::string &s);
+    PROTON_CPP_EXTERN std::string getSubject();
+
+    PROTON_CPP_EXTERN void setReplyTo(const std::string &s);
+    PROTON_CPP_EXTERN std::string getReplyTo();
+
+    PROTON_CPP_EXTERN void setCorrelationId(uint64_t id);
+    PROTON_CPP_EXTERN uint64_t getCorrelationId();
+    PROTON_CPP_EXTERN void setCorrelationId(const std::string &id);
+    PROTON_CPP_EXTERN std::string getStringCorrelationId();
+    PROTON_CPP_EXTERN void setCorrelationId(const char *p, size_t len);
+    PROTON_CPP_EXTERN size_t getCorrelationId(const char **p);
+    // TODO: UUID version
+    PROTON_CPP_EXTERN pn_type_t getCorrelationIdType();
+
+    PROTON_CPP_EXTERN void setContentType(const std::string &s);
+    PROTON_CPP_EXTERN std::string getContentType();
+
+    PROTON_CPP_EXTERN void setContentEncoding(const std::string &s);
+    PROTON_CPP_EXTERN std::string getContentEncoding();
+
+    PROTON_CPP_EXTERN void setExpiry(pn_timestamp_t t);
+    PROTON_CPP_EXTERN pn_timestamp_t getExpiry();
+
+    PROTON_CPP_EXTERN void setCreationTime(pn_timestamp_t t);
+    PROTON_CPP_EXTERN pn_timestamp_t getCreationTime();
+
+    PROTON_CPP_EXTERN void setGroupId(const std::string &s);
+    PROTON_CPP_EXTERN std::string getGroupId();
+
+    PROTON_CPP_EXTERN void setReplyToGroupId(const std::string &s);
+    PROTON_CPP_EXTERN std::string getReplyToGroupId();
+
     PROTON_CPP_EXTERN void setBody(const std::string &data);
     PROTON_CPP_EXTERN std::string getBody();
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3c0c90f7/proton-c/bindings/cpp/include/proton/cpp/MessagingAdapter.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/MessagingAdapter.h b/proton-c/bindings/cpp/include/proton/cpp/MessagingAdapter.h
index ac8b483..36a92e4 100644
--- a/proton-c/bindings/cpp/include/proton/cpp/MessagingAdapter.h
+++ b/proton-c/bindings/cpp/include/proton/cpp/MessagingAdapter.h
@@ -70,8 +70,7 @@ class MessagingAdapter : public MessagingHandler
     PROTON_CPP_EXTERN virtual void onLinkOpening(Event &e);
     PROTON_CPP_EXTERN virtual void onTransportTailClosed(Event &e);
   private:
-    MessagingHandler &delegate;  // The actual MessagingHandler
-    pn_handler_t *handshaker;
+    MessagingHandler &delegate;  // The handler for generated MessagingEvent's
     bool autoSettle;
     bool autoAccept;
     bool peerCloseIsError;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3c0c90f7/proton-c/bindings/cpp/include/proton/cpp/MessagingHandler.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/include/proton/cpp/MessagingHandler.h b/proton-c/bindings/cpp/include/proton/cpp/MessagingHandler.h
index 51f679a..4f00681 100644
--- a/proton-c/bindings/cpp/include/proton/cpp/MessagingHandler.h
+++ b/proton-c/bindings/cpp/include/proton/cpp/MessagingHandler.h
@@ -23,6 +23,7 @@
  */
 
 #include "proton/cpp/ProtonHandler.h"
+#include "proton/cpp/Acking.h"
 #include "proton/event.h"
 
 namespace proton {
@@ -30,11 +31,11 @@ namespace reactor {
 
 class Event;
 
-class PROTON_CPP_EXTERN MessagingHandler : public ProtonHandler
+class PROTON_CPP_EXTERN MessagingHandler : public ProtonHandler , public Acking
 {
   public:
-    PROTON_CPP_EXTERN MessagingHandler();
-//ZZZ    PROTON_CPP_EXTERN MessagingHandler(int prefetch=10, bool autoAccept=true, autoSettle=true, peerCloseIsError=false);
+    PROTON_CPP_EXTERN MessagingHandler(int prefetch=10, bool autoAccept=true, bool autoSettle=true,
+                                       bool peerCloseIsError=false);
     virtual ~MessagingHandler();
 
     virtual void onAbort(Event &e);
@@ -74,6 +75,14 @@ class PROTON_CPP_EXTERN MessagingHandler : public ProtonHandler
     virtual void onTransactionCommitted(Event &e);
     virtual void onTransactionDeclared(Event &e);
     virtual void onTransportClosed(Event &e);
+  protected:
+    int prefetch;
+    bool autoSettle;
+    bool autoAccept;
+    bool peerCloseIsError;
+  private:
+    friend class ContainerImpl;
+    friend class MessagingAdapter;
 };
 
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3c0c90f7/proton-c/bindings/cpp/src/Acking.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Acking.cpp b/proton-c/bindings/cpp/src/Acking.cpp
new file mode 100644
index 0000000..62eca98
--- /dev/null
+++ b/proton-c/bindings/cpp/src/Acking.cpp
@@ -0,0 +1,49 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "proton/cpp/Acking.h"
+#include "proton/delivery.h"
+
+namespace proton {
+namespace reactor {
+
+void Acking::accept(Delivery &d) {
+    settle(d, Delivery::ACCEPTED);
+}
+
+void Acking::reject(Delivery &d) {
+    settle(d, Delivery::REJECTED);
+}
+
+void Acking::release(Delivery &d, bool delivered) {
+    if (delivered)
+        settle(d, Delivery::MODIFIED);
+    else
+        settle(d, Delivery::RELEASED);
+}
+
+void Acking::settle(Delivery &d, Delivery::state state) {
+    if (state)
+        pn_delivery_update(d.getPnDelivery(), state);
+    d.settle();
+}
+
+}} // namespace proton::reactor

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3c0c90f7/proton-c/bindings/cpp/src/ContainerImpl.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/ContainerImpl.cpp b/proton-c/bindings/cpp/src/ContainerImpl.cpp
index df8c716..d1339f0 100644
--- a/proton-c/bindings/cpp/src/ContainerImpl.cpp
+++ b/proton-c/bindings/cpp/src/ContainerImpl.cpp
@@ -308,16 +308,15 @@ void ContainerImpl::run() {
     // Set our context on the reactor
     setContainerContext(reactor, this);
 
-    int prefetch = 10; // TODO: configurable
+    int prefetch = messagingHandler.prefetch;
     Handler *flowController = 0;
 
-
     // Set the reactor's main/default handler (see note below)
-    MessagingAdapter messagingAdapter(messagingHandler);
     if (prefetch) {
         flowController = new CFlowController(prefetch);
         messagingHandler.addChildHandler(*flowController);
     }
+    MessagingAdapter messagingAdapter(messagingHandler);
     messagingHandler.addChildHandler(messagingAdapter);
     pn_handler_t *cppHandler = cpp_handler(this, &messagingHandler);
     pn_reactor_set_handler(reactor, cppHandler);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3c0c90f7/proton-c/bindings/cpp/src/ContainerImpl.h
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/ContainerImpl.h b/proton-c/bindings/cpp/src/ContainerImpl.h
index 8a6faba..f7b5b9e 100644
--- a/proton-c/bindings/cpp/src/ContainerImpl.h
+++ b/proton-c/bindings/cpp/src/ContainerImpl.h
@@ -49,7 +49,7 @@ class ContainerImpl
     PROTON_CPP_EXTERN Sender createSender(Connection &connection, std::string &addr);
     PROTON_CPP_EXTERN Sender createSender(std::string &url);
     PROTON_CPP_EXTERN Receiver createReceiver(Connection &connection, std::string &addr);
-    PROTON_CPP_EXTERN Receiver createReceiver(const std::string &url); //ZZZ
+    PROTON_CPP_EXTERN Receiver createReceiver(const std::string &url);
     PROTON_CPP_EXTERN Acceptor listen(const std::string &url);
     PROTON_CPP_EXTERN std::string getContainerId();
     static void incref(ContainerImpl *);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3c0c90f7/proton-c/bindings/cpp/src/Delivery.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Delivery.cpp b/proton-c/bindings/cpp/src/Delivery.cpp
new file mode 100644
index 0000000..990e394
--- /dev/null
+++ b/proton-c/bindings/cpp/src/Delivery.cpp
@@ -0,0 +1,57 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+#include "proton/cpp/Delivery.h"
+#include "proton/delivery.h"
+
+namespace proton {
+namespace reactor {
+
+template class ProtonHandle<pn_delivery_t>;
+typedef ProtonImplRef<Delivery> PI;
+
+Delivery::Delivery(pn_delivery_t *p) {
+    PI::ctor(*this, p);
+}
+Delivery::Delivery() {
+    PI::ctor(*this, 0);
+}
+Delivery::Delivery(const Delivery& c) : ProtonHandle<pn_delivery_t>() {
+    PI::copy(*this, c);
+}
+Delivery& Delivery::operator=(const Delivery& c) {
+    return PI::assign(*this, c);
+}
+Delivery::~Delivery() {
+    PI::dtor(*this);
+}
+
+bool Delivery::settled() {
+    return pn_delivery_settled(impl);
+}
+
+void Delivery::settle() {
+    pn_delivery_settle(impl);
+}
+
+pn_delivery_t *Delivery::getPnDelivery() { return impl; }
+
+}} // namespace proton::reactor

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3c0c90f7/proton-c/bindings/cpp/src/Message.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/Message.cpp b/proton-c/bindings/cpp/src/Message.cpp
index ead6eb1..bdc8c0c 100644
--- a/proton-c/bindings/cpp/src/Message.cpp
+++ b/proton-c/bindings/cpp/src/Message.cpp
@@ -93,6 +93,45 @@ uint64_t Message::getId() {
     throw ProtonException(MSG("Message ID is not a ULONG"));
 }
 
+void Message::setId(const std::string &id) {
+    confirm(impl);
+    pn_data_t *data = pn_message_id(impl);
+    pn_data_clear(data);
+    if (int err = pn_data_put_string(data, pn_bytes(id.size(), id.data())))
+        throw ProtonException(MSG("setId error " << err));
+}
+
+std::string Message::getStringId() {
+    confirm(impl);
+    pn_data_t *data = pn_message_id(impl);
+    pn_data_rewind(data);
+    if (pn_data_size(data) == 1 && pn_data_next(data) && pn_data_type(data) == PN_STRING) {
+        pn_bytes_t bytes = pn_data_get_string(data);
+        return (std::string(bytes.start, bytes.size));
+    }
+    throw ProtonException(MSG("Message ID is not a string value"));
+}
+
+void Message::setId(const char *p, size_t len) {
+    confirm(impl);
+    pn_data_t *data = pn_message_id(impl);
+    pn_data_clear(data);
+    if (int err = pn_data_put_binary(data, pn_bytes(len, p)))
+        throw ProtonException(MSG("setId error " << err));
+}
+
+size_t Message::getId(const char **p) {
+    confirm(impl);
+    pn_data_t *data = pn_message_id(impl);
+    pn_data_rewind(data);
+    if (pn_data_size(data) == 1 && pn_data_next(data) && pn_data_type(data) == PN_BINARY) {
+        pn_bytes_t pnb = pn_data_get_binary(data);
+        *p = pnb.start;
+        return pnb.size;
+    }
+    throw ProtonException(MSG("Message ID is not a binary value"));
+}
+
 pn_type_t Message::getIdType() {
     confirm(impl);
     pn_data_t *data = pn_message_id(impl);
@@ -113,6 +152,199 @@ pn_type_t Message::getIdType() {
     return PN_NULL;
 }
 
+void Message::setUserId(const std::string &id) {
+    confirm(impl);
+    if (int err = pn_message_set_user_id(impl, pn_bytes(id.size(), id.data())))
+        throw ProtonException(MSG("setUserId error " << err));
+}
+
+std::string Message::getUserId() {
+    confirm(impl);
+    pn_bytes_t bytes = pn_message_get_user_id(impl);
+    return (std::string(bytes.start, bytes.size));
+}
+
+void Message::setAddress(const std::string &addr) {
+    confirm(impl);
+    if (int err = pn_message_set_address(impl, addr.c_str()))
+        throw ProtonException(MSG("setAddress error " << err));
+}
+
+std::string Message::getAddress() {
+    confirm(impl);
+    const char* addr = pn_message_get_address(impl);
+    return addr ? std::string(addr) : std::string();
+}
+
+void Message::setSubject(const std::string &s) {
+    confirm(impl);
+    if (int err = pn_message_set_subject(impl, s.c_str()))
+        throw ProtonException(MSG("setSubject error " << err));
+}
+
+std::string Message::getSubject() {
+    confirm(impl);
+    const char* s = pn_message_get_subject(impl);
+    return s ? std::string(s) : std::string();
+}
+
+void Message::setReplyTo(const std::string &s) {
+    confirm(impl);
+    if (int err = pn_message_set_reply_to(impl, s.c_str()))
+        throw ProtonException(MSG("setReplyTo error " << err));
+}
+
+std::string Message::getReplyTo() {
+    confirm(impl);
+    const char* s = pn_message_get_reply_to(impl);
+    return s ? std::string(s) : std::string();
+}
+
+void Message::setCorrelationId(uint64_t id) {
+    confirm(impl);
+    pn_data_t *data = pn_message_correlation_id(impl);
+    pn_data_clear(data);
+    if (int err = pn_data_put_ulong(data, id))
+        throw ProtonException(MSG("setCorrelationId error " << err));
+}
+
+uint64_t Message::getCorrelationId() {
+    confirm(impl);
+    pn_data_t *data = pn_message_correlation_id(impl);
+    pn_data_rewind(data);
+    if (pn_data_size(data) == 1 && pn_data_next(data) && pn_data_type(data) == PN_ULONG) {
+        return pn_data_get_ulong(data);
+    }
+    throw ProtonException(MSG("Correlation ID is not a ULONG"));
+}
+
+void Message::setCorrelationId(const std::string &id) {
+    confirm(impl);
+    pn_data_t *data = pn_message_correlation_id(impl);
+    pn_data_clear(data);
+    if (int err = pn_data_put_string(data, pn_bytes(id.size(), id.data())))
+        throw ProtonException(MSG("setCorrelationId error " << err));
+}
+
+std::string Message::getStringCorrelationId() {
+    confirm(impl);
+    pn_data_t *data = pn_message_correlation_id(impl);
+    pn_data_rewind(data);
+    if (pn_data_size(data) == 1 && pn_data_next(data) && pn_data_type(data) == PN_STRING) {
+        pn_bytes_t bytes = pn_data_get_string(data);
+        return (std::string(bytes.start, bytes.size));
+    }
+    throw ProtonException(MSG("Message ID is not a string value"));
+}
+
+void Message::setCorrelationId(const char *p, size_t len) {
+    confirm(impl);
+    pn_data_t *data = pn_message_correlation_id(impl);
+    pn_data_clear(data);
+    if (int err = pn_data_put_binary(data, pn_bytes(len, p)))
+        throw ProtonException(MSG("setCorrelationId error " << err));
+}
+
+size_t Message::getCorrelationId(const char **p) {
+    confirm(impl);
+    pn_data_t *data = pn_message_correlation_id(impl);
+    pn_data_rewind(data);
+    if (pn_data_size(data) == 1 && pn_data_next(data) && pn_data_type(data) == PN_BINARY) {
+        pn_bytes_t pnb = pn_data_get_binary(data);
+        *p = pnb.start;
+        return pnb.size;
+    }
+    throw ProtonException(MSG("Message ID is not a binary value"));
+}
+
+pn_type_t Message::getCorrelationIdType() {
+    confirm(impl);
+    pn_data_t *data = pn_message_correlation_id(impl);
+    pn_data_rewind(data);
+    if (pn_data_size(data) == 1 && pn_data_next(data)) {
+        pn_type_t type = pn_data_type(data);
+        switch (type) {
+        case PN_ULONG:
+        case PN_STRING:
+        case PN_BINARY:
+        case PN_UUID:
+            return type;
+            break;
+        default:
+            break;
+        }
+    }
+    return PN_NULL;
+}
+
+void Message::setContentType(const std::string &s) {
+    confirm(impl);
+    if (int err = pn_message_set_content_type(impl, s.c_str()))
+        throw ProtonException(MSG("setContentType error " << err));
+}
+
+std::string Message::getContentType() {
+    confirm(impl);
+    const char* s = pn_message_get_content_type(impl);
+    return s ? std::string(s) : std::string();
+}
+
+void Message::setContentEncoding(const std::string &s) {
+    confirm(impl);
+    if (int err = pn_message_set_content_encoding(impl, s.c_str()))
+        throw ProtonException(MSG("setContentEncoding error " << err));
+}
+
+std::string Message::getContentEncoding() {
+    confirm(impl);
+    const char* s = pn_message_get_content_encoding(impl);
+    return s ? std::string(s) : std::string();
+}
+
+void Message::setExpiry(pn_timestamp_t t) {
+    confirm(impl);
+    pn_message_set_expiry_time(impl, t);
+}
+pn_timestamp_t Message::getExpiry() {
+    confirm(impl);
+    return pn_message_get_expiry_time(impl);
+}
+
+void Message::setCreationTime(pn_timestamp_t t) {
+    confirm(impl);
+    pn_message_set_creation_time(impl, t);
+}
+pn_timestamp_t Message::getCreationTime() {
+    confirm(impl);
+    return pn_message_get_creation_time(impl);
+}
+
+
+void Message::setGroupId(const std::string &s) {
+    confirm(impl);
+    if (int err = pn_message_set_group_id(impl, s.c_str()))
+        throw ProtonException(MSG("setGroupId error " << err));
+}
+
+std::string Message::getGroupId() {
+    confirm(impl);
+    const char* s = pn_message_get_group_id(impl);
+    return s ? std::string(s) : std::string();
+}
+
+void Message::setReplyToGroupId(const std::string &s) {
+    confirm(impl);
+    if (int err = pn_message_set_reply_to_group_id(impl, s.c_str()))
+        throw ProtonException(MSG("setReplyToGroupId error " << err));
+}
+
+std::string Message::getReplyToGroupId() {
+    confirm(impl);
+    const char* s = pn_message_get_reply_to_group_id(impl);
+    return s ? std::string(s) : std::string();
+}
+
+
 void Message::setBody(const std::string &buf) {
     confirm(impl);
     pn_data_t *body = pn_message_body(impl);
@@ -127,7 +359,7 @@ void Message::getBody(std::string &str) {
     pn_data_rewind(body);
 
     if (pn_data_next(body) && pn_data_type(body) == PN_STRING) {
-        pn_bytes_t bytes= pn_data_get_string(body);
+        pn_bytes_t bytes = pn_data_get_string(body);
         if (!pn_data_next(body)) {
             // String data and nothing else
             str.resize(bytes.size);

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3c0c90f7/proton-c/bindings/cpp/src/MessagingAdapter.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/MessagingAdapter.cpp b/proton-c/bindings/cpp/src/MessagingAdapter.cpp
index 1097305..f2916db 100644
--- a/proton-c/bindings/cpp/src/MessagingAdapter.cpp
+++ b/proton-c/bindings/cpp/src/MessagingAdapter.cpp
@@ -33,13 +33,14 @@
 namespace proton {
 namespace reactor {
 
-MessagingAdapter::MessagingAdapter(MessagingHandler &d) : delegate(d), handshaker(pn_handshaker()),
-                                                          autoSettle(true), autoAccept(true),
-                                                          peerCloseIsError(false) {
-};
-MessagingAdapter::~MessagingAdapter(){
-    pn_decref(handshaker);
-};
+MessagingAdapter::MessagingAdapter(MessagingHandler &delegate_) :
+    autoSettle(delegate_.autoSettle),
+    autoAccept(delegate_.autoAccept),
+    peerCloseIsError(delegate_.peerCloseIsError),
+    delegate(delegate_)
+{};
+
+MessagingAdapter::~MessagingAdapter(){};
 
 
 void MessagingAdapter::onReactorInit(Event &e) {

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3c0c90f7/proton-c/bindings/cpp/src/MessagingHandler.cpp
----------------------------------------------------------------------
diff --git a/proton-c/bindings/cpp/src/MessagingHandler.cpp b/proton-c/bindings/cpp/src/MessagingHandler.cpp
index 6066b07..7a4a5cb 100644
--- a/proton-c/bindings/cpp/src/MessagingHandler.cpp
+++ b/proton-c/bindings/cpp/src/MessagingHandler.cpp
@@ -19,12 +19,17 @@
  *
  */
 #include "proton/cpp/MessagingHandler.h"
-#include "proton/cpp/Event.h"
+#include "proton/cpp/ProtonEvent.h"
+#include "proton/cpp/MessagingAdapter.h"
+#include "proton/handlers.h"
 
 namespace proton {
 namespace reactor {
 
-MessagingHandler::MessagingHandler(){};
+MessagingHandler::MessagingHandler(int prefetch0, bool autoAccept0, bool autoSettle0, bool peerCloseIsError0) :
+    prefetch(prefetch0), autoAccept(autoAccept0), autoSettle(autoSettle0), peerCloseIsError(peerCloseIsError0)
+{}
+
 MessagingHandler::~MessagingHandler(){};
 
 void MessagingHandler::onAbort(Event &e) { onUnhandled(e); }


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


[43/50] [abbrv] qpid-proton git commit: PROTON-827: Update go README to point to correct location.

Posted by ac...@apache.org.
PROTON-827: Update go README to point to correct location.


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/23861732
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/23861732
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/23861732

Branch: refs/heads/cjansen-cpp-client
Commit: 238617325001b2b0e72ea384d7931a65f86ae63b
Parents: 485b23d
Author: Alan Conway <ac...@redhat.com>
Authored: Fri May 29 15:27:49 2015 -0400
Committer: Alan Conway <ac...@redhat.com>
Committed: Fri May 29 15:27:49 2015 -0400

----------------------------------------------------------------------
 proton-c/bindings/go/README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/23861732/proton-c/bindings/go/README.md
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/README.md b/proton-c/bindings/go/README.md
index a5580e9..0d3a74e 100644
--- a/proton-c/bindings/go/README.md
+++ b/proton-c/bindings/go/README.md
@@ -2,4 +2,4 @@
 
 Experimental work on the Go language binding has been moved to the `go1` branch
 until it is ready for use. You can `git checkout go1` on your git clone, or
-browse at https://github.com/apache/qpid-proton/blob/go1/go/README.md
+browse at https://github.com/apache/qpid-proton/blob/go1/proton-c/bindings/go/README.md


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


[09/50] [abbrv] qpid-proton git commit: PROTON-868: Avoid "strict aliasing" warnings caused on some compilers

Posted by ac...@apache.org.
PROTON-868: Avoid "strict aliasing" warnings caused on some compilers


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/0edb24df
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/0edb24df
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/0edb24df

Branch: refs/heads/cjansen-cpp-client
Commit: 0edb24df7d30ec835acf5cf36a23c28f32100e75
Parents: 0e155e2
Author: Andrew Stitcher <as...@apache.org>
Authored: Tue May 12 14:12:35 2015 -0400
Committer: Andrew Stitcher <as...@apache.org>
Committed: Tue May 12 14:12:35 2015 -0400

----------------------------------------------------------------------
 proton-c/src/sasl/cyrus_sasl.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/0edb24df/proton-c/src/sasl/cyrus_sasl.c
----------------------------------------------------------------------
diff --git a/proton-c/src/sasl/cyrus_sasl.c b/proton-c/src/sasl/cyrus_sasl.c
index c6010e2..7ab7379 100644
--- a/proton-c/src/sasl/cyrus_sasl.c
+++ b/proton-c/src/sasl/cyrus_sasl.c
@@ -113,12 +113,14 @@ bool pni_init_client(pn_transport_t* transport) {
     if (result!=SASL_OK) return false;
 
     const sasl_callback_t *callbacks = sasl->username ? sasl->password ? pni_user_password_callbacks : pni_user_callbacks : NULL;
+    sasl_conn_t *cyrus_conn;
     result = sasl_client_new(amqp_service,
                              sasl->remote_fqdn,
                              NULL, NULL,
                              callbacks, 0,
-                             (sasl_conn_t**)&sasl->impl_context);
+                             &cyrus_conn);
     if (result!=SASL_OK) return false;
+    sasl->impl_context = cyrus_conn;
 
     return true;
 }
@@ -227,14 +229,15 @@ static int pni_wrap_server_new(pn_transport_t *transport)
     result = sasl_server_init(NULL, sasl->config_name);
     if (result!=SASL_OK) return result;
 
-    result = sasl_server_new(amqp_service, NULL, NULL, NULL, NULL, NULL, 0, (sasl_conn_t**)&sasl->impl_context);
+    sasl_conn_t *cyrus_conn;
+    result = sasl_server_new(amqp_service, NULL, NULL, NULL, NULL, NULL, 0, &cyrus_conn);
     if (result!=SASL_OK) return result;
+    sasl->impl_context = cyrus_conn;
 
     sasl_security_properties_t secprops = {0};
     secprops.security_flags =
     SASL_SEC_NOPLAINTEXT |
     ( transport->auth_required ? SASL_SEC_NOANONYMOUS : 0 ) ;
-    sasl_conn_t *cyrus_conn = (sasl_conn_t*)sasl->impl_context;
 
     result = sasl_setprop(cyrus_conn, SASL_SEC_PROPS, &secprops);
     if (result!=SASL_OK) return result;
@@ -356,7 +359,9 @@ void pni_process_response(pn_transport_t *transport, const pn_bytes_t *recv)
 
 void pni_sasl_impl_free(pn_transport_t *transport)
 {
-    sasl_dispose((sasl_conn_t**)&transport->sasl->impl_context);
+    sasl_conn_t *cyrus_conn = (sasl_conn_t*)transport->sasl->impl_context;
+    sasl_dispose(&cyrus_conn);
+    transport->sasl->impl_context = cyrus_conn;
     if (transport->sasl->client) {
         sasl_client_done();
     } else {


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


[18/50] [abbrv] qpid-proton git commit: NO-JIRA: Added Appveyor CI build instructions (Windows CI)

Posted by ac...@apache.org.
NO-JIRA: Added Appveyor CI build instructions (Windows CI)


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/57414346
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/57414346
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/57414346

Branch: refs/heads/cjansen-cpp-client
Commit: 57414346bf50e662a22f13997797d59247b84b4d
Parents: 3a34066
Author: Andrew Stitcher <as...@apache.org>
Authored: Wed May 13 12:39:05 2015 -0400
Committer: Andrew Stitcher <as...@apache.org>
Committed: Wed May 13 12:39:05 2015 -0400

----------------------------------------------------------------------
 appveyor.yml | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/57414346/appveyor.yml
----------------------------------------------------------------------
diff --git a/appveyor.yml b/appveyor.yml
new file mode 100644
index 0000000..a147e0d
--- /dev/null
+++ b/appveyor.yml
@@ -0,0 +1,16 @@
+version: 0.10-SNAPSHOT-{branch}.{build}
+configuration: RelWithDebInfo
+install:
+- cinst -y swig
+before_build:
+- mkdir BLD
+- cd BLD
+- cmake -G "Visual Studio 12" -DBUILD_PERL=no ..
+- cd ..
+build:
+  parallel: true
+  verbosity: normal
+test_script:
+- cd BLD
+- ctest -V -C RelWithDebInfo
+- cd ..


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


[17/50] [abbrv] qpid-proton git commit: Add travis-ci build status badge to README

Posted by ac...@apache.org.
Add travis-ci build status badge to README


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/3a340664
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/3a340664
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/3a340664

Branch: refs/heads/cjansen-cpp-client
Commit: 3a3406644ccebb31aa8cc739530a91950b7d3049
Parents: c476cdb
Author: Dominic Evans <do...@uk.ibm.com>
Authored: Wed May 13 17:05:36 2015 +0100
Committer: Dominic Evans <do...@uk.ibm.com>
Committed: Wed May 13 17:05:36 2015 +0100

----------------------------------------------------------------------
 README.md | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3a340664/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index c1d2bbf..fe422dc 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,8 @@
 Qpid Proton - AMQP messaging toolkit
 ====================================
 
+[![Build Status](https://travis-ci.org/apache/qpid-proton.svg?branch=master)](https://travis-ci.org/apache/qpid-proton)
+
 Qpid Proton is a high-performance, lightweight messaging library. It can be
 used in the widest range of messaging applications, including brokers, client
 libraries, routers, bridges, proxies, and more. Proton makes it trivial to


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


[37/50] [abbrv] qpid-proton git commit: NO-JIRA: Remove SSL autodetect protocol hack which is no longer necessary - Add API to get ssf from SSL layer - Wired up pn_ssl_domain_allow_unsecured() (to pn_transport_require_encryption() functionality)

Posted by ac...@apache.org.
NO-JIRA: Remove SSL autodetect protocol hack which is no longer necessary
- Add API to get ssf from SSL layer
- Wired up pn_ssl_domain_allow_unsecured()
  (to pn_transport_require_encryption() functionality)


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/a3fc3ffa
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/a3fc3ffa
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/a3fc3ffa

Branch: refs/heads/cjansen-cpp-client
Commit: a3fc3ffa297626daf9e672a427277cc8d5c4db91
Parents: 3bd4aba
Author: Andrew Stitcher <as...@apache.org>
Authored: Tue May 26 15:31:38 2015 -0400
Committer: Andrew Stitcher <as...@apache.org>
Committed: Tue May 26 15:31:38 2015 -0400

----------------------------------------------------------------------
 proton-c/include/proton/ssl.h         |  7 +++++++
 proton-c/src/engine/engine-internal.h |  1 -
 proton-c/src/ssl/openssl.c            | 14 ++++++++++++--
 proton-c/src/ssl/ssl-internal.h       |  2 --
 proton-c/src/ssl/ssl_stub.c           |  5 +++++
 proton-c/src/transport/transport.c    | 25 +++++--------------------
 proton-c/src/windows/schannel.c       | 20 ++++++++++++++++++--
 7 files changed, 47 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a3fc3ffa/proton-c/include/proton/ssl.h
----------------------------------------------------------------------
diff --git a/proton-c/include/proton/ssl.h b/proton-c/include/proton/ssl.h
index 87e7025..b250e6a 100644
--- a/proton-c/include/proton/ssl.h
+++ b/proton-c/include/proton/ssl.h
@@ -257,6 +257,13 @@ PN_EXTERN int pn_ssl_init( pn_ssl_t *ssl,
  */
 PN_EXTERN bool pn_ssl_get_cipher_name(pn_ssl_t *ssl, char *buffer, size_t size);
 
+/** Get the SSF (security strength factor) of the Cipher that is currently in use.
+ *
+ * @param[in] ssl the ssl client/server to query.
+ * @return the ssf, note that 0 means no security.
+ */
+PN_EXTERN int pn_ssl_get_ssf(pn_ssl_t *ssl);
+
 /** Get the name of the SSL protocol that is currently in use.
  *
  * Gets a text description of the SSL protocol that is currently active, or returns FALSE if SSL

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a3fc3ffa/proton-c/src/engine/engine-internal.h
----------------------------------------------------------------------
diff --git a/proton-c/src/engine/engine-internal.h b/proton-c/src/engine/engine-internal.h
index 4b24a02..2f0cc56 100644
--- a/proton-c/src/engine/engine-internal.h
+++ b/proton-c/src/engine/engine-internal.h
@@ -194,7 +194,6 @@ struct pn_transport_t {
   bool auth_required;
   bool authenticated;
   bool encryption_required;
-  bool encrypted;
 
   bool referenced;
 };

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a3fc3ffa/proton-c/src/ssl/openssl.c
----------------------------------------------------------------------
diff --git a/proton-c/src/ssl/openssl.c b/proton-c/src/ssl/openssl.c
index 02a16fc..52eac01 100644
--- a/proton-c/src/ssl/openssl.c
+++ b/proton-c/src/ssl/openssl.c
@@ -718,6 +718,10 @@ int pn_ssl_init(pn_ssl_t *ssl0, pn_ssl_domain_t *domain, const char *session_id)
   if (session_id && domain->mode == PN_SSL_MODE_CLIENT)
     ssl->session_id = pn_strdup(session_id);
 
+  // If SSL doesn't specifically allow skipping encryption, require SSL
+  // TODO: This is a probably a stop-gap until allow_unsecured is removed
+  if (!domain->allow_unsecured) transport->encryption_required = true;
+
   return init_ssl_socket(transport, ssl);
 }
 
@@ -733,9 +737,15 @@ int pn_ssl_domain_allow_unsecured_client(pn_ssl_domain_t *domain)
   return 0;
 }
 
-bool pn_ssl_allow_unsecured(pn_transport_t *transport)
+int pn_ssl_get_ssf(pn_ssl_t *ssl0)
 {
-  return transport && transport->ssl && transport->ssl->domain && transport->ssl->domain->allow_unsecured;
+  const SSL_CIPHER *c;
+
+  pni_ssl_t *ssl = get_ssl_internal(ssl0);
+  if (ssl && ssl->ssl && (c = SSL_get_current_cipher( ssl->ssl ))) {
+    return SSL_CIPHER_get_bits(c, NULL);
+  }
+  return 0;
 }
 
 bool pn_ssl_get_cipher_name(pn_ssl_t *ssl0, char *buffer, size_t size )

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a3fc3ffa/proton-c/src/ssl/ssl-internal.h
----------------------------------------------------------------------
diff --git a/proton-c/src/ssl/ssl-internal.h b/proton-c/src/ssl/ssl-internal.h
index 3d9e163..d3205ea 100644
--- a/proton-c/src/ssl/ssl-internal.h
+++ b/proton-c/src/ssl/ssl-internal.h
@@ -33,6 +33,4 @@
 // release the SSL context
 void pn_ssl_free(pn_transport_t *transport);
 
-bool pn_ssl_allow_unsecured(pn_transport_t *transport);
-
 #endif /* ssl-internal.h */

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a3fc3ffa/proton-c/src/ssl/ssl_stub.c
----------------------------------------------------------------------
diff --git a/proton-c/src/ssl/ssl_stub.c b/proton-c/src/ssl/ssl_stub.c
index 4749d0c..f504a79 100644
--- a/proton-c/src/ssl/ssl_stub.c
+++ b/proton-c/src/ssl/ssl_stub.c
@@ -142,3 +142,8 @@ const char* pn_ssl_get_remote_subject(pn_ssl_t *ssl)
 {
   return NULL;
 }
+
+int pn_ssl_get_ssf(pn_ssl_t *ssl)
+{
+  return 0;
+}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a3fc3ffa/proton-c/src/transport/transport.c
----------------------------------------------------------------------
diff --git a/proton-c/src/transport/transport.c b/proton-c/src/transport/transport.c
index c0269d9..e72875b 100644
--- a/proton-c/src/transport/transport.c
+++ b/proton-c/src/transport/transport.c
@@ -180,22 +180,13 @@ static void pn_io_layer_setup(pn_transport_t *transport, unsigned int layer)
 {
   assert(layer == 0);
   // Figure out if we are server or not
-  if (transport->server)
-  {
-    // XXX: This is currently a large hack to work around the SSL
-    // code not handling a connection error before being set up fully
-    if (transport->ssl && pn_ssl_allow_unsecured(transport)) {
+  if (transport->server) {
       transport->io_layers[layer++] = &pni_autodetect_layer;
       return;
-    }
   }
   if (transport->ssl) {
     transport->io_layers[layer++] = &ssl_layer;
   }
-  if (transport->server) {
-    transport->io_layers[layer++] = &pni_autodetect_layer;
-    return;
-  }
   if (transport->sasl) {
     transport->io_layers[layer++] = &sasl_header_layer;
   }
@@ -261,21 +252,18 @@ ssize_t pn_io_layer_input_autodetect(pn_transport_t *transport, unsigned int lay
         pn_transport_logf(transport, "  <- %s", "SASL");
     return 8;
   case PNI_PROTOCOL_AMQP1:
-    if (!transport->authenticated && transport->auth_required) {
+    if (transport->auth_required && !pn_transport_is_authenticated(transport)) {
       pn_do_error(transport, "amqp:connection:policy-error",
                   "Client skipped authentication - forbidden");
       pn_set_error_layer(transport);
       return 8;
     }
-// TODO: Encrypted connection detection not implemented yet
-#if 0
-    if (!transport->encrypted && transport->encryption_required) {
+    if (transport->encryption_required && !pn_transport_is_encrypted(transport)) {
       pn_do_error(transport, "amqp:connection:policy-error",
                   "Client connection unencryted - forbidden");
       pn_set_error_layer(transport);
       return 8;
     }
-#endif
     transport->io_layers[layer] = &amqp_write_header_layer;
     if (transport->trace & PN_TRACE_FRM)
         pn_transport_logf(transport, "  <- %s", "AMQP");
@@ -408,7 +396,6 @@ static void pn_transport_initialize(void *object)
   transport->auth_required = false;
   transport->authenticated = false;
   transport->encryption_required = false;
-  transport->encrypted = false;
 
   transport->referenced = true;
 
@@ -526,8 +513,7 @@ void pn_transport_require_auth(pn_transport_t *transport, bool required)
 
 bool pn_transport_is_authenticated(pn_transport_t *transport)
 {
-  assert(transport);
-  return transport->authenticated;
+  return transport && transport->authenticated;
 }
 
 void pn_transport_require_encryption(pn_transport_t *transport, bool required)
@@ -538,8 +524,7 @@ void pn_transport_require_encryption(pn_transport_t *transport, bool required)
 
 bool pn_transport_is_encrypted(pn_transport_t *transport)
 {
-    assert(transport);
-    return transport->encrypted;
+    return transport && transport->ssl && pn_ssl_get_ssf((pn_ssl_t*)transport)>0;
 }
 
 void pn_transport_free(pn_transport_t *transport)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/a3fc3ffa/proton-c/src/windows/schannel.c
----------------------------------------------------------------------
diff --git a/proton-c/src/windows/schannel.c b/proton-c/src/windows/schannel.c
index 78d05bf..757a108 100644
--- a/proton-c/src/windows/schannel.c
+++ b/proton-c/src/windows/schannel.c
@@ -409,6 +409,8 @@ static void ssl_session_free( pn_ssl_session_t *ssn)
 
 /** Public API - visible to application code */
 
+// TODO: This should really return true as SSL is fully implemented,
+// but the tests currently fail because the fixed certificates aren't usable on windows
 bool pn_ssl_present(void)
 {
   return false;
@@ -612,6 +614,10 @@ int pn_ssl_init(pn_ssl_t *ssl0, pn_ssl_domain_t *domain, const char *session_id)
   if (session_id && domain->mode == PN_SSL_MODE_CLIENT)
     ssl->session_id = pn_strdup(session_id);
 
+  // If SSL doesn't specifically allow skipping encryption, require SSL
+  // TODO: This is a probably a stop-gap until allow_unsecured is removed
+  if (!domain->allow_unsecured) transport->encryption_required = true;
+
   ssl->cred = domain->cred;
   pn_incref(domain->cred);
 
@@ -641,9 +647,19 @@ int pn_ssl_domain_allow_unsecured_client(pn_ssl_domain_t *domain)
 }
 
 
-bool pn_ssl_allow_unsecured(pn_transport_t *transport)
+// TODO: This is just an untested guess
+int pn_ssl_get_ssf(pn_ssl_t *ssl0)
 {
-  return transport && transport->ssl && transport->ssl->domain && transport->ssl->domain->allow_unsecured;
+  SecPkgContext_ConnectionInfo info;
+
+  pni_ssl_t *ssl = get_ssl_internal(ssl0);
+  if (ssl &&
+      ssl->state == RUNNING &&
+      SecIsValidHandle(&ssl->ctxt_handle) &&
+      QueryContextAttributes(&ssl->ctxt_handle, SECPKG_ATTR_CONNECTION_INFO, &info) == SEC_E_OK) {
+    return info.dwCipherStrength;
+  }
+  return 0;
 }
 
 bool pn_ssl_get_cipher_name(pn_ssl_t *ssl0, char *buffer, size_t size )


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


[05/50] [abbrv] qpid-proton git commit: fixed version and launcher scripts

Posted by ac...@apache.org.
fixed version and launcher scripts


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/196ef80b
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/196ef80b
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/196ef80b

Branch: refs/heads/cjansen-cpp-client
Commit: 196ef80bc331b94a1e538ab5292263c76b145528
Parents: c8f2d8a
Author: Rafael Schloming <rh...@alum.mit.edu>
Authored: Mon May 11 10:11:39 2015 -0400
Committer: Rafael Schloming <rh...@alum.mit.edu>
Committed: Mon May 11 10:11:39 2015 -0400

----------------------------------------------------------------------
 examples/engine/java/drain   | 2 +-
 examples/engine/java/pom.xml | 2 +-
 examples/engine/java/server  | 2 +-
 examples/engine/java/spout   | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/196ef80b/examples/engine/java/drain
----------------------------------------------------------------------
diff --git a/examples/engine/java/drain b/examples/engine/java/drain
index 7c54787..1f8095e 100755
--- a/examples/engine/java/drain
+++ b/examples/engine/java/drain
@@ -1,2 +1,2 @@
 #!/bin/bash
-mvn -q -e exec:java -Dexec.mainClass=org.apache.qpid.proton.examples.Drain -Dexec.args="$@"
+mvn -q -e exec:java -Dexec.mainClass=org.apache.qpid.proton.examples.Drain -Dexec.args="$*"

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/196ef80b/examples/engine/java/pom.xml
----------------------------------------------------------------------
diff --git a/examples/engine/java/pom.xml b/examples/engine/java/pom.xml
index 3fc355d..c904212 100644
--- a/examples/engine/java/pom.xml
+++ b/examples/engine/java/pom.xml
@@ -19,7 +19,7 @@
   <parent>
     <groupId>org.apache.qpid</groupId>
     <artifactId>proton-project</artifactId>
-    <version>1.0-SNAPSHOT</version>
+    <version>0.10-SNAPSHOT</version>
   </parent>
   <modelVersion>4.0.0</modelVersion>
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/196ef80b/examples/engine/java/server
----------------------------------------------------------------------
diff --git a/examples/engine/java/server b/examples/engine/java/server
index 37a9aa4..8421d79 100755
--- a/examples/engine/java/server
+++ b/examples/engine/java/server
@@ -1,2 +1,2 @@
 #!/bin/bash
-mvn -q -e exec:java -Dexec.mainClass=org.apache.qpid.proton.examples.Server -Dexec.args="$@"
+mvn -q -e exec:java -Dexec.mainClass=org.apache.qpid.proton.examples.Server -Dexec.args="$*"

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/196ef80b/examples/engine/java/spout
----------------------------------------------------------------------
diff --git a/examples/engine/java/spout b/examples/engine/java/spout
index bd83842..c473cac 100755
--- a/examples/engine/java/spout
+++ b/examples/engine/java/spout
@@ -1,2 +1,2 @@
 #!/bin/bash
-mvn -q -e exec:java -Dexec.mainClass=org.apache.qpid.proton.examples.Spout -Dexec.args="$@"
+mvn -q -e exec:java -Dexec.mainClass=org.apache.qpid.proton.examples.Spout -Dexec.args="$*"


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


[21/50] [abbrv] qpid-proton git commit: PROTON-860: store ssl_domain pointer as PN_VOID

Posted by ac...@apache.org.
PROTON-860: store ssl_domain pointer as PN_VOID


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/d4437729
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/d4437729
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/d4437729

Branch: refs/heads/cjansen-cpp-client
Commit: d4437729d5b3bed6209f01aa52629574142e14e4
Parents: 995e00d
Author: Gordon Sim <gs...@redhat.com>
Authored: Thu May 14 15:04:23 2015 +0100
Committer: Gordon Sim <gs...@redhat.com>
Committed: Thu May 14 15:04:23 2015 +0100

----------------------------------------------------------------------
 proton-c/src/reactor/acceptor.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d4437729/proton-c/src/reactor/acceptor.c
----------------------------------------------------------------------
diff --git a/proton-c/src/reactor/acceptor.c b/proton-c/src/reactor/acceptor.c
index 31fa0cc..819af8e 100644
--- a/proton-c/src/reactor/acceptor.c
+++ b/proton-c/src/reactor/acceptor.c
@@ -92,6 +92,6 @@ void pn_acceptor_set_ssl_domain(pn_acceptor_t *acceptor, pn_ssl_domain_t *domain
 {
   pn_selectable_t *sel = (pn_selectable_t *) acceptor;
   pn_record_t *record = pn_selectable_attachments(sel);
-  pn_record_def(record, PNI_ACCEPTOR_SSL_DOMAIN, PN_WEAKREF);
+  pn_record_def(record, PNI_ACCEPTOR_SSL_DOMAIN, PN_VOID);
   pn_record_set(record, PNI_ACCEPTOR_SSL_DOMAIN, domain);
 }


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


[28/50] [abbrv] qpid-proton git commit: PROTON-861: add dummy impl method to ssl stub

Posted by ac...@apache.org.
PROTON-861: add dummy impl method to ssl stub


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/37fc7be5
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/37fc7be5
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/37fc7be5

Branch: refs/heads/cjansen-cpp-client
Commit: 37fc7be58fa518961aca4a8da1dcd64c7c83a804
Parents: cb6c172
Author: Gordon Sim <gs...@redhat.com>
Authored: Fri May 15 19:43:49 2015 +0100
Committer: Gordon Sim <gs...@redhat.com>
Committed: Fri May 15 19:44:14 2015 +0100

----------------------------------------------------------------------
 proton-c/src/ssl/ssl_stub.c | 5 +++++
 1 file changed, 5 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/37fc7be5/proton-c/src/ssl/ssl_stub.c
----------------------------------------------------------------------
diff --git a/proton-c/src/ssl/ssl_stub.c b/proton-c/src/ssl/ssl_stub.c
index cea5dc4..4749d0c 100644
--- a/proton-c/src/ssl/ssl_stub.c
+++ b/proton-c/src/ssl/ssl_stub.c
@@ -137,3 +137,8 @@ int pn_ssl_get_peer_hostname( pn_ssl_t *ssl, char *hostname, size_t *bufsize )
 {
   return -1;
 }
+
+const char* pn_ssl_get_remote_subject(pn_ssl_t *ssl)
+{
+  return NULL;
+}


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


[30/50] [abbrv] qpid-proton git commit: PROTON-885: update the top-level license file

Posted by ac...@apache.org.
PROTON-885: update the top-level license file


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/59afc558
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/59afc558
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/59afc558

Branch: refs/heads/cjansen-cpp-client
Commit: 59afc5588f0203b427f22b4f9486d27af5cdaa9e
Parents: 2e2ba9c
Author: Ken Giusti <kg...@apache.org>
Authored: Fri May 15 17:17:09 2015 -0400
Committer: Ken Giusti <kg...@apache.org>
Committed: Fri May 15 17:17:09 2015 -0400

----------------------------------------------------------------------
 LICENSE | 5 +++++
 1 file changed, 5 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/59afc558/LICENSE
----------------------------------------------------------------------
diff --git a/LICENSE b/LICENSE
index 4956407..6d1be4d 100644
--- a/LICENSE
+++ b/LICENSE
@@ -207,3 +207,8 @@ PROTON SUBCOMPONENTS:
 Proton includes freegetopt with a separate BSD license.  Your use
 of the source code for freegetopt is subject to the terms and
 conditions of its license in examples/include/pncompat/internal/LICENSE.
+
+The python bindings includes files derived by PyZMQ an are licensed
+with a separate Modified BSD license.  Use of the source code in these
+files are subject to the terms and conditions in the license:
+proton-c/bindings/python/PYZMQ_LICENSE.BSD.


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


[11/50] [abbrv] qpid-proton git commit: PROTON-868: More general name for bytes to be output by SASL code

Posted by ac...@apache.org.
PROTON-868: More general name for bytes to be output by SASL code


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/89005004
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/89005004
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/89005004

Branch: refs/heads/cjansen-cpp-client
Commit: 89005004824f22c5fb05897901de183b9b16268a
Parents: 57f8273
Author: Andrew Stitcher <as...@apache.org>
Authored: Tue May 12 14:41:10 2015 -0400
Committer: Andrew Stitcher <as...@apache.org>
Committed: Tue May 12 14:41:10 2015 -0400

----------------------------------------------------------------------
 proton-c/src/sasl/cyrus_sasl.c    | 16 ++++++++--------
 proton-c/src/sasl/none_sasl.c     | 12 ++++++------
 proton-c/src/sasl/sasl-internal.h |  2 +-
 proton-c/src/sasl/sasl.c          |  6 +++---
 4 files changed, 18 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/89005004/proton-c/src/sasl/cyrus_sasl.c
----------------------------------------------------------------------
diff --git a/proton-c/src/sasl/cyrus_sasl.c b/proton-c/src/sasl/cyrus_sasl.c
index 7ab7379..1b3caf0 100644
--- a/proton-c/src/sasl/cyrus_sasl.c
+++ b/proton-c/src/sasl/cyrus_sasl.c
@@ -145,8 +145,8 @@ static int pni_wrap_client_start(pni_sasl_t *sasl, const char *mechs, const char
         }
     } while (result==SASL_INTERACT);
 
-    sasl->cyrus_out.start = out;
-    sasl->cyrus_out.size = outlen;
+    sasl->bytes_out.start = out;
+    sasl->bytes_out.size = outlen;
     return result;
 }
 
@@ -188,8 +188,8 @@ static int pni_wrap_client_step(pni_sasl_t *sasl, const pn_bytes_t *in)
         }
     } while (result==SASL_INTERACT);
 
-    sasl->cyrus_out.start = out;
-    sasl->cyrus_out.size = outlen;
+    sasl->bytes_out.start = out;
+    sasl->bytes_out.size = outlen;
     return result;
 }
 
@@ -275,8 +275,8 @@ static int pni_wrap_server_start(pni_sasl_t *sasl, const char *mech_selected, co
                                in_bytes, in_size,
                                &out, &outlen);
 
-    sasl->cyrus_out.start = out;
-    sasl->cyrus_out.size = outlen;
+    sasl->bytes_out.start = out;
+    sasl->bytes_out.size = outlen;
     return result;
 }
 
@@ -345,8 +345,8 @@ static int pni_wrap_server_step(pni_sasl_t *sasl, const pn_bytes_t *in)
                               in->start, in->size,
                               &out, &outlen);
 
-    sasl->cyrus_out.start = out;
-    sasl->cyrus_out.size = outlen;
+    sasl->bytes_out.start = out;
+    sasl->bytes_out.size = outlen;
     return result;
 }
 

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/89005004/proton-c/src/sasl/none_sasl.c
----------------------------------------------------------------------
diff --git a/proton-c/src/sasl/none_sasl.c b/proton-c/src/sasl/none_sasl.c
index 663c3a1..9e3de1d 100644
--- a/proton-c/src/sasl/none_sasl.c
+++ b/proton-c/src/sasl/none_sasl.c
@@ -65,8 +65,8 @@ bool pni_process_mechanisms(pn_transport_t *transport, const char *mechs)
     memmove(iresp + 1, transport->sasl->username, usize);
     iresp[usize + 1] = 0;
     memmove(iresp + usize + 2, transport->sasl->password, psize);
-    transport->sasl->cyrus_out.start = iresp;
-    transport->sasl->cyrus_out.size =  size;
+    transport->sasl->bytes_out.start = iresp;
+    transport->sasl->bytes_out.size =  size;
 
     // Zero out password and dealloc
     free(memset(transport->sasl->password, 0, psize));
@@ -89,12 +89,12 @@ bool pni_process_mechanisms(pn_transport_t *transport, const char *mechs)
       transport->sasl->impl_context = iresp;
 
       memmove(iresp, transport->sasl->username, size);
-      transport->sasl->cyrus_out.start = iresp;
-      transport->sasl->cyrus_out.size =  size;
+      transport->sasl->bytes_out.start = iresp;
+      transport->sasl->bytes_out.size =  size;
     } else {
       static const char anon[] = "anonymous";
-      transport->sasl->cyrus_out.start = anon;
-      transport->sasl->cyrus_out.size =  sizeof anon-1;
+      transport->sasl->bytes_out.start = anon;
+      transport->sasl->bytes_out.size =  sizeof anon-1;
     }
     return true;
   }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/89005004/proton-c/src/sasl/sasl-internal.h
----------------------------------------------------------------------
diff --git a/proton-c/src/sasl/sasl-internal.h b/proton-c/src/sasl/sasl-internal.h
index 19fc7ce..956d4af 100644
--- a/proton-c/src/sasl/sasl-internal.h
+++ b/proton-c/src/sasl/sasl-internal.h
@@ -64,7 +64,7 @@ struct pni_sasl_t {
   char *config_dir;
   const char *remote_fqdn;
   pn_sasl_outcome_t outcome;
-  pn_bytes_t cyrus_out;
+  pn_bytes_t bytes_out;
   enum pni_sasl_state desired_state;
   enum pni_sasl_state last_state;
   bool client;

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/89005004/proton-c/src/sasl/sasl.c
----------------------------------------------------------------------
diff --git a/proton-c/src/sasl/sasl.c b/proton-c/src/sasl/sasl.c
index 4a2a2f0..f32e255 100644
--- a/proton-c/src/sasl/sasl.c
+++ b/proton-c/src/sasl/sasl.c
@@ -287,7 +287,7 @@ void pni_sasl_set_desired_state(pn_transport_t *transport, enum pni_sasl_state d
 static void pni_post_sasl_frame(pn_transport_t *transport)
 {
   pni_sasl_t *sasl = transport->sasl;
-  pn_bytes_t out = sasl->cyrus_out;
+  pn_bytes_t out = sasl->bytes_out;
   enum pni_sasl_state desired_state = sasl->desired_state;
   while (sasl->desired_state > sasl->last_state) {
     switch (desired_state) {
@@ -369,8 +369,8 @@ pn_sasl_t *pn_sasl(pn_transport_t *transport)
     sasl->remote_fqdn = NULL;
     sasl->outcome = PN_SASL_NONE;
     sasl->impl_context = NULL;
-    sasl->cyrus_out.size = 0;
-    sasl->cyrus_out.start = NULL;
+    sasl->bytes_out.size = 0;
+    sasl->bytes_out.start = NULL;
     sasl->desired_state = SASL_NONE;
     sasl->last_state = SASL_NONE;
     sasl->input_bypass = false;


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


[14/50] [abbrv] qpid-proton git commit: PROTON-827: Moved go binding work to branch `go`

Posted by ac...@apache.org.
PROTON-827: Moved go binding work to branch `go`

Go binding removed from master, available on branch `go`.

master still has bindings/go/README.md with a pointer to the branch, so people
following old discussions can find it.


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/132820cb
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/132820cb
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/132820cb

Branch: refs/heads/cjansen-cpp-client
Commit: 132820cb5910f0bbe3c9ac4f702b04b4eb0051d0
Parents: 460c787
Author: Alan Conway <ac...@redhat.com>
Authored: Tue May 12 19:01:10 2015 -0400
Committer: Alan Conway <ac...@redhat.com>
Committed: Tue May 12 19:01:10 2015 -0400

----------------------------------------------------------------------
 proton-c/bindings/go/README.md                  | 197 +----
 proton-c/bindings/go/WARNING_EXPERIMENTAL       |   1 -
 proton-c/bindings/go/src/Makefile               |  16 -
 proton-c/bindings/go/src/genwrap.go             | 423 -----------
 .../go/src/qpid.apache.org/proton/doc.go        |  40 -
 .../go/src/qpid.apache.org/proton/event/doc.go  |  38 -
 .../qpid.apache.org/proton/event/handlers.go    | 411 -----------
 .../src/qpid.apache.org/proton/event/message.go |  75 --
 .../go/src/qpid.apache.org/proton/event/pump.go | 357 ---------
 .../qpid.apache.org/proton/event/wrappers.go    | 253 -------
 .../proton/event/wrappers_gen.go                | 732 -------------------
 .../qpid.apache.org/proton/internal/error.go    | 125 ----
 .../src/qpid.apache.org/proton/interop_test.go  | 308 --------
 .../go/src/qpid.apache.org/proton/marshal.go    | 238 ------
 .../go/src/qpid.apache.org/proton/message.go    | 342 ---------
 .../src/qpid.apache.org/proton/message_test.go  |  90 ---
 .../src/qpid.apache.org/proton/messaging/doc.go |  28 -
 .../proton/messaging/example_test.go            | 268 -------
 .../qpid.apache.org/proton/messaging/handler.go |  70 --
 .../proton/messaging/messaging.go               | 250 -------
 .../go/src/qpid.apache.org/proton/types.go      | 193 -----
 .../go/src/qpid.apache.org/proton/uid.go        |  40 -
 .../go/src/qpid.apache.org/proton/unmarshal.go  | 552 --------------
 .../go/src/qpid.apache.org/proton/url.go        |  96 ---
 .../go/src/qpid.apache.org/proton/url_test.go   |  51 --
 25 files changed, 3 insertions(+), 5191 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/132820cb/proton-c/bindings/go/README.md
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/README.md b/proton-c/bindings/go/README.md
index a70aa2c..9fd0a0f 100644
--- a/proton-c/bindings/go/README.md
+++ b/proton-c/bindings/go/README.md
@@ -1,196 +1,5 @@
 # *EXPERIMENTAL* Go binding for proton
 
-This is the beginning of a [Go](http://golang.org) binding for proton.
-
-This work is in early *experimental* stages, *everything* may change in future.
-Comments and contributions are strongly encouraged, this experiment is public so
-early feedback can guide development.
-
-- Email <pr...@qpid.apache.org>
-- Create issues <https://issues.apache.org/jira/browse/PROTON>, attach patches to an issue.
-
-## Goals
-
-The API should
-
-- be idiomatic, unsurprising, and easy to use for Go developers.
-- support client and server development.
-- make simple tasks simple.
-- provide deep access to AMQP protocol when that is required.
-
-There are two types of developer we want to support
-
-1. Go developers using AMQP as a message transport:
-   - Straightforward conversions between Go built-in types and AMQP types.
-   - Easy message exchange via Go channels to support use in goroutines.
-
-2. AMQP-aware developers using Go as an implementation language:
-   - Go types to exactly represent all AMQP types and encoding details.
-   - Full access to detailed AMQP concepts: sessions, links, deliveries etc.
-
-## Status
-
-Package proton encodes and decodes AMQP messages and data as Go types.
-
-Sub-packages 'event' and 'messaging' provide two alternative ways to write
-AMQP clients and servers. 'messaging' is easier for general purpose use. 'event'
-gives complete low-level control of the underlying proton C engine.
-
-The event package is fairly complete, with the exception of the proton
-reactor. It's unclear if the reactor is important for go.
-
-The messaging package is just starting. The examples work but anything else might not.
-
-There are working [examples](../../../examples/go) of a broker, sender and receiver.
-
-## The event driven API
-
-See the package documentation for details.
-
-## The Go API
-
-The goal: A procedural API that allows any user goroutine to send and receive
-AMQP messages and other information (acknowledgments, flow control instructions
-etc.) using channels. There will be no user-visible locks and no need to run
-user code in special goroutines, e.g. as handlers in a proton event loop.
-
-See the package documentation for emerging details.
-
-Currently using a channel to receive messages, a function to send them (channels
-internally) and a channel as a "future" for acknowledgements to senders. This
-may change.
-
-## Design Questions
-
-
-1. Error reporting and handling, esp. async. errors:
-
-What are common patterns for handling errors across channels?  I.e. the thing at
-one end of the channel blows up, how do you tell the other end?
-
-readers: you can close the channel, but there's no error info. You could pass a
-struct { data, error } or use a second channel. Pros & cons?
-
-writers: you can't close without a panic so you need a second channel.  Is this
-a normal pattern:
-
-    select {
-        data -> sendChan: sentit()
-        err := <- errChan: oops(err)
-    }
-
-2. Use of channels:
-
-I recently saw an interesting Go tip: "Make your API synchronous because in Go
-it is simple to make a sync call async by putting it in a goroutine."
-
-What are the tradeoffs of exposing channels directly in the API vs. hiding them
-behind methods? Exposing lets users select directly, less overhead than starting
-a goroutine, creating MORE channels and selecting those. Hiding lets us wrap
-patterns like the 'select {data, err}' pattern above, which is easier and less
-error prone than asking users to do it themselves.
-
-The standard net.Conn uses blocking methods, not channels. I did as the tip says
-and wrapped them in goroutines and channels. The library does expose *read*
-channels e.g. time.After. Are there any *write* channels in the standard
-library? I note that time.After has no errors, and suspect that may be a key
-factor in the descison.
-
-3. The "future" pattern for acknowledgements: super easy in Go but depends on 1. and 2. above.
-
-## Why a separate API for Go?
-
-Go is a concurrent language and encourages applications to be divided into
-concurrent *goroutines*. It provides traditional locking but it encourages the
-use *channels* to communicate between goroutines without explicit locks:
-
-  "Share memory by communicating, don't communicate by sharing memory"
-
-The idea is that a given value is only operated on by one goroutine at a time,
-but values can easily be passed from one goroutine to another. This removes much
-of the need for locking.
-
-Go literature distinguishes between:
-
-- *concurrency*: "keeping track of things that could be done in parallel"
-- *parallelism*: "actually doing things in parallel"
-
-The application expresses concurrency by starting goroutines for potentially
-concurrent tasks. The Go run-times schedule the activity of goroutines onto a
-small number (possibly one) of actual parallel executions.
-
-Even with *no* parallelism, concurrency lets the Go run-times *order* work with
-respect to events like file descriptors being readable/writable, channels having
-data, timers firing etc. Go automatically takes care of switching out goroutines
-that block or sleep so it is normal to write code in terms of blocking calls.
-
-Event-driven API (like poll, epoll, select or the proton event API) also
-channel unpredictably ordered events to actions in one or a small pool of
-execution threads. However this requires a different style of programming:
-"event-driven" or "reactive" programming. Go developers call it "inside-out"
-programming. In an event-driven architecture blocking is a big problem as it
-consumes a scarce thread of execution, so actions that take time to complete
-have to be re-structured in terms of future event delivery.
-
-The promise of Go is that you can express your application in concurrent,
-procedural terms with simple blocking calls and the Go run-times will turn it
-inside-out for you. Write as many goroutines as you want, and let Go interleave
-and schedule them efficiently.
-
-For example: the Go equivalent of listening for connections is a goroutine with
-a simple endless loop that calls a blocking Listen() function and starts a
-goroutine for each new connection. Each connection has its own goroutine that
-deals with just that connection till it closes.
-
-The benefit is that the variables and logic live closer together. Once you're in
-a goroutine, you have everything you need in local variables, and they are
-preserved across blocking calls. There's no need to store details in context
-objects that you have to look up when handling a later event to figure out how
-to continue where you left off.
-
-So a Go-like proton API does not force the users code to run in an event-loop
-goroutine. Instead user goroutines communicate with the event loop(s) via
-channels.  There's no need to funnel connections into one event loop, in fact it
-makes no sense.  Connections can be processed concurrently so they should be
-processed in separate goroutines and left to Go to schedule. User goroutines can
-have simple loops that block channels till messages are available, the user can
-start as many or as few such goroutines as they wish to implement concurrency as
-simple or as complex as they wish. For example blocking request-response
-vs. asynchronous flows of messages and acknowledgments.
-
-
-## Layout
-
-This directory is a [Go work-space](http://golang.org/doc/code.html), it is not
-yet connected to the rest of the proton build.
-
-To experiment, install proton in a standard place or set these environment
-variables: `PATH`, `C_INCLUDE_PATH`, `LIBRARY_PATH` and `LD_LIBRARY_PATH`.
-
-Add this directory to `GOPATH` for the Go tools.
-
-To see the docs as text:
-
-    godoc apache.org/proton
-
-To see them in your browser run this in the background and open
-http://localhost:6060 in your browser:
-
-    godoc -http=:6060 -index=true&
-
-Click "Packages" and "proton" to see the proton docs. It takes a minute or two
-to generate the index so search may not work immediately.
-
-To run the unit tests:
-
-    go test -a apache.org/proton
-
-## New to Go?
-
-If you are new to Go then these are a good place to start:
-
-- [A Tour of Go](http://tour.golang.org)
-- [Effective Go](http://golang.org/doc/effective_go.html)
-
-Then look at the tools and library docs at <http://golang.org> as you need them.
-
+Experimental work on the Go language binding has been moved to the `go` branch
+until it is ready for use. You can `git checkout go` on your git clone, or
+browse at https://github.com/apache/qpid-proton/blob/go/proton-c/bindings/go/README.md

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/132820cb/proton-c/bindings/go/WARNING_EXPERIMENTAL
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/WARNING_EXPERIMENTAL b/proton-c/bindings/go/WARNING_EXPERIMENTAL
deleted file mode 100644
index 96dc92f..0000000
--- a/proton-c/bindings/go/WARNING_EXPERIMENTAL
+++ /dev/null
@@ -1 +0,0 @@
-See README.md

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/132820cb/proton-c/bindings/go/src/Makefile
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/Makefile b/proton-c/bindings/go/src/Makefile
deleted file mode 100644
index 98baa4c..0000000
--- a/proton-c/bindings/go/src/Makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-# FIXME aconway 2015-04-09: integrate with cmake
-
-#GOFLAGS=-compiler gccgo -gccgoflags "-g -O0"
-#GOFLAGS=-gcflags "-N -l"
-
-GENERATED=qpid.apache.org/proton/event/wrappers_gen.go
-
-test: $(GENERATED)
-	go test -v $(TESTFLAGS) $(GOFLAGS) qpid.apache.org/proton
-	go test -v $(TESTFLAGS) $(GOFLAGS) qpid.apache.org/proton/event
-	go test -v $(TESTFLAGS) $(GOFLAGS) qpid.apache.org/proton/messaging
-
-$(GENERATED): genwrap.go ../../../include/proton/*.h
-	go run genwrap.go
-
-

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/132820cb/proton-c/bindings/go/src/genwrap.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/genwrap.go b/proton-c/bindings/go/src/genwrap.go
deleted file mode 100644
index e34c045..0000000
--- a/proton-c/bindings/go/src/genwrap.go
+++ /dev/null
@@ -1,423 +0,0 @@
-/*
-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.
-*/
-
-// Code generator to generate a think Go wrapper API around the C proton API.
-//
-
-package main
-
-import (
-	"fmt"
-	"io"
-	"io/ioutil"
-	"os"
-	"os/exec"
-	"path"
-	"regexp"
-	"strings"
-	"text/template"
-)
-
-func mixedCase(s string) string {
-	result := ""
-	for _, w := range strings.Split(s, "_") {
-		if w != "" {
-			result = result + strings.ToUpper(w[0:1]) + strings.ToLower(w[1:])
-		}
-	}
-	return result
-}
-
-func mixedCaseTrim(s, prefix string) string {
-	return mixedCase(strings.TrimPrefix(s, prefix))
-}
-
-var templateFuncs = template.FuncMap{"mixedCase": mixedCase, "mixedCaseTrim": mixedCaseTrim}
-
-func doTemplate(out io.Writer, data interface{}, tmpl string) {
-	panicIf(template.Must(template.New("").Funcs(templateFuncs).Parse(tmpl)).Execute(out, data))
-}
-
-type enumType struct {
-	Name   string
-	Values []string
-}
-
-// Find enums in a header file return map of enum name to values.
-func findEnums(header string) (enums []enumType) {
-	for _, enum := range enumDefRe.FindAllStringSubmatch(header, -1) {
-		enums = append(enums, enumType{enum[2], enumValRe.FindAllString(enum[1], -1)})
-	}
-	return enums
-}
-
-func genEnum(out io.Writer, name string, values []string) {
-	doTemplate(out, []interface{}{name, values}, `{{$enumName := index . 0}}{{$values := index . 1}}
-type {{mixedCase $enumName}} C.pn_{{$enumName}}_t
-const ({{range $values}}
-	{{mixedCase .}} {{mixedCase $enumName}} = C.{{.}} {{end}}
-)
-
-func (e {{mixedCase $enumName}}) String() string {
-	switch e {
-{{range $values}}
-	case C.{{.}}: return "{{mixedCaseTrim . "PN_"}}" {{end}}
-	}
-	return "unknown"
-}
-`)
-}
-
-var (
-	reSpace = regexp.MustCompile("\\s+")
-)
-
-func panicIf(err error) {
-	if err != nil {
-		panic(err)
-	}
-}
-
-func readHeader(name string) string {
-	file, err := os.Open(path.Join("..", "..", "..", "include", "proton", name+".h"))
-	panicIf(err)
-	defer file.Close()
-	s, err := ioutil.ReadAll(file)
-	panicIf(err)
-	return string(s)
-}
-
-var copyright string = `/*
-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.
-*/
-
-//
-// NOTE: This file was generated by genwrap.go, do not edit it by hand.
-//
-`
-
-type eventType struct {
-	// C, function and interface names for the event
-	Name, Cname, Fname, Iname string
-}
-
-func newEventType(cName string) eventType {
-	var etype eventType
-	etype.Cname = cName
-	etype.Name = mixedCaseTrim(cName, "PN_")
-	etype.Fname = "On" + etype.Name
-	etype.Iname = etype.Fname + "Interface"
-	return etype
-}
-
-var (
-	enumDefRe   = regexp.MustCompile("typedef enum {([^}]*)} pn_([a-z_]+)_t;")
-	enumValRe   = regexp.MustCompile("PN_[A-Z_]+")
-	skipEventRe = regexp.MustCompile("EVENT_NONE|REACTOR|SELECTABLE|TIMER")
-	skipFnRe    = regexp.MustCompile("attach|context|class|collect|^recv$|^send$|transport")
-)
-
-// Generate event wrappers.
-func event(out io.Writer) {
-	event_h := readHeader("event")
-
-	// Event is implented by hand in wrappers.go
-
-	// Get all the pn_event_type_t enum values
-	var etypes []eventType
-	enums := findEnums(event_h)
-	for _, e := range enums[0].Values {
-		if skipEventRe.FindStringSubmatch(e) == nil {
-			etypes = append(etypes, newEventType(e))
-		}
-	}
-
-	doTemplate(out, etypes, `
-type EventType int
-const ({{range .}}
-	 E{{.Name}} EventType = C.{{.Cname}}{{end}}
-)
-`)
-
-	doTemplate(out, etypes, `
-func (e EventType) String() string {
-	switch e {
-{{range .}}
-	case C.{{.Cname}}: return "{{.Name}}"{{end}}
-	}
-	return "Unknown"
-}
-`)
-}
-
-type genType struct {
-	Ctype, Gotype string
-	ToGo          func(value string) string
-	ToC           func(value string) string
-	Assign        func(value string) string
-}
-
-func (g genType) printBody(out io.Writer, value string) {
-	if g.Gotype != "" {
-		fmt.Fprintf(out, "return %s", g.ToGo(value))
-	} else {
-		fmt.Fprintf(out, "%s", value)
-	}
-}
-
-func (g genType) goLiteral(value string) string {
-	return fmt.Sprintf("%s{%s}", g.Gotype, value)
-}
-
-func (g genType) goConvert(value string) string {
-	switch g.Gotype {
-	case "string":
-		return fmt.Sprintf("C.GoString(%s)", value)
-	case "Event":
-		return fmt.Sprintf("makeEvent(%s)", value)
-	default:
-		return fmt.Sprintf("%s(%s)", g.Gotype, value)
-	}
-}
-
-var notStruct = map[string]bool{
-	"EventType":        true,
-	"SndSettleMode":    true,
-	"RcvSettleMode":    true,
-	"TerminusType":     true,
-	"State":            true,
-	"Durability":       true,
-	"ExpiryPolicy":     true,
-	"DistributionMode": true,
-}
-
-func mapType(ctype string) (g genType) {
-	g.Ctype = "C." + strings.Trim(ctype, " \n")
-
-	switch g.Ctype {
-	case "C.void":
-		g.Gotype = ""
-	case "C.size_t":
-		g.Gotype = "uint"
-	case "C.int":
-		g.Gotype = "int"
-	case "C.void *":
-		g.Gotype = "unsafe.Pointer"
-		g.Ctype = "unsafe.Pointer"
-	case "C.bool":
-		g.Gotype = "bool"
-	case "C.ssize_t":
-		g.Gotype = "int"
-	case "C.uint64_t":
-		g.Gotype = "uint64"
-	case "C.uint32_t":
-		g.Gotype = "uint16"
-	case "C.uint16_t":
-		g.Gotype = "uint32"
-	case "C.const char *":
-		fallthrough
-	case "C.char *":
-		g.Gotype = "string"
-		g.Ctype = "C.CString"
-		g.ToC = func(v string) string { return fmt.Sprintf("%sC", v) }
-		g.Assign = func(v string) string {
-			return fmt.Sprintf("%sC := C.CString(%s)\n defer C.free(unsafe.Pointer(%sC))\n", v, v, v)
-		}
-	case "C.pn_seconds_t":
-		g.Gotype = "time.Duration"
-		g.ToGo = func(v string) string { return fmt.Sprintf("(time.Duration(%s) * time.Second)", v) }
-	case "C.pn_error_t *":
-		g.Gotype = "error"
-		g.ToGo = func(v string) string { return fmt.Sprintf("internal.PnError(unsafe.Pointer(%s))", v) }
-	default:
-		pnId := regexp.MustCompile(" *pn_([a-z_]+)_t *\\*? *")
-		match := pnId.FindStringSubmatch(g.Ctype)
-		if match == nil {
-			panic(fmt.Errorf("unknown C type %#v", g.Ctype))
-		}
-		g.Gotype = mixedCase(match[1])
-		if !notStruct[g.Gotype] {
-			g.ToGo = g.goLiteral
-			g.ToC = func(v string) string { return v + ".pn" }
-		}
-	}
-	if g.ToGo == nil {
-		g.ToGo = g.goConvert // Use conversion by default.
-	}
-	if g.ToC == nil {
-		g.ToC = func(v string) string { return fmt.Sprintf("%s(%s)", g.Ctype, v) }
-	}
-	return
-}
-
-type genArg struct {
-	Name string
-	genType
-}
-
-var typeNameRe = regexp.MustCompile("^(.*( |\\*))([^ *]+)$")
-
-func splitArgs(argstr string) []genArg {
-	argstr = strings.Trim(argstr, " \n")
-	if argstr == "" {
-		return []genArg{}
-	}
-	args := make([]genArg, 0)
-	for _, item := range strings.Split(argstr, ",") {
-		item = strings.Trim(item, " \n")
-		typeName := typeNameRe.FindStringSubmatch(item)
-		if typeName == nil {
-			panic(fmt.Errorf("Can't split argument type/name %#v", item))
-		}
-		cType := strings.Trim(typeName[1], " \n")
-		name := strings.Trim(typeName[3], " \n")
-		if name == "type" {
-			name = "type_"
-		}
-		args = append(args, genArg{name, mapType(cType)})
-	}
-	return args
-}
-
-func goArgs(args []genArg) string {
-	l := ""
-	for i, arg := range args {
-		if i != 0 {
-			l += ", "
-		}
-		l += arg.Name + " " + arg.Gotype
-	}
-	return l
-}
-
-func cArgs(args []genArg) string {
-	l := ""
-	for _, arg := range args {
-		l += fmt.Sprintf(", %s", arg.ToC(arg.Name))
-	}
-	return l
-}
-
-func cAssigns(args []genArg) string {
-	l := "\n"
-	for _, arg := range args {
-		if arg.Assign != nil {
-			l += fmt.Sprintf("%s\n", arg.Assign(arg.Name))
-		}
-	}
-	return l
-}
-
-// Return the go name of the function or "" to skip the function.
-func goFnName(api, fname string) string {
-	// Skip class, context and attachment functions.
-	if skipFnRe.FindStringSubmatch(fname) != nil {
-		return ""
-	}
-	switch api + "." + fname {
-	case "link.get_drain":
-		return "IsDrain"
-	default:
-		return mixedCaseTrim(fname, "get_")
-	}
-}
-
-func apiWrapFns(api, header string, out io.Writer) {
-	fmt.Fprintf(out, "type %s struct{pn *C.pn_%s_t}\n", mixedCase(api), api)
-	fmt.Fprintf(out, "func (%c %s) IsNil() bool { return %c.pn == nil }\n", api[0], mixedCase(api), api[0])
-	fn := regexp.MustCompile(fmt.Sprintf(`PN_EXTERN ([a-z0-9_ ]+ *\*?) *pn_%s_([a-z_]+)\(pn_%s_t *\*[a-z_]+ *,? *([^)]*)\)`, api, api))
-	for _, m := range fn.FindAllStringSubmatch(header, -1) {
-		rtype, fname, argstr := mapType(m[1]), m[2], m[3]
-		gname := goFnName(api, fname)
-		if gname == "" { // Skip
-			continue
-		}
-		args := splitArgs(argstr)
-		fmt.Fprintf(out, "func (%c %s) %s", api[0], mixedCase(api), gname)
-		fmt.Fprintf(out, "(%s) %s { ", goArgs(args), rtype.Gotype)
-		fmt.Fprint(out, cAssigns(args))
-		rtype.printBody(out, fmt.Sprintf("C.pn_%s_%s(%c.pn%s)", api, fname, api[0], cArgs(args)))
-		fmt.Fprintf(out, "}\n")
-	}
-}
-
-func main() {
-	outpath := path.Join("qpid.apache.org", "proton", "event", "wrappers_gen.go")
-	out, err := os.Create(outpath)
-	panicIf(err)
-	defer out.Close()
-
-	apis := []string{"session", "link", "delivery", "disposition", "condition", "terminus", "connection"}
-	fmt.Fprintln(out, copyright)
-	fmt.Fprint(out, `
-package event
-
-import (
-	"time"
-  "unsafe"
-  "qpid.apache.org/proton/internal"
-)
-
-// #include <proton/types.h>
-// #include <proton/event.h>
-// #include <stdlib.h>
-`)
-	for _, api := range apis {
-		fmt.Fprintf(out, "// #include <proton/%s.h>\n", api)
-	}
-	fmt.Fprintln(out, `import "C"`)
-
-	event(out)
-
-	for _, api := range apis {
-		fmt.Fprintf(out, "// Wrappers for declarations in %s.h\n\n", api)
-		header := readHeader(api)
-		enums := findEnums(header)
-		for _, e := range enums {
-			genEnum(out, e.Name, e.Values)
-		}
-		apiWrapFns(api, header, out)
-	}
-	out.Close()
-
-	// Run gofmt.
-	cmd := exec.Command("gofmt", "-w", outpath)
-	cmd.Stdout = os.Stdout
-	cmd.Stderr = os.Stderr
-	err = cmd.Run()
-	if err != nil {
-		fmt.Fprintf(os.Stderr, "gofmt: %s", err)
-		os.Exit(1)
-	}
-}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/132820cb/proton-c/bindings/go/src/qpid.apache.org/proton/doc.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/proton/doc.go b/proton-c/bindings/go/src/qpid.apache.org/proton/doc.go
deleted file mode 100644
index 38c2d00..0000000
--- a/proton-c/bindings/go/src/qpid.apache.org/proton/doc.go
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
-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.
-*/
-
-/*
-Package proton encodes and decodes AMQP messages and data as Go types.
-
-It follows the standard 'encoding' libraries pattern. The mapping between AMQP
-and Go types is described in the documentation of the Marshal and Unmarshal
-functions.
-
-The sub-packages 'event' and 'messaging' provide two alternative ways to write
-AMQP clients and servers. 'messaging' is easier for general purpose use. 'event'
-gives complete low-level control of the underlying proton C engine.
-
-AMQP is an open standard for inter-operable message exchange, see <http://www.amqp.org/>
-*/
-package proton
-
-// #cgo LDFLAGS: -lqpid-proton
-import "C"
-
-// This file is just for the package comment.
-
-// FIXME aconway 2015-04-28: need to re-organize the package, it's not very intuitive.

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/132820cb/proton-c/bindings/go/src/qpid.apache.org/proton/event/doc.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/proton/event/doc.go b/proton-c/bindings/go/src/qpid.apache.org/proton/event/doc.go
deleted file mode 100644
index a0d45d7..0000000
--- a/proton-c/bindings/go/src/qpid.apache.org/proton/event/doc.go
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
-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.
-*/
-
-/*
-Package event provides a low-level API to the proton AMQP engine.
-
-For most tasks, consider instead package qpid.apache.org/proton/messaging.
-It provides a higher-level, concurrent API that is easier to use.
-
-The API is event based. There are two alternative styles of handler. EventHandler
-provides the core proton events. MessagingHandler provides a slighly simplified
-view of the event stream and automates some common tasks.
-
-See type Pump documentation for more details of the interaction between proton
-events and goroutines.
-*/
-package event
-
-// #cgo LDFLAGS: -lqpid-proton
-import "C"
-
-// This file is just for the package comment.

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/132820cb/proton-c/bindings/go/src/qpid.apache.org/proton/event/handlers.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/proton/event/handlers.go b/proton-c/bindings/go/src/qpid.apache.org/proton/event/handlers.go
deleted file mode 100644
index 5fc679a..0000000
--- a/proton-c/bindings/go/src/qpid.apache.org/proton/event/handlers.go
+++ /dev/null
@@ -1,411 +0,0 @@
-/*
-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.
-*/
-
-package event
-
-// #include <proton/reactor.h>
-// #include <proton/handlers.h>
-import "C"
-
-import (
-	"qpid.apache.org/proton/internal"
-)
-
-// EventHandler handles core proton events.
-type EventHandler interface {
-	// HandleEvent is called with an event.
-	// Typically HandleEvent() is implemented as a switch on e.Type()
-	HandleEvent(e Event) error
-}
-
-// cHandler wraps a C pn_handler_t
-type cHandler struct {
-	pn *C.pn_handler_t
-}
-
-func (h cHandler) HandleEvent(e Event) error {
-	C.pn_handler_dispatch(h.pn, e.pn, C.pn_event_type(e.pn))
-	return nil // FIXME aconway 2015-03-31: error handling
-}
-
-// MessagingHandler provides an alternative interface to EventHandler.
-// it is easier to use for most applications that send and receive messages.
-//
-// Implement this interface and then wrap your value with a MessagingHandlerDelegator.
-// MessagingHandlerDelegator implements EventHandler and can be registered with a Pump.
-//
-type MessagingHandler interface {
-	HandleMessagingEvent(MessagingEventType, Event) error
-}
-
-// MessagingEventType provides a set of events that are easier to work with than the
-// core events defined by EventType
-//
-// There are 3 types of "endpoint": Connection, Session and Link.
-// For each endpoint there are 5 event types: Opening, Opened, Closing, Closed and Error.
-// The meaning of these events is as follows:
-//
-// Opening: The remote end opened, the local end will open automatically.
-//
-// Opened: Both ends are open, regardless of which end opened first.
-//
-// Closing: The remote end closed without error, the local end will close automatically.
-//
-// Error: The remote end closed with an error, the local end will close automatically.
-//
-// Closed: Both ends are closed, regardless of which end closed first or if there was an error.
-//
-type MessagingEventType int
-
-const (
-	// The event loop starts.
-	MStart MessagingEventType = iota
-	// The peer closes the connection with an error condition.
-	MConnectionError
-	// The peer closes the session with an error condition.
-	MSessionError
-	// The peer closes the link with an error condition.
-	MLinkError
-	// The peer Initiates the opening of the connection.
-	MConnectionOpening
-	// The peer initiates the opening of the session.
-	MSessionOpening
-	// The peer initiates the opening of the link.
-	MLinkOpening
-	// The connection is opened.
-	MConnectionOpened
-	// The session is opened.
-	MSessionOpened
-	// The link is opened.
-	MLinkOpened
-	// The peer initiates the closing of the connection.
-	MConnectionClosing
-	// The peer initiates the closing of the session.
-	MSessionClosing
-	// The peer initiates the closing of the link.
-	MLinkClosing
-	// Both ends of the connection are closed.
-	MConnectionClosed
-	// Both ends of the session are closed.
-	MSessionClosed
-	// Both ends of the link are closed.
-	MLinkClosed
-	// The connection is disconnected.
-	MConnectionDisconnected
-	// The session's connection was disconnected
-	MSessionDisconnected
-	// The session's connection was disconnected
-	MLinkDisconnected
-	// The sender link has credit and messages can
-	// therefore be transferred.
-	MSendable
-	// The remote peer accepts an outgoing message.
-	MAccepted
-	// The remote peer rejects an outgoing message.
-	MRejected
-	// The peer releases an outgoing message. Note that this may be in response to
-	// either the RELEASE or MODIFIED state as defined by the AMQP specification.
-	MReleased
-	// The peer has settled the outgoing message. This is the point at which it
-	// shouod never be retransmitted.
-	MSettled
-	// A message is received. Call proton.EventMessage(Event) to get the message.
-	// To manage the outcome of this messages (e.g. to accept or reject the message)
-	// use Event.Delivery().
-	MMessage
-	// The event loop terminates, there are no more events to process.
-	MFinal
-)
-
-func (t MessagingEventType) String() string {
-	switch t {
-	case MStart:
-		return "Start"
-	case MConnectionError:
-		return "ConnectionError"
-	case MSessionError:
-		return "SessionError"
-	case MLinkError:
-		return "LinkError"
-	case MConnectionOpening:
-		return "ConnectionOpening"
-	case MSessionOpening:
-		return "SessionOpening"
-	case MLinkOpening:
-		return "LinkOpening"
-	case MConnectionOpened:
-		return "ConnectionOpened"
-	case MSessionOpened:
-		return "SessionOpened"
-	case MLinkOpened:
-		return "LinkOpened"
-	case MConnectionClosing:
-		return "ConnectionClosing"
-	case MSessionClosing:
-		return "SessionClosing"
-	case MLinkClosing:
-		return "LinkClosing"
-	case MConnectionClosed:
-		return "ConnectionClosed"
-	case MSessionClosed:
-		return "SessionClosed"
-	case MLinkClosed:
-		return "LinkClosed"
-	case MConnectionDisconnected:
-		return "ConnectionDisconnected"
-	case MSessionDisconnected:
-		return "MSessionDisconnected"
-	case MLinkDisconnected:
-		return "MLinkDisconnected"
-	case MSendable:
-		return "Sendable"
-	case MAccepted:
-		return "Accepted"
-	case MRejected:
-		return "Rejected"
-	case MReleased:
-		return "Released"
-	case MSettled:
-		return "Settled"
-	case MMessage:
-		return "Message"
-	default:
-		return "Unknown"
-	}
-}
-
-// ResourceHandler provides a simple way to track the creation and deletion of
-// various proton objects.
-// endpointDelegator captures common patterns for endpoints opening/closing
-type endpointDelegator struct {
-	remoteOpen, remoteClose, localOpen, localClose EventType
-	opening, opened, closing, closed, error        MessagingEventType
-	endpoint                                       func(Event) Endpoint
-	delegate                                       MessagingHandler
-}
-
-// HandleEvent handles an open/close event for an endpoint in a generic way.
-func (d endpointDelegator) HandleEvent(e Event) (err error) {
-	endpoint := d.endpoint(e)
-	state := endpoint.State()
-
-	switch e.Type() {
-
-	case d.localOpen:
-		if state.Is(SRemoteActive) {
-			err = d.delegate.HandleMessagingEvent(d.opened, e)
-		}
-
-	case d.remoteOpen:
-		switch {
-		case state.Is(SLocalActive):
-			err = d.delegate.HandleMessagingEvent(d.opened, e)
-		case state.Is(SLocalUninit):
-			err = d.delegate.HandleMessagingEvent(d.opening, e)
-			if err == nil {
-				endpoint.Open()
-			}
-		}
-
-	case d.remoteClose:
-		var err1 error
-		if endpoint.RemoteCondition().IsSet() { // Closed with error
-			err1 = d.delegate.HandleMessagingEvent(d.error, e)
-			if err1 == nil { // Don't overwrite an application error.
-				err1 = endpoint.RemoteCondition().Error()
-			}
-		} else {
-			err1 = d.delegate.HandleMessagingEvent(d.closing, e)
-		}
-		if state.Is(SLocalClosed) {
-			err = d.delegate.HandleMessagingEvent(d.closed, e)
-		} else if state.Is(SLocalActive) {
-			endpoint.Close()
-		}
-		if err1 != nil { // Keep the first error.
-			err = err1
-		}
-
-	case d.localClose:
-		if state.Is(SRemoteClosed) {
-			err = d.delegate.HandleMessagingEvent(d.closed, e)
-		}
-
-	default:
-		// We shouldn't be called with any other event type.
-		panic(internal.Errorf("internal error, not an open/close event: %s", e))
-	}
-
-	return err
-}
-
-// MessagingDelegator implments a EventHandler and delegates to a MessagingHandler.
-// You can modify the exported fields before you pass the MessagingDelegator to
-// a Pump.
-type MessagingDelegator struct {
-	delegate                   MessagingHandler
-	connection, session, link  endpointDelegator
-	handshaker, flowcontroller EventHandler
-
-	// AutoSettle (default true) automatically pre-settle outgoing messages.
-	AutoSettle bool
-	// AutoAccept (default true) automatically accept and settle incoming messages
-	// if they are not settled by the delegate.
-	AutoAccept bool
-	// Prefetch (default 10) initial credit to issue for incoming links.
-	Prefetch int
-	// PeerCloseIsError (default false) if true a close by the peer will be treated as an error.
-	PeerCloseError bool
-}
-
-func NewMessagingDelegator(h MessagingHandler) EventHandler {
-	return &MessagingDelegator{
-		delegate: h,
-		connection: endpointDelegator{
-			EConnectionRemoteOpen, EConnectionRemoteClose, EConnectionLocalOpen, EConnectionLocalClose,
-			MConnectionOpening, MConnectionOpened, MConnectionClosing, MConnectionClosed,
-			MConnectionError,
-			func(e Event) Endpoint { return e.Connection() },
-			h,
-		},
-		session: endpointDelegator{
-			ESessionRemoteOpen, ESessionRemoteClose, ESessionLocalOpen, ESessionLocalClose,
-			MSessionOpening, MSessionOpened, MSessionClosing, MSessionClosed,
-			MSessionError,
-			func(e Event) Endpoint { return e.Session() },
-			h,
-		},
-		link: endpointDelegator{
-			ELinkRemoteOpen, ELinkRemoteClose, ELinkLocalOpen, ELinkLocalClose,
-			MLinkOpening, MLinkOpened, MLinkClosing, MLinkClosed,
-			MLinkError,
-			func(e Event) Endpoint { return e.Link() },
-			h,
-		},
-		flowcontroller: nil,
-		AutoSettle:     true,
-		AutoAccept:     true,
-		Prefetch:       10,
-		PeerCloseError: false,
-	}
-}
-
-func handleIf(h EventHandler, e Event) error {
-	if h != nil {
-		return h.HandleEvent(e)
-	}
-	return nil
-}
-
-// Handle a proton event by passing the corresponding MessagingEvent(s) to
-// the MessagingHandler.
-func (d *MessagingDelegator) HandleEvent(e Event) error {
-	handleIf(d.flowcontroller, e) // FIXME aconway 2015-03-31: error handling.
-
-	switch e.Type() {
-
-	case EConnectionInit:
-		d.flowcontroller = cHandler{C.pn_flowcontroller(C.int(d.Prefetch))}
-		d.delegate.HandleMessagingEvent(MStart, e)
-
-	case EConnectionRemoteOpen, EConnectionRemoteClose, EConnectionLocalOpen, EConnectionLocalClose:
-		return d.connection.HandleEvent(e)
-
-	case ESessionRemoteOpen, ESessionRemoteClose, ESessionLocalOpen, ESessionLocalClose:
-		return d.session.HandleEvent(e)
-
-	case ELinkRemoteOpen, ELinkRemoteClose, ELinkLocalOpen, ELinkLocalClose:
-		return d.link.HandleEvent(e)
-
-	case ELinkFlow:
-		if e.Link().IsSender() && e.Link().Credit() > 0 {
-			return d.delegate.HandleMessagingEvent(MSendable, e)
-		}
-
-	case EDelivery:
-		if e.Delivery().Link().IsReceiver() {
-			d.incoming(e)
-		} else {
-			d.outgoing(e)
-		}
-
-	case ETransportTailClosed:
-		c := e.Connection()
-		for l := c.LinkHead(SRemoteActive); !l.IsNil(); l = l.Next(SRemoteActive) {
-			e2 := e
-			e2.link = l
-			e2.session = l.Session()
-			d.delegate.HandleMessagingEvent(MLinkDisconnected, e2)
-		}
-		for s := c.SessionHead(SRemoteActive); !s.IsNil(); s = s.Next(SRemoteActive) {
-			e2 := e
-			e2.session = s
-			d.delegate.HandleMessagingEvent(MSessionDisconnected, e2)
-		}
-		d.delegate.HandleMessagingEvent(MConnectionDisconnected, e)
-		d.delegate.HandleMessagingEvent(MFinal, e)
-	}
-	return nil
-}
-
-func (d *MessagingDelegator) incoming(e Event) (err error) {
-	delivery := e.Delivery()
-	if delivery.Readable() && !delivery.Partial() {
-		if e.Link().State().Is(SLocalClosed) {
-			e.Link().Advance()
-			if d.AutoAccept {
-				delivery.Release(false)
-			}
-		} else {
-			err = d.delegate.HandleMessagingEvent(MMessage, e)
-			e.Link().Advance()
-			if d.AutoAccept && !delivery.Settled() {
-				if err == nil {
-					delivery.Accept()
-				} else {
-					delivery.Reject()
-				}
-			}
-		}
-	} else if delivery.Updated() && delivery.Settled() {
-		err = d.delegate.HandleMessagingEvent(MSettled, e)
-	}
-	return
-}
-
-func (d *MessagingDelegator) outgoing(e Event) (err error) {
-	delivery := e.Delivery()
-	if delivery.Updated() {
-		switch delivery.Remote().Type() {
-		case Accepted:
-			err = d.delegate.HandleMessagingEvent(MAccepted, e)
-		case Rejected:
-			err = d.delegate.HandleMessagingEvent(MRejected, e)
-		case Released, Modified:
-			err = d.delegate.HandleMessagingEvent(MReleased, e)
-		}
-		if err == nil && delivery.Settled() {
-			err = d.delegate.HandleMessagingEvent(MSettled, e)
-		}
-		if err == nil && d.AutoSettle {
-			delivery.Settle()
-		}
-	}
-	return
-}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/132820cb/proton-c/bindings/go/src/qpid.apache.org/proton/event/message.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/proton/event/message.go b/proton-c/bindings/go/src/qpid.apache.org/proton/event/message.go
deleted file mode 100644
index bd7dddd..0000000
--- a/proton-c/bindings/go/src/qpid.apache.org/proton/event/message.go
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
-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.
-*/
-
-package event
-
-// #include <proton/types.h>
-// #include <proton/message.h>
-// #include <proton/codec.h>
-import "C"
-
-import (
-	"qpid.apache.org/proton"
-	"qpid.apache.org/proton/internal"
-)
-
-// DecodeMessage decodes the message containined in a delivery event.
-func DecodeMessage(e Event) (m proton.Message, err error) {
-	defer internal.DoRecover(&err)
-	delivery := e.Delivery()
-	if !delivery.Readable() || delivery.Partial() {
-		return nil, internal.Errorf("attempting to get incomplete message")
-	}
-	data := make([]byte, delivery.Pending())
-	result := delivery.Link().Recv(data)
-	if result != len(data) {
-		return nil, internal.Errorf("cannot receive message: %s", internal.PnErrorCode(result))
-	}
-	return proton.DecodeMessage(data)
-}
-
-// FIXME aconway 2015-04-08: proper handling of delivery tags. Tag counter per link.
-var tags proton.UidCounter
-
-// Send sends a proton.Message over a Link.
-// Returns a Delivery that can be use to determine the outcome of the message.
-func (link Link) Send(m proton.Message) (Delivery, error) {
-	if !link.IsSender() {
-		return Delivery{}, internal.Errorf("attempt to send message on receiving link")
-	}
-	// FIXME aconway 2015-04-08: buffering, error handling
-	delivery := link.Delivery(tags.Next())
-	bytes, err := m.Encode(nil)
-	if err != nil {
-		return Delivery{}, internal.Errorf("cannot send mesage %s", err)
-	}
-	result := link.SendBytes(bytes)
-	link.Advance()
-	if result != len(bytes) {
-		if result < 0 {
-			return delivery, internal.Errorf("send failed %v", internal.PnErrorCode(result))
-		} else {
-			return delivery, internal.Errorf("send incomplete %v of %v", result, len(bytes))
-		}
-	}
-	if link.RemoteSndSettleMode() == PnSndSettled { // FIXME aconway 2015-04-08: enum names
-		delivery.Settle()
-	}
-	return delivery, nil
-}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/132820cb/proton-c/bindings/go/src/qpid.apache.org/proton/event/pump.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/proton/event/pump.go b/proton-c/bindings/go/src/qpid.apache.org/proton/event/pump.go
deleted file mode 100644
index c9c5ca3..0000000
--- a/proton-c/bindings/go/src/qpid.apache.org/proton/event/pump.go
+++ /dev/null
@@ -1,357 +0,0 @@
-/*
-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.
-*/
-
-package event
-
-// #include <proton/connection.h>
-// #include <proton/transport.h>
-// #include <proton/event.h>
-// #include <proton/reactor.h>
-// #include <proton/handlers.h>
-// #include <proton/transport.h>
-// #include <proton/session.h>
-// #include <memory.h>
-// #include <stdlib.h>
-//
-// PN_HANDLE(REMOTE_ADDR)
-import "C"
-
-import (
-	"fmt"
-	"io"
-	"net"
-	"qpid.apache.org/proton/internal"
-	"sync"
-	"unsafe"
-)
-
-// bufferChan manages a pair of ping-pong buffers to pass bytes through a channel.
-type bufferChan struct {
-	buffers    chan []byte
-	buf1, buf2 []byte
-}
-
-func newBufferChan(size int) *bufferChan {
-	return &bufferChan{make(chan []byte), make([]byte, size), make([]byte, size)}
-}
-
-func (b *bufferChan) buffer() []byte {
-	b.buf1, b.buf2 = b.buf2, b.buf1 // Alternate buffers.
-	return b.buf1[:cap(b.buf1)]
-}
-
-// FIXME aconway 2015-05-04: direct sending to Inject may block user goroutines if
-// the pum stops. Make this a function that selects on running.
-
-// FIXME aconway 2015-05-05: for consistency should Pump be called Driver?
-
-/*
-Pump reads from a net.Conn, decodes AMQP events and calls the appropriate
-Handler functions. Actions taken by Handler functions (such as sending messages)
-are encoded and written to the net.Conn.
-
-The proton protocol engine is single threaded (per connection). The Pump runs
-proton in the goroutine that calls Pump.Run() and creates goroutines to feed
-data to/from a net.Conn. You can create multiple Pumps to handle multiple
-connections concurrently.
-
-Methods in this package can only be called in the goroutine that executes the
-corresponding Pump.Run(). You implement the EventHandler or MessagingHandler
-interfaces and provide those values to NewPump(). Their HandleEvent method will be
-called in the Pump goroutine, in typical event-driven style.
-
-Handlers can pass values from an event (Connections, Links, Deliveries etc.) to
-other goroutines, store them, or use them as map indexes. Effectively they are
-just C pointers.  Other goroutines cannot call their methods directly but they
-can can create function closures that call their methods and send those closures
-to the Pump.Inject channel. They will execute safely in the pump
-goroutine. Injected functions, or your handlers, can set up channels to get
-results back to other goroutines.
-
-You are responsible for ensuring you don't use an event value after the C object
-has been deleted. The handler methods will tell you when a value is no longer
-valid. For example after a MethodHandler handles a LinkClosed event, that link
-is no longer valid. If you do Link.Close() yourself (in a handler or injected
-function) the link remains valid until the corresponing LinkClosed event is
-received by the handler.
-
-Pump.Close() will take care of cleaning up any remaining values and types when
-you are done with the Pump. All values associated with a pump become invalid
-when you call Pump.Close()
-
-The qpid.apache.org/proton/messaging package will do all this for you, so unless
-you are doing something fairly low-level it is probably a better choice.
-
-*/
-type Pump struct {
-	// Error is set on exit from Run() if there was an error.
-	Error error
-	// Channel to inject functions to be executed in the Pump's proton event loop.
-	Inject chan func()
-
-	conn       net.Conn
-	transport  *C.pn_transport_t
-	connection *C.pn_connection_t
-	collector  *C.pn_collector_t
-	read       *bufferChan    // Read buffers channel.
-	write      *bufferChan    // Write buffers channel.
-	handlers   []EventHandler // Handlers for proton events.
-	running    chan struct{}  // This channel will be closed when the goroutines are done.
-}
-
-const bufferSize = 4096
-
-var pumps map[*C.pn_connection_t]*Pump
-
-func init() {
-	pumps = make(map[*C.pn_connection_t]*Pump)
-}
-
-// NewPump initializes a pump with a connection and handlers. To start it running:
-//    p := NewPump(...)
-//    go run p.Run()
-// The goroutine will exit when the pump is closed or disconnected.
-// You can check for errors on Pump.Error.
-//
-func NewPump(conn net.Conn, handlers ...EventHandler) (*Pump, error) {
-	// Save the connection ID for Connection.String()
-	p := &Pump{
-		Inject:     make(chan func(), 100), // FIXME aconway 2015-05-04: blocking hack
-		conn:       conn,
-		transport:  C.pn_transport(),
-		connection: C.pn_connection(),
-		collector:  C.pn_collector(),
-		handlers:   handlers,
-		read:       newBufferChan(bufferSize),
-		write:      newBufferChan(bufferSize),
-		running:    make(chan struct{}),
-	}
-	if p.transport == nil || p.connection == nil || p.collector == nil {
-		return nil, internal.Errorf("failed to allocate pump")
-	}
-	pnErr := int(C.pn_transport_bind(p.transport, p.connection))
-	if pnErr != 0 {
-		return nil, internal.Errorf("cannot setup pump: %s", internal.PnErrorCode(pnErr))
-	}
-	C.pn_connection_collect(p.connection, p.collector)
-	C.pn_connection_open(p.connection)
-	pumps[p.connection] = p
-	return p, nil
-}
-
-func (p *Pump) String() string {
-	return fmt.Sprintf("(%s-%s)", p.conn.LocalAddr(), p.conn.RemoteAddr())
-}
-
-func (p *Pump) Id() string {
-	return fmt.Sprintf("%p", &p)
-}
-
-// setError sets error only if not already set
-func (p *Pump) setError(e error) {
-	if p.Error == nil {
-		p.Error = e
-	}
-}
-
-// Server puts the Pump in server mode, meaning it will auto-detect security settings on
-// the incoming connnection such as use of SASL and SSL.
-// Must be called before Run()
-//
-func (p *Pump) Server() {
-	C.pn_transport_set_server(p.transport)
-}
-
-func (p *Pump) free() {
-	if p.connection != nil {
-		C.pn_connection_free(p.connection)
-	}
-	if p.transport != nil {
-		C.pn_transport_free(p.transport)
-	}
-	if p.collector != nil {
-		C.pn_collector_free(p.collector)
-	}
-	for _, h := range p.handlers {
-		switch h := h.(type) {
-		case cHandler:
-			C.pn_handler_free(h.pn)
-		}
-	}
-}
-
-// Close closes the AMQP connection, the net.Conn, and stops associated goroutines.
-// It will cause Run() to return. Run() may return earlier if the network disconnects
-// but you must still call Close() to clean everything up.
-//
-// Methods on values associated with the pump (Connections, Sessions, Links) will panic
-// if called after Close()
-//
-func (p *Pump) Close() error {
-	// If the pump is still running, inject a close. Either way wait for it to finish.
-	select {
-	case p.Inject <- func() { C.pn_connection_close(p.connection) }:
-		<-p.running // Wait to finish
-	case <-p.running: // Wait for goroutines to finish
-	}
-	delete(pumps, p.connection)
-	p.free()
-	return p.Error
-}
-
-// Run the pump. Normally called in a goroutine as: go pump.Run()
-// An error dunring Run is stored on p.Error.
-//
-func (p *Pump) Run() {
-	// Signal errors from the read/write goroutines. Don't block if we don't
-	// read all the errors, we only care about the first.
-	error := make(chan error, 2)
-	// FIXME aconway 2015-05-04: 	stop := make(chan struct{}) // Closed to signal that read/write should stop.
-
-	wait := sync.WaitGroup{}
-	wait.Add(2)
-
-	go func() { // Read goroutine
-		defer wait.Done()
-		for {
-			rbuf := p.read.buffer()
-			n, err := p.conn.Read(rbuf)
-			if n > 0 {
-				p.read.buffers <- rbuf[:n]
-			} else if err != nil {
-				close(p.read.buffers)
-				error <- err
-				return
-			}
-		}
-	}()
-
-	go func() { // Write goroutine
-		defer wait.Done()
-		for {
-			wbuf, ok := <-p.write.buffers
-			if !ok {
-				return
-			}
-			_, err := p.conn.Write(wbuf)
-			if err != nil {
-				error <- err
-				return
-			}
-		}
-	}()
-
-	wbuf := p.write.buffer()[:0]
-loop:
-	for {
-		if len(wbuf) == 0 {
-			p.pop(&wbuf)
-		}
-		// Don't set wchan unless there is something to write.
-		var wchan chan []byte
-		if len(wbuf) > 0 {
-			wchan = p.write.buffers
-		}
-
-		select {
-		case buf := <-p.read.buffers: // Read a buffer
-			p.push(buf)
-		case wchan <- wbuf: // Write a buffer
-			wbuf = p.write.buffer()[:0]
-		case f := <-p.Inject: // Function injected from another goroutine
-			f()
-		case err := <-error: // Read or write error
-			p.setError(err)
-			C.pn_transport_close_tail(p.transport)
-			C.pn_transport_close_head(p.transport)
-		}
-		if err := p.process(); err != nil {
-			p.setError(err)
-			break loop
-		}
-	}
-	close(p.write.buffers)
-	p.conn.Close()
-	wait.Wait()
-	close(p.running) // Signal goroutines have exited and Error is set.
-}
-
-func minInt(a, b int) int {
-	if a < b {
-		return a
-	} else {
-		return b
-	}
-}
-
-func (p *Pump) pop(buf *[]byte) {
-	pending := int(C.pn_transport_pending(p.transport))
-	switch {
-	case pending == int(C.PN_EOS):
-		*buf = (*buf)[:]
-		return
-	case pending < 0:
-		panic(internal.Errorf("%s", internal.PnErrorCode(pending)))
-	}
-	size := minInt(pending, cap(*buf))
-	*buf = (*buf)[:size]
-	if size == 0 {
-		return
-	}
-	C.memcpy(unsafe.Pointer(&(*buf)[0]), unsafe.Pointer(C.pn_transport_head(p.transport)), C.size_t(size))
-	C.pn_transport_pop(p.transport, C.size_t(size))
-}
-
-func (p *Pump) push(buf []byte) {
-	buf2 := buf
-	for len(buf2) > 0 {
-		n := int(C.pn_transport_push(p.transport, (*C.char)(unsafe.Pointer((&buf2[0]))), C.size_t(len(buf2))))
-		if n <= 0 {
-			panic(internal.Errorf("error in transport: %s", internal.PnErrorCode(n)))
-		}
-		buf2 = buf2[n:]
-	}
-}
-
-func (p *Pump) handle(e Event) error {
-	for _, h := range p.handlers {
-		if err := h.HandleEvent(e); err != nil {
-			return err
-		}
-	}
-	if e.Type() == ETransportClosed {
-		return io.EOF
-	}
-	return nil
-}
-
-func (p *Pump) process() error {
-	// FIXME aconway 2015-05-04: if a Handler returns error we should stop the pump
-	for ce := C.pn_collector_peek(p.collector); ce != nil; ce = C.pn_collector_peek(p.collector) {
-		e := makeEvent(ce)
-		if err := p.handle(e); err != nil {
-			return err
-		}
-		C.pn_collector_pop(p.collector)
-	}
-	return nil
-}
-
-// Connectoin gets the Pump's connection value.
-func (p *Pump) Connection() Connection { return Connection{p.connection} }

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/132820cb/proton-c/bindings/go/src/qpid.apache.org/proton/event/wrappers.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/proton/event/wrappers.go b/proton-c/bindings/go/src/qpid.apache.org/proton/event/wrappers.go
deleted file mode 100644
index d2c4e43..0000000
--- a/proton-c/bindings/go/src/qpid.apache.org/proton/event/wrappers.go
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
-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.
-*/
-
-package event
-
-//#include <proton/codec.h>
-//#include <proton/connection.h>
-//#include <proton/session.h>
-//#include <proton/session.h>
-//#include <proton/delivery.h>
-//#include <proton/link.h>
-//#include <proton/event.h>
-//#include <proton/transport.h>
-//#include <proton/link.h>
-//#include <stdlib.h>
-import "C"
-
-import (
-	"fmt"
-	"qpid.apache.org/proton/internal"
-	"unsafe"
-)
-
-// FIXME aconway 2015-05-05: Documentation for generated types.
-
-// Event is an AMQP protocol event.
-type Event struct {
-	pn         *C.pn_event_t
-	eventType  EventType
-	connection Connection
-	session    Session
-	link       Link
-	delivery   Delivery
-}
-
-func makeEvent(pn *C.pn_event_t) Event {
-	return Event{
-		pn:         pn,
-		eventType:  EventType(C.pn_event_type(pn)),
-		connection: Connection{C.pn_event_connection(pn)},
-		session:    Session{C.pn_event_session(pn)},
-		link:       Link{C.pn_event_link(pn)},
-		delivery:   Delivery{C.pn_event_delivery(pn)},
-	}
-}
-func (e Event) IsNil() bool            { return e.eventType == EventType(0) }
-func (e Event) Type() EventType        { return e.eventType }
-func (e Event) Connection() Connection { return e.connection }
-func (e Event) Session() Session       { return e.session }
-func (e Event) Link() Link             { return e.link }
-func (e Event) Delivery() Delivery     { return e.delivery }
-func (e Event) String() string         { return e.Type().String() }
-
-// Data holds a pointer to decoded AMQP data.
-// Use proton.marshal/unmarshal to access it as Go data types.
-//
-type Data struct{ pn *C.pn_data_t }
-
-func NewData(p unsafe.Pointer) Data { return Data{(*C.pn_data_t)(p)} }
-
-func (d Data) Free()                   { C.pn_data_free(d.pn) }
-func (d Data) Pointer() unsafe.Pointer { return unsafe.Pointer(d.pn) }
-func (d Data) Clear()                  { C.pn_data_clear(d.pn) }
-func (d Data) Rewind()                 { C.pn_data_rewind(d.pn) }
-func (d Data) Error() error {
-	return internal.PnError(unsafe.Pointer(C.pn_data_error(d.pn)))
-}
-
-// State holds the state flags for an AMQP endpoint.
-type State byte
-
-const (
-	SLocalUninit  State = C.PN_LOCAL_UNINIT
-	SLocalActive        = C.PN_LOCAL_ACTIVE
-	SLocalClosed        = C.PN_LOCAL_CLOSED
-	SRemoteUninit       = C.PN_REMOTE_UNINIT
-	SRemoteActive       = C.PN_REMOTE_ACTIVE
-	SRemoteClosed       = C.PN_REMOTE_CLOSED
-)
-
-// Is is True if bits & state is non 0.
-func (s State) Is(bits State) bool { return s&bits != 0 }
-
-// Return a State containig just the local flags
-func (s State) Local() State { return State(s & C.PN_LOCAL_MASK) }
-
-// Return a State containig just the remote flags
-func (s State) Remote() State { return State(s & C.PN_REMOTE_MASK) }
-
-// Endpoint is the common interface for Connection, Link and Session.
-type Endpoint interface {
-	// State is the open/closed state.
-	State() State
-	// Open an endpoint.
-	Open()
-	// Close an endpoint.
-	Close()
-	// Condition holds a local error condition.
-	Condition() Condition
-	// RemoteCondition holds a remote error condition.
-	RemoteCondition() Condition
-}
-
-const (
-	Received uint64 = C.PN_RECEIVED
-	Accepted        = C.PN_ACCEPTED
-	Rejected        = C.PN_REJECTED
-	Released        = C.PN_RELEASED
-	Modified        = C.PN_MODIFIED
-)
-
-// SettleAs is equivalent to d.Update(disposition); d.Settle()
-// It is a no-op if e does not have a delivery.
-func (d Delivery) SettleAs(disposition uint64) {
-	d.Update(disposition)
-	d.Settle()
-}
-
-// Accept accepts and settles a delivery.
-func (d Delivery) Accept() { d.SettleAs(Accepted) }
-
-// Reject rejects and settles a delivery
-func (d Delivery) Reject() { d.SettleAs(Rejected) }
-
-// Release releases and settles a delivery
-// If delivered is true the delivery count for the message will be increased.
-func (d Delivery) Release(delivered bool) {
-	if delivered {
-		d.SettleAs(Modified)
-	} else {
-		d.SettleAs(Released)
-	}
-}
-
-// FIXME aconway 2015-05-05: don't expose DeliveryTag as a C pointer, just as a String?
-
-type DeliveryTag struct{ pn C.pn_delivery_tag_t }
-
-func (t DeliveryTag) String() string { return C.GoStringN(t.pn.start, C.int(t.pn.size)) }
-
-func (l Link) Recv(buf []byte) int {
-	if len(buf) == 0 {
-		return 0
-	}
-	return int(C.pn_link_recv(l.pn, (*C.char)(unsafe.Pointer(&buf[0])), C.size_t(len(buf))))
-}
-
-func (l Link) SendBytes(bytes []byte) int {
-	return int(C.pn_link_send(l.pn, cPtr(bytes), cLen(bytes)))
-}
-
-func pnTag(tag string) C.pn_delivery_tag_t {
-	bytes := []byte(tag)
-	return C.pn_dtag(cPtr(bytes), cLen(bytes))
-}
-
-func (l Link) Delivery(tag string) Delivery {
-	return Delivery{C.pn_delivery(l.pn, pnTag(tag))}
-}
-
-func cPtr(b []byte) *C.char {
-	if len(b) == 0 {
-		return nil
-	}
-	return (*C.char)(unsafe.Pointer(&b[0]))
-}
-
-func cLen(b []byte) C.size_t {
-	return C.size_t(len(b))
-}
-
-func (s Session) Sender(name string) Link {
-	cname := C.CString(name)
-	defer C.free(unsafe.Pointer(cname))
-	return Link{C.pn_sender(s.pn, cname)}
-}
-
-func (s Session) Receiver(name string) Link {
-	cname := C.CString(name)
-	defer C.free(unsafe.Pointer(cname))
-	return Link{C.pn_receiver(s.pn, cname)}
-}
-
-func joinId(a, b interface{}) string {
-	return fmt.Sprintf("%s/%s", a, b)
-}
-
-// Pump associated with this connection.
-func (c Connection) Pump() *Pump { return pumps[c.pn] }
-
-// Unique (per process) string identifier for a connection, useful for debugging.
-func (c Connection) String() string { return pumps[c.pn].String() }
-
-// Head functions don't follow the normal naming conventions so missed by the generator.
-
-func (c Connection) LinkHead(s State) Link {
-	return Link{C.pn_link_head(c.pn, C.pn_state_t(s))}
-}
-
-func (c Connection) SessionHead(s State) Session {
-	return Session{C.pn_session_head(c.pn, C.pn_state_t(s))}
-}
-
-// Unique (per process) string identifier for a session, including connection identifier.
-func (s Session) String() string {
-	return joinId(s.Connection(), fmt.Sprintf("%p", s.pn))
-}
-
-// Unique (per process) string identifier for a link, inlcuding session identifier.
-func (l Link) String() string {
-	return joinId(l.Session(), l.Name())
-}
-
-// Error returns an error interface corresponding to Condition.
-func (c Condition) Error() error {
-	if c.IsNil() {
-		return nil
-	} else {
-		return fmt.Errorf("%s: %s", c.Name(), c.Description())
-	}
-}
-
-// SetIfUnset sets name and description on a condition if it is not already set.
-func (c Condition) SetIfUnset(name, description string) {
-	if !c.IsSet() {
-		c.SetName(name)
-		c.SetDescription(description)
-	}
-}
-
-func (c Connection) Session() (Session, error) {
-	s := Session{C.pn_session(c.pn)}
-	if s.IsNil() {
-		return s, Connection(c).Error()
-	}
-	return s, nil
-}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/132820cb/proton-c/bindings/go/src/qpid.apache.org/proton/event/wrappers_gen.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/proton/event/wrappers_gen.go b/proton-c/bindings/go/src/qpid.apache.org/proton/event/wrappers_gen.go
deleted file mode 100644
index f53e8bb..0000000
--- a/proton-c/bindings/go/src/qpid.apache.org/proton/event/wrappers_gen.go
+++ /dev/null
@@ -1,732 +0,0 @@
-/*
-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.
-*/
-
-//
-// NOTE: This file was generated by genwrap.go, do not edit it by hand.
-//
-
-package event
-
-import (
-	"qpid.apache.org/proton/internal"
-	"time"
-	"unsafe"
-)
-
-// #include <proton/types.h>
-// #include <proton/event.h>
-// #include <stdlib.h>
-// #include <proton/session.h>
-// #include <proton/link.h>
-// #include <proton/delivery.h>
-// #include <proton/disposition.h>
-// #include <proton/condition.h>
-// #include <proton/terminus.h>
-// #include <proton/connection.h>
-import "C"
-
-type EventType int
-
-const (
-	EConnectionInit         EventType = C.PN_CONNECTION_INIT
-	EConnectionBound        EventType = C.PN_CONNECTION_BOUND
-	EConnectionUnbound      EventType = C.PN_CONNECTION_UNBOUND
-	EConnectionLocalOpen    EventType = C.PN_CONNECTION_LOCAL_OPEN
-	EConnectionRemoteOpen   EventType = C.PN_CONNECTION_REMOTE_OPEN
-	EConnectionLocalClose   EventType = C.PN_CONNECTION_LOCAL_CLOSE
-	EConnectionRemoteClose  EventType = C.PN_CONNECTION_REMOTE_CLOSE
-	EConnectionFinal        EventType = C.PN_CONNECTION_FINAL
-	ESessionInit            EventType = C.PN_SESSION_INIT
-	ESessionLocalOpen       EventType = C.PN_SESSION_LOCAL_OPEN
-	ESessionRemoteOpen      EventType = C.PN_SESSION_REMOTE_OPEN
-	ESessionLocalClose      EventType = C.PN_SESSION_LOCAL_CLOSE
-	ESessionRemoteClose     EventType = C.PN_SESSION_REMOTE_CLOSE
-	ESessionFinal           EventType = C.PN_SESSION_FINAL
-	ELinkInit               EventType = C.PN_LINK_INIT
-	ELinkLocalOpen          EventType = C.PN_LINK_LOCAL_OPEN
-	ELinkRemoteOpen         EventType = C.PN_LINK_REMOTE_OPEN
-	ELinkLocalClose         EventType = C.PN_LINK_LOCAL_CLOSE
-	ELinkRemoteClose        EventType = C.PN_LINK_REMOTE_CLOSE
-	ELinkLocalDetach        EventType = C.PN_LINK_LOCAL_DETACH
-	ELinkRemoteDetach       EventType = C.PN_LINK_REMOTE_DETACH
-	ELinkFlow               EventType = C.PN_LINK_FLOW
-	ELinkFinal              EventType = C.PN_LINK_FINAL
-	EDelivery               EventType = C.PN_DELIVERY
-	ETransport              EventType = C.PN_TRANSPORT
-	ETransportAuthenticated EventType = C.PN_TRANSPORT_AUTHENTICATED
-	ETransportError         EventType = C.PN_TRANSPORT_ERROR
-	ETransportHeadClosed    EventType = C.PN_TRANSPORT_HEAD_CLOSED
-	ETransportTailClosed    EventType = C.PN_TRANSPORT_TAIL_CLOSED
-	ETransportClosed        EventType = C.PN_TRANSPORT_CLOSED
-)
-
-func (e EventType) String() string {
-	switch e {
-
-	case C.PN_CONNECTION_INIT:
-		return "ConnectionInit"
-	case C.PN_CONNECTION_BOUND:
-		return "ConnectionBound"
-	case C.PN_CONNECTION_UNBOUND:
-		return "ConnectionUnbound"
-	case C.PN_CONNECTION_LOCAL_OPEN:
-		return "ConnectionLocalOpen"
-	case C.PN_CONNECTION_REMOTE_OPEN:
-		return "ConnectionRemoteOpen"
-	case C.PN_CONNECTION_LOCAL_CLOSE:
-		return "ConnectionLocalClose"
-	case C.PN_CONNECTION_REMOTE_CLOSE:
-		return "ConnectionRemoteClose"
-	case C.PN_CONNECTION_FINAL:
-		return "ConnectionFinal"
-	case C.PN_SESSION_INIT:
-		return "SessionInit"
-	case C.PN_SESSION_LOCAL_OPEN:
-		return "SessionLocalOpen"
-	case C.PN_SESSION_REMOTE_OPEN:
-		return "SessionRemoteOpen"
-	case C.PN_SESSION_LOCAL_CLOSE:
-		return "SessionLocalClose"
-	case C.PN_SESSION_REMOTE_CLOSE:
-		return "SessionRemoteClose"
-	case C.PN_SESSION_FINAL:
-		return "SessionFinal"
-	case C.PN_LINK_INIT:
-		return "LinkInit"
-	case C.PN_LINK_LOCAL_OPEN:
-		return "LinkLocalOpen"
-	case C.PN_LINK_REMOTE_OPEN:
-		return "LinkRemoteOpen"
-	case C.PN_LINK_LOCAL_CLOSE:
-		return "LinkLocalClose"
-	case C.PN_LINK_REMOTE_CLOSE:
-		return "LinkRemoteClose"
-	case C.PN_LINK_LOCAL_DETACH:
-		return "LinkLocalDetach"
-	case C.PN_LINK_REMOTE_DETACH:
-		return "LinkRemoteDetach"
-	case C.PN_LINK_FLOW:
-		return "LinkFlow"
-	case C.PN_LINK_FINAL:
-		return "LinkFinal"
-	case C.PN_DELIVERY:
-		return "Delivery"
-	case C.PN_TRANSPORT:
-		return "Transport"
-	case C.PN_TRANSPORT_AUTHENTICATED:
-		return "TransportAuthenticated"
-	case C.PN_TRANSPORT_ERROR:
-		return "TransportError"
-	case C.PN_TRANSPORT_HEAD_CLOSED:
-		return "TransportHeadClosed"
-	case C.PN_TRANSPORT_TAIL_CLOSED:
-		return "TransportTailClosed"
-	case C.PN_TRANSPORT_CLOSED:
-		return "TransportClosed"
-	}
-	return "Unknown"
-}
-
-// Wrappers for declarations in session.h
-
-type Session struct{ pn *C.pn_session_t }
-
-func (s Session) IsNil() bool { return s.pn == nil }
-func (s Session) Free() {
-	C.pn_session_free(s.pn)
-}
-func (s Session) State() State {
-	return State(C.pn_session_state(s.pn))
-}
-func (s Session) Error() error {
-	return internal.PnError(unsafe.Pointer(C.pn_session_error(s.pn)))
-}
-func (s Session) Condition() Condition {
-	return Condition{C.pn_session_condition(s.pn)}
-}
-func (s Session) RemoteCondition() Condition {
-	return Condition{C.pn_session_remote_condition(s.pn)}
-}
-func (s Session) Connection() Connection {
-	return Connection{C.pn_session_connection(s.pn)}
-}
-func (s Session) Open() {
-	C.pn_session_open(s.pn)
-}
-func (s Session) Close() {
-	C.pn_session_close(s.pn)
-}
-func (s Session) IncomingCapacity() uint {
-	return uint(C.pn_session_get_incoming_capacity(s.pn))
-}
-func (s Session) SetIncomingCapacity(capacity uint) {
-	C.pn_session_set_incoming_capacity(s.pn, C.size_t(capacity))
-}
-func (s Session) OutgoingBytes() uint {
-	return uint(C.pn_session_outgoing_bytes(s.pn))
-}
-func (s Session) IncomingBytes() uint {
-	return uint(C.pn_session_incoming_bytes(s.pn))
-}
-func (s Session) Next(state State) Session {
-	return Session{C.pn_session_next(s.pn, C.pn_state_t(state))}
-}
-
-// Wrappers for declarations in link.h
-
-type SndSettleMode C.pn_snd_settle_mode_t
-
-const (
-	PnSndUnsettled SndSettleMode = C.PN_SND_UNSETTLED
-	PnSndSettled   SndSettleMode = C.PN_SND_SETTLED
-	PnSndMixed     SndSettleMode = C.PN_SND_MIXED
-)
-
-func (e SndSettleMode) String() string {
-	switch e {
-
-	case C.PN_SND_UNSETTLED:
-		return "SndUnsettled"
-	case C.PN_SND_SETTLED:
-		return "SndSettled"
-	case C.PN_SND_MIXED:
-		return "SndMixed"
-	}
-	return "unknown"
-}
-
-type RcvSettleMode C.pn_rcv_settle_mode_t
-
-const (
-	PnRcvFirst  RcvSettleMode = C.PN_RCV_FIRST
-	PnRcvSecond RcvSettleMode = C.PN_RCV_SECOND
-)
-
-func (e RcvSettleMode) String() string {
-	switch e {
-
-	case C.PN_RCV_FIRST:
-		return "RcvFirst"
-	case C.PN_RCV_SECOND:
-		return "RcvSecond"
-	}
-	return "unknown"
-}
-
-type Link struct{ pn *C.pn_link_t }
-
-func (l Link) IsNil() bool { return l.pn == nil }
-func (l Link) Free() {
-	C.pn_link_free(l.pn)
-}
-func (l Link) Name() string {
-	return C.GoString(C.pn_link_name(l.pn))
-}
-func (l Link) IsSender() bool {
-	return bool(C.pn_link_is_sender(l.pn))
-}
-func (l Link) IsReceiver() bool {
-	return bool(C.pn_link_is_receiver(l.pn))
-}
-func (l Link) State() State {
-	return State(C.pn_link_state(l.pn))
-}
-func (l Link) Error() error {
-	return internal.PnError(unsafe.Pointer(C.pn_link_error(l.pn)))
-}
-func (l Link) Condition() Condition {
-	return Condition{C.pn_link_condition(l.pn)}
-}
-func (l Link) RemoteCondition() Condition {
-	return Condition{C.pn_link_remote_condition(l.pn)}
-}
-func (l Link) Session() Session {
-	return Session{C.pn_link_session(l.pn)}
-}
-func (l Link) Next(state State) Link {
-	return Link{C.pn_link_next(l.pn, C.pn_state_t(state))}
-}
-func (l Link) Open() {
-	C.pn_link_open(l.pn)
-}
-func (l Link) Close() {
-	C.pn_link_close(l.pn)
-}
-func (l Link) Detach() {
-	C.pn_link_detach(l.pn)
-}
-func (l Link) Source() Terminus {
-	return Terminus{C.pn_link_source(l.pn)}
-}
-func (l Link) Target() Terminus {
-	return Terminus{C.pn_link_target(l.pn)}
-}
-func (l Link) RemoteSource() Terminus {
-	return Terminus{C.pn_link_remote_source(l.pn)}
-}
-func (l Link) RemoteTarget() Terminus {
-	return Terminus{C.pn_link_remote_target(l.pn)}
-}
-func (l Link) Current() Delivery {
-	return Delivery{C.pn_link_current(l.pn)}
-}
-func (l Link) Advance() bool {
-	return bool(C.pn_link_advance(l.pn))
-}
-func (l Link) Credit() int {
-	return int(C.pn_link_credit(l.pn))
-}
-func (l Link) Queued() int {
-	return int(C.pn_link_queued(l.pn))
-}
-func (l Link) RemoteCredit() int {
-	return int(C.pn_link_remote_credit(l.pn))
-}
-func (l Link) IsDrain() bool {
-	return bool(C.pn_link_get_drain(l.pn))
-}
-func (l Link) Drained() int {
-	return int(C.pn_link_drained(l.pn))
-}
-func (l Link) Available() int {
-	return int(C.pn_link_available(l.pn))
-}
-func (l Link) SndSettleMode() SndSettleMode {
-	return SndSettleMode(C.pn_link_snd_settle_mode(l.pn))
-}
-func (l Link) RcvSettleMode() RcvSettleMode {
-	return RcvSettleMode(C.pn_link_rcv_settle_mode(l.pn))
-}
-func (l Link) SetSndSettleMode(mode SndSettleMode) {
-	C.pn_link_set_snd_settle_mode(l.pn, C.pn_snd_settle_mode_t(mode))
-}
-func (l Link) SetRcvSettleMode(mode RcvSettleMode) {
-	C.pn_link_set_rcv_settle_mode(l.pn, C.pn_rcv_settle_mode_t(mode))
-}
-func (l Link) RemoteSndSettleMode() SndSettleMode {
-	return SndSettleMode(C.pn_link_remote_snd_settle_mode(l.pn))
-}
-func (l Link) RemoteRcvSettleMode() RcvSettleMode {
-	return RcvSettleMode(C.pn_link_remote_rcv_settle_mode(l.pn))
-}
-func (l Link) Unsettled() int {
-	return int(C.pn_link_unsettled(l.pn))
-}
-func (l Link) Offered(credit int) {
-	C.pn_link_offered(l.pn, C.int(credit))
-}
-func (l Link) Flow(credit int) {
-	C.pn_link_flow(l.pn, C.int(credit))
-}
-func (l Link) Drain(credit int) {
-	C.pn_link_drain(l.pn, C.int(credit))
-}
-func (l Link) SetDrain(drain bool) {
-	C.pn_link_set_drain(l.pn, C.bool(drain))
-}
-func (l Link) Draining() bool {
-	return bool(C.pn_link_draining(l.pn))
-}
-
-// Wrappers for declarations in delivery.h
-
-type Delivery struct{ pn *C.pn_delivery_t }
-
-func (d Delivery) IsNil() bool { return d.pn == nil }
-func (d Delivery) Tag() DeliveryTag {
-	return DeliveryTag{C.pn_delivery_tag(d.pn)}
-}
-func (d Delivery) Link() Link {
-	return Link{C.pn_delivery_link(d.pn)}
-}
-func (d Delivery) Local() Disposition {
-	return Disposition{C.pn_delivery_local(d.pn)}
-}
-func (d Delivery) LocalState() uint64 {
-	return uint64(C.pn_delivery_local_state(d.pn))
-}
-func (d Delivery) Remote() Disposition {
-	return Disposition{C.pn_delivery_remote(d.pn)}
-}
-func (d Delivery) RemoteState() uint64 {
-	return uint64(C.pn_delivery_remote_state(d.pn))
-}
-func (d Delivery) Settled() bool {
-	return bool(C.pn_delivery_settled(d.pn))
-}
-func (d Delivery) Pending() uint {
-	return uint(C.pn_delivery_pending(d.pn))
-}
-func (d Delivery) Partial() bool {
-	return bool(C.pn_delivery_partial(d.pn))
-}
-func (d Delivery) Writable() bool {
-	return bool(C.pn_delivery_writable(d.pn))
-}
-func (d Delivery) Readable() bool {
-	return bool(C.pn_delivery_readable(d.pn))
-}
-func (d Delivery) Updated() bool {
-	return bool(C.pn_delivery_updated(d.pn))
-}
-func (d Delivery) Update(state uint64) {
-	C.pn_delivery_update(d.pn, C.uint64_t(state))
-}
-func (d Delivery) Clear() {
-	C.pn_delivery_clear(d.pn)
-}
-func (d Delivery) Current() bool {
-	return bool(C.pn_delivery_current(d.pn))
-}
-func (d Delivery) Settle() {
-	C.pn_delivery_settle(d.pn)
-}
-func (d Delivery) Dump() {
-	C.pn_delivery_dump(d.pn)
-}
-func (d Delivery) Buffered() bool {
-	return bool(C.pn_delivery_buffered(d.pn))
-}
-
-// Wrappers for declarations in disposition.h
-
-type Disposition struct{ pn *C.pn_disposition_t }
-
-func (d Disposition) IsNil() bool { return d.pn == nil }
-func (d Disposition) Type() uint64 {
-	return uint64(C.pn_disposition_type(d.pn))
-}
-func (d Disposition) Condition() Condition {
-	return Condition{C.pn_disposition_condition(d.pn)}
-}
-func (d Disposition) Data() Data {
-	return Data{C.pn_disposition_data(d.pn)}
-}
-func (d Disposition) SectionNumber() uint16 {
-	return uint16(C.pn_disposition_get_section_number(d.pn))
-}
-func (d Disposition) SetSectionNumber(section_number uint16) {
-	C.pn_disposition_set_section_number(d.pn, C.uint32_t(section_number))
-}
-func (d Disposition) SectionOffset() uint64 {
-	return uint64(C.pn_disposition_get_section_offset(d.pn))
-}
-func (d Disposition) SetSectionOffset(section_offset uint64) {
-	C.pn_disposition_set_section_offset(d.pn, C.uint64_t(section_offset))
-}
-func (d Disposition) IsFailed() bool {
-	return bool(C.pn_disposition_is_failed(d.pn))
-}
-func (d Disposition) SetFailed(failed bool) {
-	C.pn_disposition_set_failed(d.pn, C.bool(failed))
-}
-func (d Disposition) IsUndeliverable() bool {
-	return bool(C.pn_disposition_is_undeliverable(d.pn))
-}
-func (d Disposition) SetUndeliverable(undeliverable bool) {
-	C.pn_disposition_set_undeliverable(d.pn, C.bool(undeliverable))
-}
-func (d Disposition) Annotations() Data {
-	return Data{C.pn_disposition_annotations(d.pn)}
-}
-
-// Wrappers for declarations in condition.h
-
-type Condition struct{ pn *C.pn_condition_t }
-
-func (c Condition) IsNil() bool { return c.pn == nil }
-func (c Condition) IsSet() bool {
-	return bool(C.pn_condition_is_set(c.pn))
-}
-func (c Condition) Clear() {
-	C.pn_condition_clear(c.pn)
-}
-func (c Condition) Name() string {
-	return C.GoString(C.pn_condition_get_name(c.pn))
-}
-func (c Condition) SetName(name string) int {
-	nameC := C.CString(name)
-	defer C.free(unsafe.Pointer(nameC))
-
-	return int(C.pn_condition_set_name(c.pn, nameC))
-}
-func (c Condition) Description() string {
-	return C.GoString(C.pn_condition_get_description(c.pn))
-}
-func (c Condition) SetDescription(description string) int {
-	descriptionC := C.CString(description)
-	defer C.free(unsafe.Pointer(descriptionC))
-
-	return int(C.pn_condition_set_description(c.pn, descriptionC))
-}
-func (c Condition) Info() Data {
-	return Data{C.pn_condition_info(c.pn)}
-}
-func (c Condition) IsRedirect() bool {
-	return bool(C.pn_condition_is_redirect(c.pn))
-}
-func (c Condition) RedirectHost() string {
-	return C.GoString(C.pn_condition_redirect_host(c.pn))
-}
-func (c Condition) RedirectPort() int {
-	return int(C.pn_condition_redirect_port(c.pn))
-}
-
-// Wrappers for declarations in terminus.h
-
-type TerminusType C.pn_terminus_type_t
-
-const (
-	PnUnspecified TerminusType = C.PN_UNSPECIFIED
-	PnSource      TerminusType = C.PN_SOURCE
-	PnTarget      TerminusType = C.PN_TARGET
-	PnCoordinator TerminusType = C.PN_COORDINATOR
-)
-
-func (e TerminusType) String() string {
-	switch e {
-
-	case C.PN_UNSPECIFIED:
-		return "Unspecified"
-	case C.PN_SOURCE:
-		return "Source"
-	case C.PN_TARGET:
-		return "Target"
-	case C.PN_COORDINATOR:
-		return "Coordinator"
-	}
-	return "unknown"
-}
-
-type Durability C.pn_durability_t
-
-const (
-	PnNondurable    Durability = C.PN_NONDURABLE
-	PnConfiguration Durability = C.PN_CONFIGURATION
-	PnDeliveries    Durability = C.PN_DELIVERIES
-)
-
-func (e Durability) String() string {
-	switch e {
-
-	case C.PN_NONDURABLE:
-		return "Nondurable"
-	case C.PN_CONFIGURATION:
-		return "Configuration"
-	case C.PN_DELIVERIES:
-		return "Deliveries"
-	}
-	return "unknown"
-}
-
-type ExpiryPolicy C.pn_expiry_policy_t
-
-const (
-	PnExpireWithLink       ExpiryPolicy = C.PN_EXPIRE_WITH_LINK
-	PnExpireWithSession    ExpiryPolicy = C.PN_EXPIRE_WITH_SESSION
-	PnExpireWithConnection ExpiryPolicy = C.PN_EXPIRE_WITH_CONNECTION
-	PnExpireNever          ExpiryPolicy = C.PN_EXPIRE_NEVER
-)
-
-func (e ExpiryPolicy) String() string {
-	switch e {
-
-	case C.PN_EXPIRE_WITH_LINK:
-		return "ExpireWithLink"
-	case C.PN_EXPIRE_WITH_SESSION:
-		return "ExpireWithSession"
-	case C.PN_EXPIRE_WITH_CONNECTION:
-		return "ExpireWithConnection"
-	case C.PN_EXPIRE_NEVER:
-		return "ExpireNever"
-	}
-	return "unknown"
-}
-
-type DistributionMode C.pn_distribution_mode_t
-
-const (
-	PnDistModeUnspecified DistributionMode = C.PN_DIST_MODE_UNSPECIFIED
-	PnDistModeCopy        DistributionMode = C.PN_DIST_MODE_COPY
-	PnDistModeMove        DistributionMode = C.PN_DIST_MODE_MOVE
-)
-
-func (e DistributionMode) String() string {
-	switch e {
-
-	case C.PN_DIST_MODE_UNSPECIFIED:
-		return "DistModeUnspecified"
-	case C.PN_DIST_MODE_COPY:
-		return "DistModeCopy"
-	case C.PN_DIST_MODE_MOVE:
-		return "DistModeMove"
-	}
-	return "unknown"
-}
-
-type Terminus struct{ pn *C.pn_terminus_t }
-
-func (t Terminus) IsNil() bool { return t.pn == nil }
-func (t Terminus) Type() TerminusType {
-	return TerminusType(C.pn_terminus_get_type(t.pn))
-}
-func (t Terminus) SetType(type_ TerminusType) int {
-	return int(C.pn_terminus_set_type(t.pn, C.pn_terminus_type_t(type_)))
-}
-func (t Terminus) Address() string {
-	return C.GoString(C.pn_terminus_get_address(t.pn))
-}
-func (t Terminus) SetAddress(address string) int {
-	addressC := C.CString(address)
-	defer C.free(unsafe.Pointer(addressC))
-
-	return int(C.pn_terminus_set_address(t.pn, addressC))
-}
-func (t Terminus) SetDistributionMode(mode DistributionMode) int {
-	return int(C.pn_terminus_set_distribution_mode(t.pn, C.pn_distribution_mode_t(mode)))
-}
-func (t Terminus) Durability() Durability {
-	return Durability(C.pn_terminus_get_durability(t.pn))
-}
-func (t Terminus) SetDurability(durability Durability) int {
-	return int(C.pn_terminus_set_durability(t.pn, C.pn_durability_t(durability)))
-}
-func (t Terminus) ExpiryPolicy() ExpiryPolicy {
-	return ExpiryPolicy(C.pn_terminus_get_expiry_policy(t.pn))
-}
-func (t Terminus) SetExpiryPolicy(policy ExpiryPolicy) int {
-	return int(C.pn_terminus_set_expiry_policy(t.pn, C.pn_expiry_policy_t(policy)))
-}
-func (t Terminus) Timeout() time.Duration {
-	return (time.Duration(C.pn_terminus_get_timeout(t.pn)) * time.Second)
-}
-func (t Terminus) SetTimeout(timeout time.Duration) int {
-	return int(C.pn_terminus_set_timeout(t.pn, C.pn_seconds_t(timeout)))
-}
-func (t Terminus) IsDynamic() bool {
-	return bool(C.pn_terminus_is_dynamic(t.pn))
-}
-func (t Terminus) SetDynamic(dynamic bool) int {
-	return int(C.pn_terminus_set_dynamic(t.pn, C.bool(dynamic)))
-}
-func (t Terminus) Properties() Data {
-	return Data{C.pn_terminus_properties(t.pn)}
-}
-func (t Terminus) Capabilities() Data {
-	return Data{C.pn_terminus_capabilities(t.pn)}
-}
-func (t Terminus) Outcomes() Data {
-	return Data{C.pn_terminus_outcomes(t.pn)}
-}
-func (t Terminus) Filter() Data {
-	return Data{C.pn_terminus_filter(t.pn)}
-}
-func (t Terminus) Copy(src Terminus) int {
-	return int(C.pn_terminus_copy(t.pn, src.pn))
-}
-
-// Wrappers for declarations in connection.h
-
-type Connection struct{ pn *C.pn_connection_t }
-
-func (c Connection) IsNil() bool { return c.pn == nil }
-func (c Connection) Free() {
-	C.pn_connection_free(c.pn)
-}
-func (c Connection) Release() {
-	C.pn_connection_release(c.pn)
-}
-func (c Connection) Error() error {
-	return internal.PnError(unsafe.Pointer(C.pn_connection_error(c.pn)))
-}
-func (c Connection) State() State {
-	return State(C.pn_connection_state(c.pn))
-}
-func (c Connection) Open() {
-	C.pn_connection_open(c.pn)
-}
-func (c Connection) Close() {
-	C.pn_connection_close(c.pn)
-}
-func (c Connection) Reset() {
-	C.pn_connection_reset(c.pn)
-}
-func (c Connection) Condition() Condition {
-	return Condition{C.pn_connection_condition(c.pn)}
-}
-func (c Connection) RemoteCondition() Condition {
-	return Condition{C.pn_connection_remote_condition(c.pn)}
-}
-func (c Connection) Container() string {
-	return C.GoString(C.pn_connection_get_container(c.pn))
-}
-func (c Connection) SetContainer(container string) {
-	containerC := C.CString(container)
-	defer C.free(unsafe.Pointer(containerC))
-
-	C.pn_connection_set_container(c.pn, containerC)
-}
-func (c Connection) SetUser(user string) {
-	userC := C.CString(user)
-	defer C.free(unsafe.Pointer(userC))
-
-	C.pn_connection_set_user(c.pn, userC)
-}
-func (c Connection) SetPassword(password string) {
-	passwordC := C.CString(password)
-	defer C.free(unsafe.Pointer(passwordC))
-
-	C.pn_connection_set_password(c.pn, passwordC)
-}
-func (c Connection) User() string {
-	return C.GoString(C.pn_connection_get_user(c.pn))
-}
-func (c Connection) Hostname() string {
-	return C.GoString(C.pn_connection_get_hostname(c.pn))
-}
-func (c Connection) SetHostname(hostname string) {
-	hostnameC := C.CString(hostname)
-	defer C.free(unsafe.Pointer(hostnameC))
-
-	C.pn_connection_set_hostname(c.pn, hostnameC)
-}
-func (c Connection) RemoteContainer() string {
-	return C.GoString(C.pn_connection_remote_container(c.pn))
-}
-func (c Connection) RemoteHostname() string {
-	return C.GoString(C.pn_connection_remote_hostname(c.pn))
-}
-func (c Connection) OfferedCapabilities() Data {
-	return Data{C.pn_connection_offered_capabilities(c.pn)}
-}
-func (c Connection) DesiredCapabilities() Data {
-	return Data{C.pn_connection_desired_capabilities(c.pn)}
-}
-func (c Connection) Properties() Data {
-	return Data{C.pn_connection_properties(c.pn)}
-}
-func (c Connection) RemoteOfferedCapabilities() Data {
-	return Data{C.pn_connection_remote_offered_capabilities(c.pn)}
-}
-func (c Connection) RemoteDesiredCapabilities() Data {
-	return Data{C.pn_connection_remote_desired_capabilities(c.pn)}
-}
-func (c Connection) RemoteProperties() Data {
-	return Data{C.pn_connection_remote_properties(c.pn)}
-}

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/132820cb/proton-c/bindings/go/src/qpid.apache.org/proton/internal/error.go
----------------------------------------------------------------------
diff --git a/proton-c/bindings/go/src/qpid.apache.org/proton/internal/error.go b/proton-c/bindings/go/src/qpid.apache.org/proton/internal/error.go
deleted file mode 100644
index 01ba890..0000000
--- a/proton-c/bindings/go/src/qpid.apache.org/proton/internal/error.go
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
-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.
-*/
-
-// Internal implementation details - ignore.
-package internal
-
-// #cgo LDFLAGS: -lqpid-proton
-// #include <proton/error.h>
-// #include <proton/codec.h>
-import "C"
-
-import (
-	"fmt"
-	"runtime"
-	"sync"
-	"sync/atomic"
-	"unsafe"
-)
-
-// Error type for all proton errors.
-type Error string
-
-// Error prefixes error message with proton:
-func (e Error) Error() string {
-	return "proton: " + string(e)
-}
-
-// Errorf creates an Error with a formatted message
-func Errorf(format string, a ...interface{}) Error {
-	return Error(fmt.Sprintf(format, a...))
-}
-
-type PnErrorCode int
-
-func (e PnErrorCode) String() string {
-	switch e {
-	case C.PN_EOS:
-		return "end-of-data"
-	case C.PN_ERR:
-		return "error"
-	case C.PN_OVERFLOW:
-		return "overflow"
-	case C.PN_UNDERFLOW:
-		return "underflow"
-	case C.PN_STATE_ERR:
-		return "bad-state"
-	case C.PN_ARG_ERR:
-		return "invalid-argument"
-	case C.PN_TIMEOUT:
-		return "timeout"
-	case C.PN_INTR:
-		return "interrupted"
-	case C.PN_INPROGRESS:
-		return "in-progress"
-	default:
-		return fmt.Sprintf("unknown-error(%d)", e)
-	}
-}
-
-func PnError(p unsafe.Pointer) error {
-	e := (*C.pn_error_t)(p)
-	if e == nil || C.pn_error_code(e) == 0 {
-		return nil
-	}
-	return Errorf("%s: %s", PnErrorCode(C.pn_error_code(e)), C.GoString(C.pn_error_text(e)))
-}
-
-// DoRecover is called to recover from internal panics
-func DoRecover(err *error) {
-	r := recover()
-	switch r := r.(type) {
-	case nil: // We are not recovering
-		return
-	case runtime.Error: // Don't catch runtime.Error
-		panic(r)
-	case error:
-		*err = r
-	default:
-		panic(r)
-	}
-}
-
-// panicIf panics if condition is true, the panic value is Errorf(fmt, args...)
-func panicIf(condition bool, fmt string, args ...interface{}) {
-	if condition {
-		panic(Errorf(fmt, args...))
-	}
-}
-
-// FirstError is a goroutine-safe error holder that keeps the first error that is set.
-type FirstError struct {
-	err  atomic.Value
-	once sync.Once
-}
-
-// Set the error if not allread set.
-func (e *FirstError) Set(err error) {
-	e.once.Do(func() { e.err.Store(err) })
-}
-
-// Get the error.
-func (e *FirstError) Get() error {
-	v := e.err.Load()
-	if v != nil {
-		return v.(error)
-	} else {
-		return nil
-	}
-}


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


[32/50] [abbrv] qpid-proton git commit: Merge pull request #1 from kgiusti/PROTON-885-flaper87

Posted by ac...@apache.org.
Merge pull request #1 from kgiusti/PROTON-885-flaper87

PROTON-885: update the top-level license file

Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/786ba2ad
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/786ba2ad
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/786ba2ad

Branch: refs/heads/cjansen-cpp-client
Commit: 786ba2ad36d9e88eb1ca68d84d2b0634fd23d54f
Parents: 2e2ba9c 59afc55
Author: Flavio Percoco Premoli <fl...@gmail.com>
Authored: Tue May 19 22:09:06 2015 +0200
Committer: Flavio Percoco Premoli <fl...@gmail.com>
Committed: Tue May 19 22:09:06 2015 +0200

----------------------------------------------------------------------
 LICENSE | 5 +++++
 1 file changed, 5 insertions(+)
----------------------------------------------------------------------



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


[03/50] [abbrv] qpid-proton git commit: Merge branch 'pr-27'

Posted by ac...@apache.org.
Merge branch 'pr-27'

Closes #27


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/d39f2228
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/d39f2228
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/d39f2228

Branch: refs/heads/cjansen-cpp-client
Commit: d39f22283275d5993808b467dd82d24f7a0184fe
Parents: 30efcdb c31b068
Author: Dominic Evans <do...@uk.ibm.com>
Authored: Mon May 11 09:40:48 2015 +0100
Committer: Dominic Evans <do...@uk.ibm.com>
Committed: Mon May 11 09:43:06 2015 +0100

----------------------------------------------------------------------
 proton-c/src/buffer.c             | 34 ++++++++++++++++++++++++----------
 proton-c/src/error.c              |  8 +++++---
 proton-c/src/messenger/store.c    | 22 ++++++++++++----------
 proton-c/src/object/map.c         | 12 +++++++-----
 proton-c/src/object/object.c      |  9 ++++++---
 proton-c/src/parser.c             | 10 ++++++----
 tests/tools/apps/c/reactor-recv.c |  8 ++++++--
 7 files changed, 66 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/d39f2228/proton-c/src/object/map.c
----------------------------------------------------------------------


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


[02/50] [abbrv] qpid-proton git commit: NO-JIRA: Make pn_strcasecmp() etc. work correctly with 8 bit chars.

Posted by ac...@apache.org.
NO-JIRA: Make pn_strcasecmp() etc. work correctly with 8 bit chars.


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/30efcdbe
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/30efcdbe
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/30efcdbe

Branch: refs/heads/cjansen-cpp-client
Commit: 30efcdbea5015e03d77b388d8c0a6979a2392325
Parents: fa52f4e
Author: Andrew Stitcher <as...@apache.org>
Authored: Fri May 8 16:53:16 2015 -0400
Committer: Andrew Stitcher <as...@apache.org>
Committed: Fri May 8 16:53:16 2015 -0400

----------------------------------------------------------------------
 proton-c/src/util.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/30efcdbe/proton-c/src/util.c
----------------------------------------------------------------------
diff --git a/proton-c/src/util.c b/proton-c/src/util.c
index 2b560a6..e2c6727 100644
--- a/proton-c/src/util.c
+++ b/proton-c/src/util.c
@@ -214,7 +214,7 @@ void pni_fatal(const char *fmt, ...)
 
 int pn_strcasecmp(const char *a, const char *b)
 {
-  char diff;
+  int diff;
   while (*b) {
     diff = tolower(*a++)-tolower(*b++);
     if ( diff!=0 ) return diff;
@@ -224,7 +224,7 @@ int pn_strcasecmp(const char *a, const char *b)
 
 int pn_strncasecmp(const char* a, const char* b, size_t len)
 {
-  char diff = 0;
+  int diff = 0;
   while (*b && len > 0) {
     diff = tolower(*a++)-tolower(*b++);
     if ( diff!=0 ) return diff;


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