/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil -*- */
/*
 * Copyright (c) 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>
 */

#include "dispatcher.h"
#include "fs-watcher.h"
#include "logging.h"
#include "ccnx-wrapper.h"

#include <boost/make_shared.hpp>

using namespace boost;
using namespace std;
using namespace Ccnx;

int main(int argc, char *argv[])
{
  INIT_LOGGERS ();

  if (argc != 4)
    {
      cerr << "Usage: ./csd <username> <shared-folder> <path>" << endl;
      return 1;
    }

  string username = argv[1];
  string sharedFolder = argv[2];
  string path = argv[3];

  cout << "Starting ChronoShare for [" << username << "] shared-folder [" << sharedFolder << "] at [" << path << "]" << endl;

  Dispatcher dispatcher (username, sharedFolder, path, make_shared<CcnxWrapper> ());

  FsWatcher watcher (path.c_str (),
                     bind (&Dispatcher::Did_LocalFile_AddOrModify, &dispatcher, _1),
                     bind (&Dispatcher::Did_LocalFile_Delete,      &dispatcher, _1));

  while (true)
    {
      sleep (1);
    }

  return 0;
}
