XmlRpcMethodFactory.cc 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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 "XmlRpcMethodFactory.h"
  36. #include "XmlRpcMethodImpl.h"
  37. #include "OptionParser.h"
  38. #include "OptionHandler.h"
  39. namespace aria2 {
  40. namespace xmlrpc {
  41. SharedHandle<XmlRpcMethod>
  42. XmlRpcMethodFactory::create(const std::string& methodName)
  43. {
  44. if(methodName == AddUriXmlRpcMethod::getMethodName()) {
  45. return SharedHandle<XmlRpcMethod>(new AddUriXmlRpcMethod());
  46. #ifdef ENABLE_BITTORRENT
  47. } else if(methodName == AddTorrentXmlRpcMethod::getMethodName()) {
  48. return SharedHandle<XmlRpcMethod>(new AddTorrentXmlRpcMethod());
  49. #endif // ENABLE_BITTORRENT
  50. #ifdef ENABLE_METALINK
  51. }
  52. else if(methodName == AddMetalinkXmlRpcMethod::getMethodName()) {
  53. return SharedHandle<XmlRpcMethod>(new AddMetalinkXmlRpcMethod());
  54. #endif // ENABLE_METALINK
  55. }
  56. else if(methodName == RemoveXmlRpcMethod::getMethodName()) {
  57. return SharedHandle<XmlRpcMethod>(new RemoveXmlRpcMethod());
  58. } else if(methodName == PauseXmlRpcMethod::getMethodName()) {
  59. return SharedHandle<XmlRpcMethod>(new PauseXmlRpcMethod());
  60. } else if(methodName == ForcePauseXmlRpcMethod::getMethodName()) {
  61. return SharedHandle<XmlRpcMethod>(new ForcePauseXmlRpcMethod());
  62. } else if(methodName == PauseAllXmlRpcMethod::getMethodName()) {
  63. return SharedHandle<XmlRpcMethod>(new PauseAllXmlRpcMethod());
  64. } else if(methodName == ForcePauseAllXmlRpcMethod::getMethodName()) {
  65. return SharedHandle<XmlRpcMethod>(new ForcePauseAllXmlRpcMethod());
  66. } else if(methodName == UnpauseXmlRpcMethod::getMethodName()) {
  67. return SharedHandle<XmlRpcMethod>(new UnpauseXmlRpcMethod());
  68. } else if(methodName == UnpauseAllXmlRpcMethod::getMethodName()) {
  69. return SharedHandle<XmlRpcMethod>(new UnpauseAllXmlRpcMethod());
  70. } else if(methodName == ForceRemoveXmlRpcMethod::getMethodName()) {
  71. return SharedHandle<XmlRpcMethod>(new ForceRemoveXmlRpcMethod());
  72. } else if(methodName == ChangePositionXmlRpcMethod::getMethodName()) {
  73. return SharedHandle<XmlRpcMethod>(new ChangePositionXmlRpcMethod());
  74. } else if(methodName == TellStatusXmlRpcMethod::getMethodName()) {
  75. return SharedHandle<XmlRpcMethod>(new TellStatusXmlRpcMethod());
  76. } else if(methodName == GetUrisXmlRpcMethod::getMethodName()) {
  77. return SharedHandle<XmlRpcMethod>(new GetUrisXmlRpcMethod());
  78. } else if(methodName == GetFilesXmlRpcMethod::getMethodName()) {
  79. return SharedHandle<XmlRpcMethod>(new GetFilesXmlRpcMethod());
  80. #ifdef ENABLE_BITTORRENT
  81. }
  82. else if(methodName == GetPeersXmlRpcMethod::getMethodName()) {
  83. return SharedHandle<XmlRpcMethod>(new GetPeersXmlRpcMethod());
  84. #endif // ENABLE_BITTORRENT
  85. } else if(methodName == GetServersXmlRpcMethod::getMethodName()) {
  86. return SharedHandle<XmlRpcMethod>(new GetServersXmlRpcMethod());
  87. } else if(methodName == TellActiveXmlRpcMethod::getMethodName()) {
  88. return SharedHandle<XmlRpcMethod>(new TellActiveXmlRpcMethod());
  89. } else if(methodName == TellWaitingXmlRpcMethod::getMethodName()) {
  90. return SharedHandle<XmlRpcMethod>(new TellWaitingXmlRpcMethod());
  91. } else if(methodName == TellStoppedXmlRpcMethod::getMethodName()) {
  92. return SharedHandle<XmlRpcMethod>(new TellStoppedXmlRpcMethod());
  93. } else if(methodName == GetOptionXmlRpcMethod::getMethodName()) {
  94. return SharedHandle<XmlRpcMethod>(new GetOptionXmlRpcMethod());
  95. } else if(methodName == ChangeUriXmlRpcMethod::getMethodName()) {
  96. return SharedHandle<XmlRpcMethod>(new ChangeUriXmlRpcMethod());
  97. } else if(methodName == ChangeOptionXmlRpcMethod::getMethodName()) {
  98. return SharedHandle<XmlRpcMethod>(new ChangeOptionXmlRpcMethod());
  99. } else if(methodName == GetGlobalOptionXmlRpcMethod::getMethodName()) {
  100. return SharedHandle<XmlRpcMethod>(new GetGlobalOptionXmlRpcMethod());
  101. } else if(methodName == ChangeGlobalOptionXmlRpcMethod::getMethodName()) {
  102. return SharedHandle<XmlRpcMethod>(new ChangeGlobalOptionXmlRpcMethod());
  103. } else if(methodName == PurgeDownloadResultXmlRpcMethod::getMethodName()) {
  104. return SharedHandle<XmlRpcMethod>(new PurgeDownloadResultXmlRpcMethod());
  105. } else if(methodName == GetVersionXmlRpcMethod::getMethodName()) {
  106. return SharedHandle<XmlRpcMethod>(new GetVersionXmlRpcMethod());
  107. } else if(methodName == GetSessionInfoXmlRpcMethod::getMethodName()) {
  108. return SharedHandle<XmlRpcMethod>(new GetSessionInfoXmlRpcMethod());
  109. } else if(methodName == ShutdownXmlRpcMethod::getMethodName()) {
  110. return SharedHandle<XmlRpcMethod>(new ShutdownXmlRpcMethod());
  111. } else if(methodName == ForceShutdownXmlRpcMethod::getMethodName()) {
  112. return SharedHandle<XmlRpcMethod>(new ForceShutdownXmlRpcMethod());
  113. } else if(methodName == SystemMulticallXmlRpcMethod::getMethodName()) {
  114. return SharedHandle<XmlRpcMethod>(new SystemMulticallXmlRpcMethod());
  115. } else {
  116. return SharedHandle<XmlRpcMethod>(new NoSuchMethodXmlRpcMethod());
  117. }
  118. }
  119. } // namespace xmlrpc
  120. } // namespace aria2