blob: dc65f209212e5af953e5946e4526eca7bda78cb2 [file] [log] [blame]
Alexander Afanasyevfa2f6622016-12-25 12:28:00 -08001/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/**
3 * Copyright (c) 2013-2016, Regents of the University of California.
Alexander Afanasyev548d38d2013-01-26 16:36:06 -08004 *
Alexander Afanasyevfa2f6622016-12-25 12:28:00 -08005 * This file is part of ChronoShare, a decentralized file sharing application over NDN.
Alexander Afanasyev548d38d2013-01-26 16:36:06 -08006 *
Alexander Afanasyevfa2f6622016-12-25 12:28:00 -08007 * ChronoShare is free software: you can redistribute it and/or modify it under the terms
8 * of the GNU General Public License as published by the Free Software Foundation, either
9 * version 3 of the License, or (at your option) any later version.
Alexander Afanasyev548d38d2013-01-26 16:36:06 -080010 *
Alexander Afanasyevfa2f6622016-12-25 12:28:00 -080011 * ChronoShare is distributed in the hope that it will be useful, but WITHOUT ANY
12 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
13 * PARTICULAR PURPOSE. See the GNU General Public License for more details.
Alexander Afanasyev548d38d2013-01-26 16:36:06 -080014 *
Alexander Afanasyevfa2f6622016-12-25 12:28:00 -080015 * You should have received copies of the GNU General Public License along with
16 * ChronoShare, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
17 *
18 * See AUTHORS.md for complete list of ChronoShare authors and contributors.
Alexander Afanasyev548d38d2013-01-26 16:36:06 -080019 */
20
Alexander Afanasyev2b0363a2013-01-28 21:42:12 -080021#include <QtCore>
22
Alexander Afanasyevf4cde4e2016-12-25 13:42:57 -080023#include "dispatcher.hpp"
24#include "fs-watcher.hpp"
25#include "logging.hpp"
26#include "ccnx-wrapper.hpp"
Alexander Afanasyev548d38d2013-01-26 16:36:06 -080027
28#include <boost/make_shared.hpp>
29
30using namespace boost;
31using namespace std;
Alexander Afanasyev1dd37ed2013-08-14 18:08:09 -070032using namespace Ndnx;
Alexander Afanasyev548d38d2013-01-26 16:36:06 -080033
34int main(int argc, char *argv[])
35{
36 INIT_LOGGERS ();
37
Alexander Afanasyev2b0363a2013-01-28 21:42:12 -080038 QCoreApplication app(argc, argv);
39
Alexander Afanasyev548d38d2013-01-26 16:36:06 -080040 if (argc != 4)
41 {
42 cerr << "Usage: ./csd <username> <shared-folder> <path>" << endl;
43 return 1;
44 }
45
46 string username = argv[1];
47 string sharedFolder = argv[2];
48 string path = argv[3];
49
50 cout << "Starting ChronoShare for [" << username << "] shared-folder [" << sharedFolder << "] at [" << path << "]" << endl;
51
Alexander Afanasyev1dd37ed2013-08-14 18:08:09 -070052 Dispatcher dispatcher (username, sharedFolder, path, make_shared<NdnxWrapper> ());
Alexander Afanasyev548d38d2013-01-26 16:36:06 -080053
54 FsWatcher watcher (path.c_str (),
55 bind (&Dispatcher::Did_LocalFile_AddOrModify, &dispatcher, _1),
Zhenkai Zhud1756272013-02-01 17:02:18 -080056 bind (&Dispatcher::Did_LocalFile_Delete, &dispatcher, _1));
Alexander Afanasyev548d38d2013-01-26 16:36:06 -080057
Alexander Afanasyev2b0363a2013-01-28 21:42:12 -080058 return app.exec ();
Alexander Afanasyev548d38d2013-01-26 16:36:06 -080059}