Send correct informations to a http tracker.
[tairent.git] / src / main / mainmodule.cpp
blob9f8856486cd6015203c68b2b2f6eb6fe2c0e1692
1 /***************************************************************************
2 * *
3 * Copyright (C) 2006 David Brodsky *
4 * *
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. *
9 * *
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. *
14 * *
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"
32 namespace Tairent
35 namespace Main
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));
61 /* }}} */
63 /* {{{ MainModule::~MainModule */
64 MainModule::~MainModule()
66 delete limitManager;
67 delete mainThread;
68 delete torrentServer;
69 delete torrentManager;
70 delete trackerManager;
72 /* }}} */
74 /* {{{ MainModule::initialized() */
75 void MainModule::initialized()
77 INFO("Starting application");
78 torrentManager->startTorrents();
80 hashCheckerThread->start();
82 mainThread->run();
84 torrentServer->stop();
85 torrentManager->stopTorrents();
87 mainThread->run(); // wait for objects to clean up
89 hashCheckerThread->stop();
90 hashCheckerThread->join();
92 torrentManager->destroy();
94 /* }}} */
96 }; // namespace Main
98 }; // namespace Tairent
100 EXPORT_MODULE(main, Tairent::Main::MainModule)
102 // vim: ai sw=4 ts=4 noet fdm=marker