PageRenderTime 52ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/newview/lldelayedgestureerror.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 121 lines | 72 code | 17 blank | 32 comment | 8 complexity | 20b362da7460c5c7fc4146a38ee9dca6 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file lldelayedgestureerror.cpp
  3. * @brief Delayed gesture error message -- try to wait until name has been retrieved
  4. * @author Dale Glass
  5. *
  6. * $LicenseInfo:firstyear=2004&license=viewerlgpl$
  7. * Second Life Viewer Source Code
  8. * Copyright (C) 2010, Linden Research, Inc.
  9. *
  10. * This library is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU Lesser General Public
  12. * License as published by the Free Software Foundation;
  13. * version 2.1 of the License only.
  14. *
  15. * This library is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * Lesser General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Lesser General Public
  21. * License along with this library; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  23. *
  24. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  25. * $/LicenseInfo$
  26. */
  27. #include "llviewerprecompiledheaders.h"
  28. #include "lldelayedgestureerror.h"
  29. #include <list>
  30. #include "llnotificationsutil.h"
  31. #include "llcallbacklist.h"
  32. #include "llinventory.h"
  33. #include "llviewerinventory.h"
  34. #include "llinventorymodel.h"
  35. const F32 MAX_NAME_WAIT_TIME = 5.0f;
  36. LLDelayedGestureError::ErrorQueue LLDelayedGestureError::sQueue;
  37. //static
  38. void LLDelayedGestureError::gestureMissing(const LLUUID &id)
  39. {
  40. LLErrorEntry ent("GestureMissing", id);
  41. if ( ! doDialog(ent) )
  42. {
  43. enqueue(ent);
  44. }
  45. }
  46. //static
  47. void LLDelayedGestureError::gestureFailedToLoad(const LLUUID &id)
  48. {
  49. LLErrorEntry ent("UnableToLoadGesture", id);
  50. if ( ! doDialog(ent) )
  51. {
  52. enqueue(ent);
  53. }
  54. }
  55. //static
  56. void LLDelayedGestureError::enqueue(const LLErrorEntry &ent)
  57. {
  58. if ( sQueue.empty() )
  59. {
  60. gIdleCallbacks.addFunction(onIdle, NULL);
  61. }
  62. sQueue.push_back(ent);
  63. }
  64. //static
  65. void LLDelayedGestureError::onIdle(void *userdata)
  66. {
  67. if ( ! sQueue.empty() )
  68. {
  69. LLErrorEntry ent = sQueue.front();
  70. sQueue.pop_front();
  71. if ( ! doDialog(ent, false ) )
  72. {
  73. enqueue(ent);
  74. }
  75. }
  76. else
  77. {
  78. // Nothing to do anymore
  79. gIdleCallbacks.deleteFunction(onIdle, NULL);
  80. }
  81. }
  82. //static
  83. bool LLDelayedGestureError::doDialog(const LLErrorEntry &ent, bool uuid_ok)
  84. {
  85. LLSD args;
  86. LLInventoryItem *item = gInventory.getItem( ent.mItemID );
  87. if ( item )
  88. {
  89. args["NAME"] = item->getName();
  90. }
  91. else
  92. {
  93. if ( uuid_ok || ent.mTimer.getElapsedTimeF32() > MAX_NAME_WAIT_TIME )
  94. {
  95. args["NAME"] = ent.mItemID.asString();
  96. }
  97. else
  98. {
  99. return false;
  100. }
  101. }
  102. LLNotificationsUtil::add(ent.mNotifyName, args);
  103. return true;
  104. }