From fc3c50063f659584b2145addab8236a479a031b7 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 18 May 2009 19:53:51 +0200 Subject: Von sigc++ auf boost-signals migriert --- src/modules/SystemBackendPosix.cpp | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'src/modules/SystemBackendPosix.cpp') diff --git a/src/modules/SystemBackendPosix.cpp b/src/modules/SystemBackendPosix.cpp index 21e5c75..4969c6d 100644 --- a/src/modules/SystemBackendPosix.cpp +++ b/src/modules/SystemBackendPosix.cpp @@ -33,8 +33,6 @@ #include #include -#include - #define init SystemBackendPosix_LTX_init #define deinit SystemBackendPosix_LTX_deinit @@ -43,8 +41,8 @@ namespace Modules { SystemBackendPosix *SystemBackendPosix::backend = 0; -std::map > SystemBackendPosix::processes; -std::map > SystemBackendPosix::processesWithOutput; +std::map > SystemBackendPosix::processes; +std::map > SystemBackendPosix::processesWithOutput; std::map SystemBackendPosix::processesWOHandles; std::map SystemBackendPosix::processesWOOutput; @@ -70,7 +68,7 @@ SystemBackendPosix::~SystemBackendPosix() { } -void SystemBackendPosix::fsInfoCallback(int, const std::string &output, const sigc::slot& > &callback) { +void SystemBackendPosix::fsInfoCallback(int, const std::string &output, const boost::function1& > &callback) { std::vector ret; std::istringstream stream(output); std::string str; @@ -99,14 +97,14 @@ void SystemBackendPosix::fsInfoCallback(int, const std::string &output, const si callback(ret); } -bool SystemBackendPosix::getFSInfo(const sigc::slot& > &callback) { +bool SystemBackendPosix::getFSInfo(const boost::function1& > &callback) { std::vector argv; argv.push_back("/bin/df"); argv.push_back("-P"); argv.push_back("-k"); - return execWithOutput(sigc::bind(sigc::mem_fun(this, &SystemBackendPosix::fsInfoCallback), callback), "/bin/df", argv); + return execWithOutput(boost::bind(&SystemBackendPosix::fsInfoCallback, this, _1, _2, callback), "/bin/df", argv); } @@ -115,14 +113,14 @@ void SystemBackendPosix::childHandler(int) { pid_t pid; while((pid = waitpid(-1, &status, WNOHANG)) > 0) { - std::map >::iterator it = processes.find(pid); + std::map >::iterator it = processes.find(pid); if(it != processes.end()) { - Common::ActionManager::get()->add(sigc::bind(it->second, status)); + Common::ActionManager::get()->add(boost::bind(it->second, status)); processes.erase(it); } else { - std::map >::iterator it2 = processesWithOutput.find(pid); + std::map >::iterator it2 = processesWithOutput.find(pid); if(it2 != processesWithOutput.end()) { char buffer[1024]; @@ -133,10 +131,10 @@ void SystemBackendPosix::childHandler(int) { while((n = read(handle, buffer, sizeof(buffer))) > 0) output += std::string(buffer, n); - Net::FdManager::get()->unregisterFd(handle); - close(handle); + //Net::FdManager::get()->unregisterFd(handle); + //close(handle); - Common::ActionManager::get()->add(sigc::bind(it2->second, status, output)); + //Common::ActionManager::get()->add(boost::bind(it2->second, status, output)); processesWithOutput.erase(it2); processesWOHandles.erase(pid); processesWOOutput.erase(pid); @@ -218,7 +216,7 @@ void SystemBackendPosix::destroyArgs(std::pair args) { } } -bool SystemBackendPosix::exec(const sigc::slot &resultHandler, const std::string &filename, const std::vector &argv, const std::vector &env) { +bool SystemBackendPosix::exec(const boost::function1 &resultHandler, const std::string &filename, const std::vector &argv, const std::vector &env) { pid_t pid; std::pair args = makeArgs(filename, argv, env); @@ -239,7 +237,7 @@ bool SystemBackendPosix::exec(const sigc::slot &resultHandler, const return ret; } -bool SystemBackendPosix::execWithOutput(const sigc::slot &resultHandler, const std::string &filename, const std::vector &argv, const std::vector &env) { +bool SystemBackendPosix::execWithOutput(const boost::function2 &resultHandler, const std::string &filename, const std::vector &argv, const std::vector &env) { pid_t pid; std::pair args = makeArgs(filename, argv, env); @@ -268,7 +266,7 @@ bool SystemBackendPosix::execWithOutput(const sigc::slotregisterFd(pipeHandles[0], sigc::bind(sigc::ptr_fun(&SystemBackendPosix::outputHandler), pid), POLLIN); + Net::FdManager::get()->registerFd(pipeHandles[0], boost::bind(&SystemBackendPosix::outputHandler, _1, pid), POLLIN); } dup2(saveStdout, STDOUT_FILENO); // restore old stdout -- cgit v1.2.3