Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tfarmexecutor.h"
Toshihiro Shimizu 890ddd
#include <qstringlist></qstringlist>
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
TFarmExecutor::TFarmExecutor(int port) : TTcpIpServer(port) {}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Campbell Barton ccd505
static int extractArgs(const QString &s, std::vector<qstring> &argv) {</qstring>
Shinya Kitaoka 120a6e
  argv.clear();
Shinya Kitaoka 120a6e
  if (s == "") return 0;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  QStringList sl = s.split(',');
Shinya Kitaoka 120a6e
  int i;
Shinya Kitaoka 120a6e
  for (i = 0; i < sl.size(); i++) argv.push_back(sl.at(i));
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  return argv.size();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
void TFarmExecutor::onReceive(int socket, const QString &data) {
Shinya Kitaoka 120a6e
  QString reply;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  try {
Shinya Kitaoka 120a6e
    std::vector<qstring> argv;</qstring>
Shinya Kitaoka 120a6e
    extractArgs(data, argv);
Shinya Kitaoka 120a6e
    reply = execute(argv);
Shinya Kitaoka 120a6e
  } catch (...) {
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  sendReply(socket, reply);
Toshihiro Shimizu 890ddd
}