change CcnxWrapper to support fetching of raw data
diff --git a/ccnx/sync-ccnx-wrapper.cc b/ccnx/sync-ccnx-wrapper.cc
index ea0f876..85ffbd6 100644
--- a/ccnx/sync-ccnx-wrapper.cc
+++ b/ccnx/sync-ccnx-wrapper.cc
@@ -235,18 +235,28 @@
              ccn_upcall_kind kind,
              ccn_upcall_info *info)
 {
-  CcnxWrapper::DataCallback *f = static_cast<CcnxWrapper::DataCallback*> (selfp->data);
+  //CcnxWrapper::DataCallback *f = static_cast<CcnxWrapper::DataCallback*> (selfp->data);
+  ClosurePass *cp = static_cast<ClosurePass *> (selfp->data);
 
   switch (kind)
     {
     case CCN_UPCALL_FINAL:  // effecitve in unit tests
-      delete f;
+      delete cp;
+      cp = NULL;
       delete selfp;
       return CCN_UPCALL_RESULT_OK;
 
     case CCN_UPCALL_CONTENT:
       break;
 
+    case CCN_UPCALL_INTEREST_TIMED_OUT: {
+      if (cp != NULL && cp->getRetry() > 0) {
+        cp->decRetry();
+        return CCN_UPCALL_RESULT_REEXPRESS;
+      }
+      return CCN_UPCALL_RESULT_OK;
+    }
+
     default:
       return CCN_UPCALL_RESULT_OK;
     }
@@ -255,7 +265,6 @@
   size_t len;
   if (ccn_content_get_value(info->content_ccnb, info->pco->offset[CCN_PCO_E], info->pco, (const unsigned char **)&pcontent, &len) < 0)
     BOOST_THROW_EXCEPTION(CcnxOperationException() << errmsg_info_str("decode ContentObject failed"));
-  string content(pcontent, len);
 
   string name;
   for (int i = 0; i < info->content_comps->n - 1; i++)
@@ -267,11 +276,25 @@
       string compStr(comp, size);
       name += compStr;
     }
-  (*f) (name, content);
+
+  cp->runCallback(name, pcontent, len);
+
   return CCN_UPCALL_RESULT_OK;
 }
 
-int CcnxWrapper::sendInterest (const string &strInterest, const DataCallback &dataCallback)
+int CcnxWrapper::sendInterest (const string &strInterest, const DataCallback &dataCallback, int retry)
+{
+  DataClosurePass * pass = new DataClosurePass(STRING_FORM, retry, dataCallback);
+  sendInterest(strInterest, pass);
+}
+
+int CcnxWrapper::sendInterestForRawData (const string &strInterest, const RawDataCallback &rawDataCallback, int retry)
+{
+  RawDataClosurePass * pass = new RawDataClosurePass(RAW_DATA, retry, rawDataCallback);
+  sendInterest(strInterest, pass);
+}
+
+int CcnxWrapper::sendInterest (const string &strInterest, void *dataPass)
 {
   recursive_mutex::scoped_lock lock(m_mutex);
   if (!m_running)
@@ -282,7 +305,7 @@
   ccn_closure *dataClosure = new ccn_closure;
 
   ccn_name_from_uri (pname, strInterest.c_str());
-  dataClosure->data = new DataCallback (dataCallback); // should be removed when closure is removed
+  dataClosure->data = dataPass;
 
   dataClosure->p = &incomingData;
   if (ccn_express_interest (m_handle, pname, dataClosure, NULL) < 0)
@@ -333,4 +356,44 @@
   ccn_charbuf_destroy(&pname);
 }
 
+DataClosurePass::DataClosurePass (CallbackType type, int retry, const CcnxWrapper::DataCallback &dataCallback): ClosurePass(type, retry), m_callback(NULL)
+{
+   m_callback = new CcnxWrapper::DataCallback (dataCallback); 
+}
+
+DataClosurePass::~DataClosurePass () 
+{
+  delete m_callback;
+  m_callback = NULL;
+}
+
+void 
+DataClosurePass::runCallback(std::string name, const char *data, size_t len) 
+{
+  string content(data, len);
+  if (m_callback != NULL) {
+    (*m_callback)(name, content);
+  }
+}
+
+
+RawDataClosurePass::RawDataClosurePass (CallbackType type, int retry, const CcnxWrapper::RawDataCallback &rawDataCallback): ClosurePass(type, retry), m_callback(NULL)
+{
+   m_callback = new CcnxWrapper::RawDataCallback (rawDataCallback); 
+}
+
+RawDataClosurePass::~RawDataClosurePass () 
+{
+  delete m_callback;
+  m_callback = NULL;
+}
+
+void 
+RawDataClosurePass::runCallback(std::string name, const char *data, size_t len) 
+{
+  if (m_callback != NULL) {
+    (*m_callback)(name, data, len);
+  }
+}
+
 }