Add main page for Doxygen generated documentation.
[tairent.git] / src / main / mainmodule.cpp
blobc978500e77cae690d1b25a30582457ceea5a8ce7
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 rlimiter;
67 delete wlimiter;
68 delete limitManager;
69 delete hashCheckerThread;
70 delete mainThread;
71 delete torrentServer;
72 delete torrentManager;
73 delete trackerManager;
75 /* }}} */
77 /* {{{ MainModule::initialized() */
78 void MainModule::initialized()
80 INFO("Starting application");
81 torrentManager->startTorrents();
83 hashCheckerThread->start();
85 mainThread->run();
87 torrentServer->stop();
88 torrentManager->stopTorrents();
90 mainThread->run(); // wait for objects to clean up
92 hashCheckerThread->stop();
93 hashCheckerThread->join();
95 torrentManager->destroy();
97 /* }}} */
99 }; // namespace Main
101 }; // namespace Tairent
103 EXPORT_MODULE(main, Tairent::Main::MainModule)
105 // vim: ai sw=4 ts=4 noet fdm=marker