Archiver.cpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 <memory>
  19. #include <new>
  20. #include <string>
  21. #include "Archiver.h"
  22. #include <kopano/ECConfig.h>
  23. #include "ArchiverImpl.h"
  24. namespace KC {
  25. const char* Archiver::GetConfigPath()
  26. {
  27. static std::string s_strConfigPath;
  28. if (s_strConfigPath.empty()) {
  29. const char *lpszConfigPath = getenv("KOPANO_ARCHIVER_CONF");
  30. if (!lpszConfigPath || lpszConfigPath[0] == '\0')
  31. s_strConfigPath = ECConfig::GetDefaultPath("archiver.cfg");
  32. else
  33. s_strConfigPath = lpszConfigPath;
  34. }
  35. return s_strConfigPath.c_str();
  36. }
  37. const configsetting_t* Archiver::GetConfigDefaults()
  38. {
  39. static const configsetting_t s_lpDefaults[] = {
  40. // Connect settings
  41. { "server_socket", "default:" },
  42. { "sslkey_file", "" },
  43. { "sslkey_pass", "", CONFIGSETTING_EXACT },
  44. // Archive settings
  45. { "archive_enable", "yes" },
  46. { "archive_after", "30" },
  47. { "stub_enable", "no" },
  48. { "stub_unread", "no" },
  49. { "stub_after", "0" },
  50. { "delete_enable", "no" },
  51. { "delete_unread", "no" },
  52. { "delete_after", "0" },
  53. { "purge_enable", "no" },
  54. { "purge_after", "2555" },
  55. { "track_history", "no" },
  56. { "cleanup_action", "store" },
  57. { "cleanup_follow_purge_after", "no" },
  58. { "enable_auto_attach", "no" },
  59. { "auto_attach_writable", "yes" },
  60. // Log options
  61. { "log_method", "file" },
  62. { "log_file", "-" },
  63. { "log_level", "3", CONFIGSETTING_RELOADABLE },
  64. { "log_timestamp", "yes" },
  65. { "log_buffer_size", "0" },
  66. { "mysql_host", "localhost" },
  67. { "mysql_port", "3306" },
  68. { "mysql_user", "root" },
  69. { "mysql_password", "", CONFIGSETTING_EXACT },
  70. { "mysql_database", "kopano-archiver" },
  71. { "mysql_socket", "" },
  72. { "purge-soft-deleted", "no" },
  73. { NULL, NULL },
  74. };
  75. return s_lpDefaults;
  76. }
  77. eResult Archiver::Create(auto_ptr_type *lpptrArchiver)
  78. {
  79. if (lpptrArchiver == NULL)
  80. return InvalidParameter;
  81. auto_ptr_type ptrArchiver(new(std::nothrow) ArchiverImpl);
  82. if (ptrArchiver == nullptr)
  83. return OutOfMemory;
  84. *lpptrArchiver = std::move(ptrArchiver);
  85. return Success;
  86. }
  87. } /* namespace */