1 /***************************************************************************
3 * Copyright (C) 2006 David Brodsky *
5 * This program is free software; you can redistribute it and/or *
6 * modify it under the terms of the GNU General Public License as *
7 * published by the Free Software Foundation and appearing *
8 * in the file LICENSE.GPL included in the packaging of this file. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
13 * General Public License for more details. *
15 ***************************************************************************/
17 #include <tairon/core/log.h>
18 #include <tairon/core/modulemanager.h>
19 #include <tairon/core/signals.h>
20 #include <tairon/core/threadmanager.h>
21 #include <tairon/net/limiter.h>
22 #include <tairon/net/limitmanager.h>
24 #include "mainmodule.h"
26 #include "hashcheckerthread.h"
27 #include "mainthread.h"
28 #include "torrentmanager.h"
29 #include "torrentserver.h"
30 #include "trackermanager.h"
38 extern Tairon::Net::Limiter
*rlimiter
;
39 extern Tairon::Net::Limiter
*wlimiter
;
41 /* {{{ MainModule::MainModule() */
42 MainModule::MainModule() : Tairon::Core::Module()
44 // build thread first, because it may be needed by other objects
45 mainThread
= new MainThread();
46 Tairon::Core::ThreadManager::self()->setMainThread(mainThread
);
48 hashCheckerThread
= new HashCheckerThread();
50 trackerManager
= new TrackerManager();
51 torrentManager
= new TorrentManager();
52 torrentServer
= new TorrentServer();
54 limitManager
= new Tairon::Net::LimitManager();
56 rlimiter
= new Tairon::Net::Limiter(500000);
57 wlimiter
= new Tairon::Net::Limiter(500000);
59 Tairon::Core::ModuleManager::self()->initializedSignal
->connect(Tairon::Core::methodFunctor(this, &MainModule::initialized
));
63 /* {{{ MainModule::~MainModule */
64 MainModule::~MainModule()
69 delete torrentManager
;
70 delete trackerManager
;
74 /* {{{ MainModule::initialized() */
75 void MainModule::initialized()
77 INFO("Starting application");
78 torrentManager
->startTorrents();
80 hashCheckerThread
->start();
84 torrentServer
->stop();
85 torrentManager
->stopTorrents();
87 mainThread
->run(); // wait for objects to clean up
89 hashCheckerThread
->stop();
90 hashCheckerThread
->join();
92 torrentManager
->destroy();
98 }; // namespace Tairent
100 EXPORT_MODULE(main
, Tairent::Main::MainModule
)
102 // vim: ai sw=4 ts=4 noet fdm=marker