Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
Campbell Barton 07f3e8
#if (!(defined(x64) || defined(__LP64__) || defined(LINUX)))
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
// Toonz includes
Toshihiro Shimizu 890ddd
#include "tiio_std.h"
Toshihiro Shimizu 890ddd
#include "tnzimage.h"
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
// Qt includes
Toshihiro Shimizu 890ddd
#include <qcoreapplication></qcoreapplication>
Toshihiro Shimizu 890ddd
#include <qthread></qthread>
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
// tipc includes
Toshihiro Shimizu 890ddd
#include "tipcmsg.h"
Toshihiro Shimizu 890ddd
#include "tipcsrv.h"
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
// Specific Parsers includes
Toshihiro Shimizu 890ddd
#include "t32movmsg.h"
Toshihiro Shimizu 890ddd
#include "t323gpmsg.h"
Toshihiro Shimizu 890ddd
#include "t32fontmsg.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//************************************************************************
Toshihiro Shimizu 890ddd
//    Server Thread
Toshihiro Shimizu 890ddd
//************************************************************************
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class ServerThread : public QThread {
Shinya Kitaoka 120a6e
  QString m_srvName;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  ServerThread(const QString &srvName) : m_srvName(srvName) {}
Shinya Kitaoka 120a6e
Shinya Kitaoka 473e70
  void run() override {
Shinya Kitaoka 120a6e
    // Start a local server receiving connections on the specified key
Shinya Kitaoka 120a6e
    tipc::Server server;
Shinya Kitaoka 120a6e
    mov_io::addParsers(&server);
Shinya Kitaoka 120a6e
    _3gp_io::addParsers(&server);
Toshihiro Shimizu 890ddd
#ifdef MACOSX
Shinya Kitaoka 120a6e
    font_io::addParsers(&server);
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    // Start listening on supplied key
Shinya Kitaoka 120a6e
    bool ok = server.listen(m_srvName);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
    exec();
Shinya Kitaoka 120a6e
  }
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//************************************************************************
Toshihiro Shimizu 890ddd
//    Main server implementation
Toshihiro Shimizu 890ddd
//************************************************************************
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
int main(int argc, char *argv[]) {
Shinya Kitaoka 120a6e
  if (argc < 2)  // The server key name must be passed
Shinya Kitaoka 120a6e
    return -1;
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  QCoreApplication a(argc, argv);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  Tiio::defineStd();
Shinya Kitaoka 120a6e
  initImageIo();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  QString srvName(QString::fromUtf8(argv[1]));
Shinya Kitaoka 120a6e
  QString mainSrvName(srvName + "_main");
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  QLocalServer::removeServer(srvName);
Shinya Kitaoka 120a6e
  QLocalServer::removeServer(mainSrvName);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // Start a separate thread to host most of the event processing
Shinya Kitaoka 120a6e
  ServerThread *srvThread = new ServerThread(srvName);
Shinya Kitaoka 120a6e
  srvThread->start();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // Start a server on the main thread too - this one to host
Shinya Kitaoka 120a6e
  // commands that need to be explicitly performed on the main thread
Shinya Kitaoka 120a6e
  tipc::Server server;
Shinya Kitaoka 120a6e
  mov_io::addParsers(&server);
Shinya Kitaoka 120a6e
  _3gp_io::addParsers(&server);
Toshihiro Shimizu 890ddd
#ifdef MACOSX
Shinya Kitaoka 120a6e
  font_io::addParsers(&server);
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // Start listening on supplied key
Shinya Kitaoka 120a6e
  bool ok = server.listen(srvName + "_main");
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  a.exec();
Toshihiro Shimizu 890ddd
}
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
int main(int argc, char *argv[]) { return 0; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
#endif  // !x64 && !__LP64__