RpcMethodFactory.cc 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. /* <!-- copyright */
  2. /*
  3. * aria2 - The high speed download utility
  4. *
  5. * Copyright (C) 2009 Tatsuhiro Tsujikawa
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. *
  21. * In addition, as a special exception, the copyright holders give
  22. * permission to link the code of portions of this program with the
  23. * OpenSSL library under certain conditions as described in each
  24. * individual source file, and distribute linked combinations
  25. * including the two.
  26. * You must obey the GNU General Public License in all respects
  27. * for all of the code used other than OpenSSL. If you modify
  28. * file(s) with this exception, you may extend this exception to your
  29. * version of the file(s), but you are not obligated to do so. If you
  30. * do not wish to do so, delete this exception statement from your
  31. * version. If you delete this exception statement from all source
  32. * files in the program, then also delete it here.
  33. */
  34. /* copyright --> */
  35. #include "RpcMethodFactory.h"
  36. #include "RpcMethodImpl.h"
  37. #include "OptionParser.h"
  38. #include "OptionHandler.h"
  39. namespace aria2 {
  40. namespace rpc {
  41. SharedHandle<RpcMethod>
  42. RpcMethodFactory::create(const std::string& methodName)
  43. {
  44. if(methodName == AddUriRpcMethod::getMethodName()) {
  45. return SharedHandle<RpcMethod>(new AddUriRpcMethod());
  46. #ifdef ENABLE_BITTORRENT
  47. } else if(methodName == AddTorrentRpcMethod::getMethodName()) {
  48. return SharedHandle<RpcMethod>(new AddTorrentRpcMethod());
  49. #endif // ENABLE_BITTORRENT
  50. #ifdef ENABLE_METALINK
  51. }
  52. else if(methodName == AddMetalinkRpcMethod::getMethodName()) {
  53. return SharedHandle<RpcMethod>(new AddMetalinkRpcMethod());
  54. #endif // ENABLE_METALINK
  55. }
  56. else if(methodName == RemoveRpcMethod::getMethodName()) {
  57. return SharedHandle<RpcMethod>(new RemoveRpcMethod());
  58. } else if(methodName == PauseRpcMethod::getMethodName()) {
  59. return SharedHandle<RpcMethod>(new PauseRpcMethod());
  60. } else if(methodName == ForcePauseRpcMethod::getMethodName()) {
  61. return SharedHandle<RpcMethod>(new ForcePauseRpcMethod());
  62. } else if(methodName == PauseAllRpcMethod::getMethodName()) {
  63. return SharedHandle<RpcMethod>(new PauseAllRpcMethod());
  64. } else if(methodName == ForcePauseAllRpcMethod::getMethodName()) {
  65. return SharedHandle<RpcMethod>(new ForcePauseAllRpcMethod());
  66. } else if(methodName == UnpauseRpcMethod::getMethodName()) {
  67. return SharedHandle<RpcMethod>(new UnpauseRpcMethod());
  68. } else if(methodName == UnpauseAllRpcMethod::getMethodName()) {
  69. return SharedHandle<RpcMethod>(new UnpauseAllRpcMethod());
  70. } else if(methodName == ForceRemoveRpcMethod::getMethodName()) {
  71. return SharedHandle<RpcMethod>(new ForceRemoveRpcMethod());
  72. } else if(methodName == ChangePositionRpcMethod::getMethodName()) {
  73. return SharedHandle<RpcMethod>(new ChangePositionRpcMethod());
  74. } else if(methodName == TellStatusRpcMethod::getMethodName()) {
  75. return SharedHandle<RpcMethod>(new TellStatusRpcMethod());
  76. } else if(methodName == GetUrisRpcMethod::getMethodName()) {
  77. return SharedHandle<RpcMethod>(new GetUrisRpcMethod());
  78. } else if(methodName == GetFilesRpcMethod::getMethodName()) {
  79. return SharedHandle<RpcMethod>(new GetFilesRpcMethod());
  80. #ifdef ENABLE_BITTORRENT
  81. }
  82. else if(methodName == GetPeersRpcMethod::getMethodName()) {
  83. return SharedHandle<RpcMethod>(new GetPeersRpcMethod());
  84. #endif // ENABLE_BITTORRENT
  85. } else if(methodName == GetServersRpcMethod::getMethodName()) {
  86. return SharedHandle<RpcMethod>(new GetServersRpcMethod());
  87. } else if(methodName == TellActiveRpcMethod::getMethodName()) {
  88. return SharedHandle<RpcMethod>(new TellActiveRpcMethod());
  89. } else if(methodName == TellWaitingRpcMethod::getMethodName()) {
  90. return SharedHandle<RpcMethod>(new TellWaitingRpcMethod());
  91. } else if(methodName == TellStoppedRpcMethod::getMethodName()) {
  92. return SharedHandle<RpcMethod>(new TellStoppedRpcMethod());
  93. } else if(methodName == GetOptionRpcMethod::getMethodName()) {
  94. return SharedHandle<RpcMethod>(new GetOptionRpcMethod());
  95. } else if(methodName == ChangeUriRpcMethod::getMethodName()) {
  96. return SharedHandle<RpcMethod>(new ChangeUriRpcMethod());
  97. } else if(methodName == ChangeOptionRpcMethod::getMethodName()) {
  98. return SharedHandle<RpcMethod>(new ChangeOptionRpcMethod());
  99. } else if(methodName == GetGlobalOptionRpcMethod::getMethodName()) {
  100. return SharedHandle<RpcMethod>(new GetGlobalOptionRpcMethod());
  101. } else if(methodName == ChangeGlobalOptionRpcMethod::getMethodName()) {
  102. return SharedHandle<RpcMethod>(new ChangeGlobalOptionRpcMethod());
  103. } else if(methodName == PurgeDownloadResultRpcMethod::getMethodName()) {
  104. return SharedHandle<RpcMethod>(new PurgeDownloadResultRpcMethod());
  105. } else if(methodName == RemoveDownloadResultRpcMethod::getMethodName()) {
  106. return SharedHandle<RpcMethod>(new RemoveDownloadResultRpcMethod());
  107. } else if(methodName == GetVersionRpcMethod::getMethodName()) {
  108. return SharedHandle<RpcMethod>(new GetVersionRpcMethod());
  109. } else if(methodName == GetSessionInfoRpcMethod::getMethodName()) {
  110. return SharedHandle<RpcMethod>(new GetSessionInfoRpcMethod());
  111. } else if(methodName == ShutdownRpcMethod::getMethodName()) {
  112. return SharedHandle<RpcMethod>(new ShutdownRpcMethod());
  113. } else if(methodName == ForceShutdownRpcMethod::getMethodName()) {
  114. return SharedHandle<RpcMethod>(new ForceShutdownRpcMethod());
  115. } else if(methodName == SystemMulticallRpcMethod::getMethodName()) {
  116. return SharedHandle<RpcMethod>(new SystemMulticallRpcMethod());
  117. } else {
  118. return SharedHandle<RpcMethod>(new NoSuchMethodRpcMethod());
  119. }
  120. }
  121. } // namespace rpc
  122. } // namespace aria2