diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mad-core.cpp | 16 | ||||
-rw-r--r-- | src/mad.cpp | 34 | ||||
-rw-r--r-- | src/madc.cpp | 24 |
3 files changed, 41 insertions, 33 deletions
diff --git a/src/mad-core.cpp b/src/mad-core.cpp index 40c3654..f621967 100644 --- a/src/mad-core.cpp +++ b/src/mad-core.cpp @@ -22,8 +22,12 @@ #include "Net/Connection.h" #include "Core/ConnectionManager.h" #include "Core/ConfigManager.h" + #include <signal.h> +using namespace Mad; + + int main() { sigset_t signals; @@ -31,15 +35,15 @@ int main() { sigaddset(&signals, SIGPIPE); sigprocmask(SIG_BLOCK, &signals, 0); - Mad::Common::Backends::ConsoleLogger logger; - Mad::Common::Logger::registerLogger(&logger); + Common::Backends::ConsoleLogger logger; + Common::Logger::registerLogger(&logger); - Mad::Core::ConfigManager::useConfigManager(); - Mad::Core::ConnectionManager::init(); + Core::ConfigManager::useConfigManager(); + Core::ConnectionManager::init(); while(true) { - if(Mad::Core::ConnectionManager::getConnectionManager()->wait(10000)) - Mad::Core::ConnectionManager::getConnectionManager()->run(); + if(Core::ConnectionManager::getConnectionManager()->wait(10000)) + Core::ConnectionManager::getConnectionManager()->run(); } return 0; diff --git a/src/mad.cpp b/src/mad.cpp index bbcedcc..62b97f1 100644 --- a/src/mad.cpp +++ b/src/mad.cpp @@ -29,26 +29,28 @@ #include <unistd.h> +using namespace Mad; -void requestFinished(const Mad::Common::Request<>&) { - Mad::Common::Logger::log("Identified."); + +static void requestFinished(const Mad::Common::Request<>&) { + Common::Logger::log("Identified."); } int main() { - Mad::Common::Backends::ConsoleLogger logger; - Mad::Common::Logger::registerLogger(&logger); + Common::Backends::ConsoleLogger logger; + Common::Logger::registerLogger(&logger); - Mad::Net::Connection::init(); + Net::Connection::init(); - Mad::Common::RequestManager::init(false); - Mad::Common::RequestManager::getRequestManager()->registerPacketType<Mad::Common::RequestHandlers::StatusRequestHandler>(Mad::Net::Packet::STATUS); + Common::RequestManager::init(false); + Common::RequestManager::getRequestManager()->registerPacketType<Common::RequestHandlers::StatusRequestHandler>(Net::Packet::STATUS); - Mad::Common::Backends::SystemBackendProc::useBackend(); + Common::Backends::SystemBackendProc::useBackend(); - Mad::Net::ClientConnection *connection = new Mad::Net::ClientConnection; + Net::ClientConnection *connection = new Net::ClientConnection; try { - connection->connect(Mad::Net::IPAddress("127.0.0.1"), true); + connection->connect(Net::IPAddress("127.0.0.1"), true); while(connection->isConnecting()) { struct pollfd fd = connection->getPollfd(); @@ -57,12 +59,12 @@ int main() { connection->sendReceive(fd.revents); } - Mad::Common::RequestManager::getRequestManager()->registerConnection(connection); + Common::RequestManager::getRequestManager()->registerConnection(connection); //char hostname[256]; //gethostname(hostname, sizeof(hostname)); - //Mad::Common::RequestManager::getRequestManager()->sendRequest(connection, std::auto_ptr<Mad::Common::RequestBase>(new Mad::Daemon::Requests::IdentifyRequest(hostname, sigc::ptr_fun(requestFinished)))); - Mad::Common::RequestManager::getRequestManager()->sendRequest(connection, std::auto_ptr<Mad::Common::RequestBase>(new Mad::Daemon::Requests::IdentifyRequest("test", sigc::ptr_fun(requestFinished)))); + //Common::RequestManager::getRequestManager()->sendRequest(connection, std::auto_ptr<Common::RequestBase>(new Daemon::Requests::IdentifyRequest(hostname, sigc::ptr_fun(requestFinished)))); + Common::RequestManager::getRequestManager()->sendRequest(connection, std::auto_ptr<Common::RequestBase>(new Daemon::Requests::IdentifyRequest("test", sigc::ptr_fun(requestFinished)))); while(connection->isConnected()) { struct pollfd fd = connection->getPollfd(); @@ -71,15 +73,15 @@ int main() { connection->sendReceive(fd.revents); } - Mad::Common::RequestManager::getRequestManager()->unregisterConnection(connection); + Common::RequestManager::getRequestManager()->unregisterConnection(connection); } catch(Mad::Common::Exception &e) { - Mad::Common::Logger::log(Mad::Common::Logger::CRITICAL, "Connection error: " + e.strerror()); + Common::Logger::log(Common::Logger::CRITICAL, "Connection error: " + e.strerror()); } delete connection; - Mad::Net::Connection::deinit(); + Net::Connection::deinit(); return 0; } diff --git a/src/madc.cpp b/src/madc.cpp index 48b15c9..828a2bf 100644 --- a/src/madc.cpp +++ b/src/madc.cpp @@ -33,8 +33,10 @@ #include <readline/readline.h> #include <readline/history.h> +using namespace Mad; -static Mad::Client::CommandParser *parser; + +static Client::CommandParser *parser; static struct pollfd fds[2]; @@ -72,16 +74,16 @@ int main(int argc, char *argv[]) { std::exit(1); } - Mad::Common::Backends::ConsoleLogger logger; - Mad::Common::Logger::registerLogger(&logger); + Common::Backends::ConsoleLogger logger; + Common::Logger::registerLogger(&logger); - Mad::Net::Connection::init(); + Net::Connection::init(); - Mad::Common::RequestManager::init(false); - Mad::Net::ClientConnection *connection = new Mad::Net::ClientConnection; + Common::RequestManager::init(false); + Net::ClientConnection *connection = new Net::ClientConnection; try { - connection->connect(Mad::Net::IPAddress(argv[1])); + connection->connect(Net::IPAddress(argv[1])); std::cerr << "Connecting to " << argv[1] << "..." << std::flush; @@ -94,7 +96,7 @@ int main(int argc, char *argv[]) { std::cerr << " connected." << std::endl << std::endl; - Mad::Common::RequestManager::getRequestManager()->registerConnection(connection); + Common::RequestManager::getRequestManager()->registerConnection(connection); parser = new Mad::Client::CommandParser(connection); parser->signalFinished().connect(sigc::ptr_fun(activateReadline)); @@ -116,15 +118,15 @@ int main(int argc, char *argv[]) { delete parser; - Mad::Common::RequestManager::getRequestManager()->unregisterConnection(connection); + Common::RequestManager::getRequestManager()->unregisterConnection(connection); } catch(Mad::Common::Exception &e) { - Mad::Common::Logger::log(Mad::Common::Logger::CRITICAL, "Connection error: " + e.strerror()); + Common::Logger::log(Common::Logger::CRITICAL, "Connection error: " + e.strerror()); } delete connection; - Mad::Net::Connection::deinit(); + Net::Connection::deinit(); return 0; } |