ECLicenseClient.cpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. * Copyright 2005 - 2016 Zarafa and its licensors
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU Affero General Public License, version 3,
  6. * as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU Affero General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU Affero General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. *
  16. */
  17. #include <kopano/platform.h>
  18. #include <string>
  19. #include <vector>
  20. #include <cstdlib>
  21. #include <sys/un.h>
  22. #include <sys/socket.h>
  23. #include <kopano/ECDefs.h>
  24. #include <kopano/ECChannel.h>
  25. #include <kopano/stringutil.h>
  26. #include "ECLicenseClient.h"
  27. namespace KC {
  28. ECRESULT ECLicenseClient::ServiceTypeToServiceTypeString(unsigned int ulServiceType, std::string &strServiceType)
  29. {
  30. ECRESULT er = erSuccess;
  31. switch(ulServiceType)
  32. {
  33. case 0 /*SERVICE_TYPE_ZCP*/:
  34. strServiceType = "ZCP";
  35. break;
  36. case 1 /*SERVICE_TYPE_ARCHIVE*/:
  37. strServiceType = "ARCHIVER";
  38. break;
  39. default:
  40. er = KCERR_INVALID_TYPE;
  41. break;
  42. }
  43. return er;
  44. }
  45. ECRESULT ECLicenseClient::GetCapabilities(unsigned int ulServiceType, std::vector<std::string > &lstCapabilities)
  46. {
  47. ECRESULT er;
  48. std::string strServiceType;
  49. er = ServiceTypeToServiceTypeString(ulServiceType, strServiceType);
  50. if (er != erSuccess)
  51. return er;
  52. lstCapabilities.clear();
  53. if (ulServiceType == 0) {
  54. lstCapabilities.push_back("DEFAULT");
  55. lstCapabilities.push_back("OUTLOOK");
  56. lstCapabilities.push_back("OLENABLED");
  57. lstCapabilities.push_back("BACKUP");
  58. lstCapabilities.push_back("GATEWAY");
  59. lstCapabilities.push_back("ICAL");
  60. lstCapabilities.push_back("REPORT");
  61. lstCapabilities.push_back("MIGRATION");
  62. lstCapabilities.push_back("WA-ADVANCED-CALENDAR");
  63. lstCapabilities.push_back("BES");
  64. lstCapabilities.push_back("MULTISERVER");
  65. lstCapabilities.push_back("UPDATER");
  66. lstCapabilities.push_back("EWS");
  67. }
  68. return erSuccess;
  69. }
  70. ECRESULT ECLicenseClient::GetSerial(unsigned int ulServiceType, std::string &strSerial, std::vector<std::string> &lstCALs)
  71. {
  72. ECRESULT er;
  73. std::string strServiceType;
  74. er = ServiceTypeToServiceTypeString(ulServiceType, strServiceType);
  75. if (er != erSuccess)
  76. return er;
  77. strSerial = "";
  78. lstCALs.clear();
  79. return erSuccess;
  80. }
  81. ECRESULT ECLicenseClient::GetInfo(unsigned int ulServiceType, unsigned int *lpulUserCount)
  82. {
  83. ECRESULT er;
  84. std::string strServiceType;
  85. er = ServiceTypeToServiceTypeString(ulServiceType, strServiceType);
  86. if (er != erSuccess)
  87. return er;
  88. *lpulUserCount = 65535;
  89. return erSuccess;
  90. }
  91. struct LICENSERESPONSE {
  92. unsigned int ulVersion; // Current: LICENSERESPONSE_VERSION
  93. unsigned int ulTrackingId;
  94. unsigned long long llFlags;
  95. unsigned int ulStatus;
  96. char szPadding[4]; // Make sure the struct is padded to a multiple of 8 bytes
  97. };
  98. ECRESULT ECLicenseClient::Auth(const unsigned char *lpData,
  99. unsigned int ulSize, void **lppResponse, unsigned int *lpulResponseSize)
  100. {
  101. *lppResponse = calloc(1, sizeof(LICENSERESPONSE));
  102. *lpulResponseSize = sizeof(LICENSERESPONSE);
  103. return erSuccess;
  104. }
  105. ECRESULT ECLicenseClient::SetSerial(unsigned int ulServiceType, const std::string &strSerial, const std::vector<std::string> &lstCALs)
  106. {
  107. ECRESULT er;
  108. std::string strServiceType;
  109. er = ServiceTypeToServiceTypeString(ulServiceType, strServiceType);
  110. if (er != erSuccess)
  111. return er;
  112. return erSuccess;
  113. }
  114. } /* namespace */