blob: 7363ef7946907a17438941e52c4cb98de86508c3 [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 Afanasyeveda3b7a2016-12-25 11:26:40 -080023#include "ccnx-wrapper.hpp"
Alexander Afanasyevf4cde4e2016-12-25 13:42:57 -080024#include "dispatcher.hpp"
25#include "fs-watcher.hpp"
26#include "logging.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
Alexander Afanasyeveda3b7a2016-12-25 11:26:40 -080034int
35main(int argc, char* argv[])
Alexander Afanasyev548d38d2013-01-26 16:36:06 -080036{
Alexander Afanasyeveda3b7a2016-12-25 11:26:40 -080037 INIT_LOGGERS();
Alexander Afanasyev548d38d2013-01-26 16:36:06 -080038
Alexander Afanasyev2b0363a2013-01-28 21:42:12 -080039 QCoreApplication app(argc, argv);
40
Alexander Afanasyeveda3b7a2016-12-25 11:26:40 -080041 if (argc != 4) {
42 cerr << "Usage: ./csd <username> <shared-folder> <path>" << endl;
43 return 1;
44 }
Alexander Afanasyev548d38d2013-01-26 16:36:06 -080045
46 string username = argv[1];
47 string sharedFolder = argv[2];
48 string path = argv[3];
49
Alexander Afanasyeveda3b7a2016-12-25 11:26:40 -080050 cout << "Starting ChronoShare for [" << username << "] shared-folder [" << sharedFolder
51 << "] at [" << path << "]" << endl;
Alexander Afanasyev548d38d2013-01-26 16:36:06 -080052
Alexander Afanasyeveda3b7a2016-12-25 11:26:40 -080053 Dispatcher dispatcher(username, sharedFolder, path, make_shared<CcnxWrapper>());
Alexander Afanasyev548d38d2013-01-26 16:36:06 -080054
Alexander Afanasyeveda3b7a2016-12-25 11:26:40 -080055 FsWatcher watcher(path.c_str(),
56 bind(&Dispatcher::Did_LocalFile_AddOrModify, &dispatcher, _1),
57 bind(&Dispatcher::Did_LocalFile_Delete, &dispatcher, _1));
Alexander Afanasyev548d38d2013-01-26 16:36:06 -080058
Alexander Afanasyeveda3b7a2016-12-25 11:26:40 -080059 return app.exec();
Alexander Afanasyev548d38d2013-01-26 16:36:06 -080060}