Initial stuff for fetcher
diff --git a/src/chronoshare-client.ice b/src/fetch-manager.cc
similarity index 63%
rename from src/chronoshare-client.ice
rename to src/fetch-manager.cc
index c2e056f..ba24f97 100644
--- a/src/chronoshare-client.ice
+++ b/src/fetch-manager.cc
@@ -19,16 +19,28 @@
  *	   Zhenkai Zhu <zhenkai@cs.ucla.edu>
  */
 
-module ChronoshareClient
+#include "fetch-manager.h"
+#include <boost/make_shared.hpp>
+#include <boost/ref.hpp>
+#include <boost/throw_exception.hpp>
+
+using namespace boost;
+using namespace std;
+using namespace Ccnx;
+
+FetchManager::FetchManager (CcnxWrapperPtr ccnx, SyncLogPtr sync)
+  : m_ccnx (ccnx)
+  , m_sync (sync)
 {
-  sequence<byte> HashBytes;
-  
-  interface Notify 
-  {
-    void updateFile (string filename, ["cpp:array"] HashBytes fileHash, long wtime, int mode);
+  m_scheduler.start ();
+}
 
-    void moveFile (string origFilename, string newFilename);
+FetchManager::~FetchManager ()
+{
+  m_scheduler.shutdown ();
+}
 
-    void deleteFile (string filename);
-  };
-};
+void
+FetchManager::Enqueue (const Ccnx::Name &deviceName, uint32_t minSeqNo, uint32_t maxSeqNo, int priority/*=PRIORITY_NORMAL*/)
+{
+}
diff --git a/src/fetch-manager.h b/src/fetch-manager.h
new file mode 100644
index 0000000..5efd838
--- /dev/null
+++ b/src/fetch-manager.h
@@ -0,0 +1,65 @@
+/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
+/*
+ * Copyright (c) 2012-2013 University of California, Los Angeles
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation;
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ * Author: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+ *	   Zhenkai Zhu <zhenkai@cs.ucla.edu>
+ */
+
+#ifndef FETCH_MANAGER_H
+#define FETCH_MANAGER_H
+
+#include <boost/exception/all.hpp>
+#include <boost/shared_ptr.hpp>
+#include <string>
+#include <stdint.h>
+#include "scheduler.h"
+
+#include "ccnx-wrapper.h"
+#include "ccnx-tunnel.h"
+#include "sync-log.h"
+
+class FetchManager
+{
+  enum
+    {
+      PRIORITY_NORMAL,
+      PRIORITY_HIGH
+    };
+
+public:
+  FetchManager (Ccnx::CcnxWrapperPtr ccnx, SyncLogPtr sync);
+  virtual ~FetchManager ();
+
+  void
+  Enqueue (const Ccnx::Name &deviceName, uint32_t minSeqNo, uint32_t maxSeqNo, int priority=PRIORITY_NORMAL);
+  
+private:
+  Ccnx::CcnxWrapperPtr m_ccnx;
+  SyncLogPtr m_sync; // to access forwarding hints
+  Scheduler m_scheduler;
+};
+
+
+typedef boost::error_info<struct tag_errmsg, std::string> errmsg_info_str; 
+namespace Error {
+struct Fetcher : virtual boost::exception, virtual std::exception { };
+}
+
+typedef boost::shared_ptr<FetchManager> FetchManagerPtr;
+
+
+#endif // FETCHER_H
diff --git a/src/fetcher.cc b/src/fetcher.cc
index e021540..d0a6788 100644
--- a/src/fetcher.cc
+++ b/src/fetcher.cc
@@ -26,45 +26,23 @@
 
 using namespace boost;
 using namespace std;
-namespace fs = boost::filesystem;
 
-const std::string INIT_DATABASE = "\
-PRAGMA foreign_keys = ON;           \
-                                    \
-CREATE TABLE                                     \
-    Queue(                                       \
-        name     BLOB NOT NULL PRIMARY KEY,      \
-        seq_no_rcvd INTEGER,                     \
-        seq_no_available INTEGER,                \
-    );                                           \
-";
+Fetcher::Fetcher (Ccnx::CcnxWrapperPtr ccnx, SchedulerPtr scheduler,
+                  const Ccnx::Name &name, int32_t minSeqNo, int32_t maxSeqNo,
+                  const Ccnx::Name &forwardingHint/* = Ccnx::Name ()*/)
+  : m_ccnx (ccnx)
+  , m_scheduler (scheduler)
+  , m_name (name)
+  , m_forwardingHint (forwardingHint)
+  , m_minSendSeqNo (-1)
+  , m_maxSendSeqNo (-1)
+  , m_minSeqNo (minSeqNo)
+  , m_maxSeqNo (maxSeqNo)
 
-Fetcher::Fetcher (const fs::path &path, const string &name)
+  , m_pipeline (6) // initial "congestion window"
 {
-  fs::path chronoshareDirectory = path / ".chronoshare";
-  fs::create_directories (chronoshareDirectory);
-  
-  int res = sqlite3_open((chronoshareDirectory / (name+".db")).c_str (), &m_db);
-  if (res != SQLITE_OK)
-    {
-      BOOST_THROW_EXCEPTION (Error::Fetcher ()
-                             << errmsg_info_str ("Cannot open/create dabatabase: [" + (chronoshareDirectory / (name+".db")).string () + "]"));
-    }
-  
-  char *errmsg = 0;
-  res = sqlite3_exec (m_db, INIT_DATABASE.c_str (), NULL, NULL, &errmsg);
-  if (res != SQLITE_OK && errmsg != 0)
-    {
-      // std::cerr << "DEBUG: " << errmsg << std::endl;
-      sqlite3_free (errmsg);
-    }
 }
 
 Fetcher::~Fetcher ()
 {
-  int res = sqlite3_close (m_db);
-  if (res != SQLITE_OK)
-    {
-      // complain
-    }
 }
diff --git a/src/fetcher.h b/src/fetcher.h
index 8cb4664..fba4f29 100644
--- a/src/fetcher.h
+++ b/src/fetcher.h
@@ -22,26 +22,34 @@
 #ifndef FETCHER_H
 #define FETCHER_H
 
-#include <stdint.h>
-#include <sqlite3.h>
-#include <boost/exception/all.hpp>
-#include <string>
-#include <boost/filesystem.hpp>
+#include "ccnx-wrapper.h"
+#include "scheduler.h"
 
-typedef boost::error_info<struct tag_errmsg, std::string> errmsg_info_str; 
-
-class Fetcher
+class Fetcher 
 {
 public:
-  Fetcher (const boost::filesystem::path &path, const std::string &name);
+  Fetcher (Ccnx::CcnxWrapperPtr ccnx, SchedulerPtr scheduler,
+           const Ccnx::Name &name, int32_t minSeqNo, int32_t maxSeqNo,
+           const Ccnx::Name &forwardingHint = Ccnx::Name ());
   virtual ~Fetcher ();
   
 private:
+  Ccnx::CcnxWrapperPtr m_ccnx;
+  SchedulerPtr m_scheduler;
+  
+  Ccnx::Name m_name;
+  Ccnx::Name m_forwardingHint;
+  
+  int32_t m_minSendSeqNo;
+  int32_t m_maxSendSeqNo;
+  int32_t m_minSeqNo;
+  int32_t m_maxSeqNo;
 
-protected:
-  sqlite3 *m_db;
+  uint32_t m_pipeline;
 };
 
+typedef boost::error_info<struct tag_errmsg, std::string> errmsg_info_str; 
+
 namespace Error {
 struct Fetcher : virtual boost::exception, virtual std::exception { };
 }