Toshihiro Shimizu 890ddd
#pragma once
Toshihiro Shimizu 890ddd
Campbell Barton d0e335
#include <qobject></qobject>
Toshihiro Shimizu 890ddd
#include <set></set>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include "tcommon.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#undef DVAPI
Toshihiro Shimizu 890ddd
#undef DVVAR
Toshihiro Shimizu 890ddd
#ifdef TSYSTEM_EXPORTS
Toshihiro Shimizu 890ddd
#define DVAPI DV_EXPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_EXPORT_VAR
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
#define DVAPI DV_IMPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_IMPORT_VAR
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class QLocalServer;
Toshihiro Shimizu 890ddd
class QLocalSocket;
Toshihiro Shimizu 890ddd
class QTcpServer;
Toshihiro Shimizu 890ddd
class QTcpSocket;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#undef ERROR
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
namespace DVGui {
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
enum MsgType {
Shinya Kitaoka 120a6e
  INFORMATION,
Shinya Kitaoka 120a6e
  WARNING,   // this one opens  a popup only if tmsg not visible
Shinya Kitaoka 120a6e
  CRITICAL,  // this one opens always a popup
Shinya Kitaoka 120a6e
  QUESTION
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void DVAPI MsgBox(MsgType type, const QString &text);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
void DVAPI error(const QString &msg);
Toshihiro Shimizu 890ddd
void DVAPI warning(const QString &msg);
Toshihiro Shimizu 890ddd
void DVAPI info(const QString &msg);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class DVAPI TMsgCore final : public QObject {
Shinya Kitaoka 120a6e
  Q_OBJECT
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  QTcpServer *m_tcpServer;
Shinya Kitaoka 120a6e
  QTcpSocket *m_clientSocket;
Shinya Kitaoka 120a6e
  std::set<qtcpsocket *=""> m_sockets;</qtcpsocket>
Shinya Kitaoka 120a6e
  void readFromSocket(QTcpSocket *socket);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  TMsgCore();
Shinya Kitaoka 120a6e
  ~TMsgCore();
Shinya Kitaoka 120a6e
  static TMsgCore *instance();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // client side
Shinya Kitaoka 120a6e
  // 'send' returns false if the tmessage is not active in the application
luz paz 6454c4
  // (typically, in console applications such as tcomposer)
Shinya Kitaoka 120a6e
  bool send(DVGui::MsgType type, const QString &message);
Shinya Kitaoka 120a6e
  void connectTo(const QString &address = "");
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  // server side
Shinya Kitaoka 120a6e
  bool openConnection();
Shinya Kitaoka 120a6e
  QString getConnectionName();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
Q_SIGNALS:
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void sendMessage(int type, const QString &message);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public Q_SLOTS:
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void OnNewConnection();
Shinya Kitaoka 120a6e
  void OnReadyRead();
Shinya Kitaoka 120a6e
  void OnDisconnected();
Toshihiro Shimizu 890ddd
};