summaryrefslogtreecommitdiffstats
path: root/src/madc.cpp
diff options
context:
space:
mode:
authorMatthias Schiffer <matthias@gamezock.de>2009-06-18 22:03:02 +0200
committerMatthias Schiffer <matthias@gamezock.de>2009-06-18 22:03:02 +0200
commit7234fe326d16d6bf9f4374a09ddc6ef790e6723f (patch)
tree437d4c40eeb1e9b34b369e4b82064a1572c7dac9 /src/madc.cpp
parentbf561f8226e97f4ace4f04bddf198175e91ee7f0 (diff)
downloadmad-7234fe326d16d6bf9f4374a09ddc6ef790e6723f.tar
mad-7234fe326d16d6bf9f4374a09ddc6ef790e6723f.zip
Globale Variablen durch Application-Klasse ersetzt
Diffstat (limited to 'src/madc.cpp')
-rw-r--r--src/madc.cpp35
1 files changed, 16 insertions, 19 deletions
diff --git a/src/madc.cpp b/src/madc.cpp
index ea32f2f..55c2be7 100644
--- a/src/madc.cpp
+++ b/src/madc.cpp
@@ -18,12 +18,12 @@
*/
#include "Core/ConfigManager.h"
-#include "Core/Logger.h"
-#include "Core/ThreadManager.h"
#include "Common/ClientConnection.h"
#include "Common/RequestManager.h"
#include "Common/Requests/IdentifyRequest.h"
+
+#include "Client/Application.h"
#include "Client/CommandParser.h"
#include "Client/InformationManager.h"
@@ -48,12 +48,11 @@ int main(int argc, char *argv[]) {
std::exit(1);
}
- Core::ThreadManager::get()->init();
- Client::InformationManager::get()->init();
+ Client::Application application;
- Core::ConfigManager::get()->finish();
+ application.getConfigManager()->finish();
- Common::ClientConnection *connection = new Common::ClientConnection;
+ Common::ClientConnection *connection = new Common::ClientConnection(&application);
try {
connection->connect(boost::asio::ip::tcp::endpoint(boost::asio::ip::address::from_string(argv[1]), 6666));
@@ -62,32 +61,32 @@ int main(int argc, char *argv[]) {
connection->waitWhileConnecting();
- Common::RequestManager::get()->registerConnection(connection);
+ application.getRequestManager()->registerConnection(connection);
{
- boost::shared_ptr<Common::Requests::IdentifyRequest> request(new Common::Requests::IdentifyRequest);
- Common::RequestManager::get()->sendRequest(connection, request);
+ boost::shared_ptr<Common::Requests::IdentifyRequest> request(new Common::Requests::IdentifyRequest(&application));
+ application.getRequestManager()->sendRequest(connection, request);
request->wait();
}
std::cerr << " connected." << std::endl;
std::cerr << "Receiving host list..." << std::flush;
- Client::InformationManager::get()->updateDaemonList(connection);
- Client::InformationManager::get()->waitWhileUpdating();
+ application.getInformationManager()->updateDaemonList(connection);
+ application.getInformationManager()->waitWhileUpdating();
std::cerr << " done." << std::endl << std::endl;
- Client::CommandParser::get()->setConnection(connection);
+ Client::CommandParser commandParser(&application, connection);
- while(connection->isConnected() && !Client::CommandParser::get()->willDisconnect()) {
+ while(connection->isConnected() && !commandParser.willDisconnect()) {
char *cmd = readline("mad> ");
if(!cmd) {
- Client::CommandParser::get()->requestDisconnect();
+ commandParser.requestDisconnect();
}
else if(*cmd) {
- Client::CommandParser::get()->parse(cmd);
+ commandParser.parse(cmd);
add_history(cmd);
}
else continue;
@@ -95,15 +94,13 @@ int main(int argc, char *argv[]) {
connection->waitWhileConnected();
- Common::RequestManager::get()->unregisterConnection(connection);
+ application.getRequestManager()->unregisterConnection(connection);
}
catch(Core::Exception &e) {
- Core::Logger::logf(Core::Logger::CRITICAL, "Connection error: %s", e.strerror().c_str());
+ application.logf(Core::LoggerBase::CRITICAL, "Connection error: %s", e.strerror().c_str());
}
delete connection;
- Core::Initializable::deinit();
-
return 0;
}