PageRenderTime 151ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/llcommon/llliveappconfig.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 80 lines | 39 code | 8 blank | 33 comment | 3 complexity | ff20a5ea67dd2efe3b9873c7755d8b77 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llliveappconfig.cpp
  3. * @brief Configuration information for an LLApp that overrides indra.xml
  4. *
  5. * $LicenseInfo:firstyear=2003&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #include "linden_common.h"
  27. #include "llliveappconfig.h"
  28. #include "llapp.h"
  29. #include "llsd.h"
  30. #include "llsdserialize.h"
  31. LLLiveAppConfig::LLLiveAppConfig(
  32. const std::string& filename,
  33. F32 refresh_period,
  34. LLApp::OptionPriority priority) :
  35. LLLiveFile(filename, refresh_period),
  36. mPriority(priority)
  37. { }
  38. LLLiveAppConfig::~LLLiveAppConfig()
  39. { }
  40. // virtual
  41. bool LLLiveAppConfig::loadFile()
  42. {
  43. llinfos << "LLLiveAppConfig::loadFile(): reading from "
  44. << filename() << llendl;
  45. llifstream file(filename());
  46. LLSD config;
  47. if (file.is_open())
  48. {
  49. LLSDSerialize::fromXML(config, file);
  50. if(!config.isMap())
  51. {
  52. llwarns << "Live app config not an map in " << filename()
  53. << " Ignoring the data." << llendl;
  54. return false;
  55. }
  56. file.close();
  57. }
  58. else
  59. {
  60. llinfos << "Live file " << filename() << " does not exit." << llendl;
  61. }
  62. // *NOTE: we do not handle the else case here because we would not
  63. // have attempted to load the file unless LLLiveFile had
  64. // determined there was a reason to load it. This only happens
  65. // when either the file has been updated or it is either suddenly
  66. // in existence or has passed out of existence. Therefore, we want
  67. // to set the config to an empty config, and return that it
  68. // changed.
  69. LLApp* app = LLApp::instance();
  70. if(app) app->setOptionData(mPriority, config);
  71. return true;
  72. }