QxConnect.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /****************************************************************************
  2. **
  3. ** https://www.qxorm.com/
  4. ** Copyright (C) 2013 Lionel Marty (contact@qxorm.com)
  5. **
  6. ** This file is part of the QxOrm library
  7. **
  8. ** This software is provided 'as-is', without any express or implied
  9. ** warranty. In no event will the authors be held liable for any
  10. ** damages arising from the use of this software
  11. **
  12. ** Commercial Usage
  13. ** Licensees holding valid commercial QxOrm licenses may use this file in
  14. ** accordance with the commercial license agreement provided with the
  15. ** Software or, alternatively, in accordance with the terms contained in
  16. ** a written agreement between you and Lionel Marty
  17. **
  18. ** GNU General Public License Usage
  19. ** Alternatively, this file may be used under the terms of the GNU
  20. ** General Public License version 3.0 as published by the Free Software
  21. ** Foundation and appearing in the file 'license.gpl3.txt' included in the
  22. ** packaging of this file. Please review the following information to
  23. ** ensure the GNU General Public License version 3.0 requirements will be
  24. ** met : http://www.gnu.org/copyleft/gpl.html
  25. **
  26. ** If you are unsure which license is appropriate for your use, or
  27. ** if you have questions regarding the use of this file, please contact :
  28. ** contact@qxorm.com
  29. **
  30. ****************************************************************************/
  31. #ifdef _QX_ENABLE_QT_NETWORK
  32. #ifndef _QX_SERVICE_CONNECT_H_
  33. #define _QX_SERVICE_CONNECT_H_
  34. #ifdef _MSC_VER
  35. #pragma once
  36. #endif
  37. /*!
  38. * \file QxConnect.h
  39. * \author Lionel Marty
  40. * \ingroup QxService
  41. * \brief Define connection parameters used by QxService module of QxOrm library
  42. */
  43. #ifndef QT_NO_SSL
  44. #include <QtNetwork/qsslsocket.h>
  45. #include <QtNetwork/qsslconfiguration.h>
  46. #include <QtNetwork/qsslcertificate.h>
  47. #include <QtNetwork/qsslerror.h>
  48. #include <QtNetwork/qsslkey.h>
  49. #endif // QT_NO_SSL
  50. #ifndef Q_MOC_RUN
  51. #include <QxSingleton/QxSingleton.h>
  52. #endif // Q_MOC_RUN
  53. namespace qx {
  54. namespace service {
  55. /*!
  56. * \ingroup QxService
  57. * \brief qx::service::QxConnect : define connection parameters used by QxService module of QxOrm library (this class is a singleton)
  58. *
  59. * <a href="https://www.qxorm.com/qxorm_en/tutorial_2.html" target="_blank">Click here to access to a tutorial to explain how to work with QxService module.</a>
  60. */
  61. class QX_DLL_EXPORT QxConnect : public qx::QxSingleton<QxConnect>
  62. {
  63. friend class qx::QxSingleton<QxConnect>;
  64. public:
  65. enum serialization_type { serialization_binary, serialization_xml, serialization_text, serialization_portable_binary,
  66. serialization_wide_binary, serialization_wide_xml, serialization_wide_text,
  67. serialization_polymorphic_binary, serialization_polymorphic_xml, serialization_polymorphic_text,
  68. serialization_qt, serialization_json };
  69. private:
  70. struct QxConnectImpl;
  71. std::unique_ptr<QxConnectImpl> m_pImpl; //!< Private implementation idiom
  72. QxConnect();
  73. virtual ~QxConnect();
  74. public:
  75. QString getIp();
  76. long getPort();
  77. serialization_type getSerializationType();
  78. long getThreadCount();
  79. int getMaxWait();
  80. bool getCompressData();
  81. bool getEncryptData();
  82. quint64 getEncryptKey();
  83. long getKeepAlive();
  84. bool getModeHTTP();
  85. qlonglong getSessionTimeOut();
  86. #ifndef QT_NO_SSL
  87. bool getSSLEnabled();
  88. QSslConfiguration getSSLConfiguration();
  89. QList<QSslCertificate> getSSLCACertificates();
  90. QSslCertificate getSSLLocalCertificate();
  91. QSslKey getSSLPrivateKey();
  92. QList<QSslError> getSSLIgnoreErrors();
  93. QSsl::SslProtocol getSSLProtocol();
  94. QString getSSLPeerVerifyName();
  95. QSslSocket::PeerVerifyMode getSSLPeerVerifyMode();
  96. int getSSLPeerVerifyDepth();
  97. #endif // QT_NO_SSL
  98. void setIp(const QString & s);
  99. void setPort(long l);
  100. void setSerializationType(serialization_type e);
  101. void setThreadCount(long l);
  102. void setMaxWait(int i);
  103. void setCompressData(bool b);
  104. void setEncryptData(bool b, quint64 key = 0);
  105. void setKeepAlive(long l);
  106. void setModeHTTP(bool b);
  107. void setSessionTimeOut(qlonglong l);
  108. #ifndef QT_NO_SSL
  109. void setSSLEnabled(bool b);
  110. void setSSLConfiguration(QSslConfiguration cfg);
  111. void setSSLCACertificates(QList<QSslCertificate> lst);
  112. void setSSLLocalCertificate(QSslCertificate cert);
  113. void setSSLPrivateKey(QSslKey key);
  114. void setSSLIgnoreErrors(QList<QSslError> lst);
  115. void setSSLProtocol(QSsl::SslProtocol e);
  116. void setSSLPeerVerifyName(const QString & s);
  117. void setSSLPeerVerifyMode(QSslSocket::PeerVerifyMode e);
  118. void setSSLPeerVerifyDepth(int i);
  119. #endif // QT_NO_SSL
  120. };
  121. } // namespace service
  122. } // namespace qx
  123. QX_DLL_EXPORT_QX_SINGLETON_HPP(qx::service::QxConnect)
  124. #endif // _QX_SERVICE_CONNECT_H_
  125. #endif // _QX_ENABLE_QT_NETWORK