PageRenderTime 29ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llcommon/lleventapi.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 77 lines | 31 code | 8 blank | 38 comment | 0 complexity | 700a2376895d137b53512213ecbd4c0c MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file lleventapi.cpp
  3. * @author Nat Goodspeed
  4. * @date 2009-11-10
  5. * @brief Implementation for lleventapi.
  6. *
  7. * $LicenseInfo:firstyear=2009&license=viewerlgpl$
  8. * Second Life Viewer Source Code
  9. * Copyright (C) 2010, Linden Research, Inc.
  10. *
  11. * This library is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU Lesser General Public
  13. * License as published by the Free Software Foundation;
  14. * version 2.1 of the License only.
  15. *
  16. * This library is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  19. * Lesser General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Lesser General Public
  22. * License along with this library; if not, write to the Free Software
  23. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  24. *
  25. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  26. * $/LicenseInfo$
  27. */
  28. // Precompiled header
  29. #include "linden_common.h"
  30. // associated header
  31. #include "lleventapi.h"
  32. // STL headers
  33. // std headers
  34. // external library headers
  35. // other Linden headers
  36. #include "llerror.h"
  37. LLEventAPI::LLEventAPI(const std::string& name, const std::string& desc, const std::string& field):
  38. lbase(name, field),
  39. ibase(name),
  40. mDesc(desc)
  41. {
  42. }
  43. LLEventAPI::~LLEventAPI()
  44. {
  45. }
  46. LLEventAPI::Response::Response(const LLSD& seed, const LLSD& request, const LLSD::String& replyKey):
  47. mResp(seed),
  48. mReq(request),
  49. mKey(replyKey)
  50. {}
  51. LLEventAPI::Response::~Response()
  52. {
  53. // When you instantiate a stack Response object, if the original
  54. // request requested a reply, send it when we leave this block, no
  55. // matter how.
  56. sendReply(mResp, mReq, mKey);
  57. }
  58. void LLEventAPI::Response::warn(const std::string& warning)
  59. {
  60. LL_WARNS("LLEventAPI::Response") << warning << LL_ENDL;
  61. mResp["warnings"].append(warning);
  62. }
  63. void LLEventAPI::Response::error(const std::string& error)
  64. {
  65. // Use LL_WARNS rather than LL_ERROR: we don't want the viewer to shut
  66. // down altogether.
  67. LL_WARNS("LLEventAPI::Response") << error << LL_ENDL;
  68. mResp["error"] = error;
  69. }