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