PageRenderTime 33ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llinventory/lltransactionflags.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 167 lines | 125 code | 10 blank | 32 comment | 13 complexity | 265a91da1c15c6d989f61437c5bae7bd MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file lltransactionflags.cpp
  3. * @brief Some exported symbols and functions for dealing with
  4. * transaction flags.
  5. *
  6. * $LicenseInfo:firstyear=2003&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 "linden_common.h"
  28. #include "lluuid.h"
  29. #include "lltransactionflags.h"
  30. #include "lltransactiontypes.h"
  31. const U8 TRANSACTION_FLAGS_NONE = 0;
  32. const U8 TRANSACTION_FLAG_SOURCE_GROUP = 1;
  33. const U8 TRANSACTION_FLAG_DEST_GROUP = 2;
  34. const U8 TRANSACTION_FLAG_OWNER_GROUP = 4;
  35. const U8 TRANSACTION_FLAG_SIMULTANEOUS_CONTRIBUTION = 8;
  36. const U8 TRANSACTION_FLAG_SIMULTANEOUS_CONTRIBUTION_REMOVAL = 16;
  37. U8 pack_transaction_flags(BOOL is_source_group, BOOL is_dest_group)
  38. {
  39. U8 rv = 0;
  40. if(is_source_group) rv |= TRANSACTION_FLAG_SOURCE_GROUP;
  41. if(is_dest_group) rv |= TRANSACTION_FLAG_DEST_GROUP;
  42. return rv;
  43. }
  44. BOOL is_tf_source_group(TransactionFlags flags)
  45. {
  46. return ((flags & TRANSACTION_FLAG_SOURCE_GROUP) == TRANSACTION_FLAG_SOURCE_GROUP);
  47. }
  48. BOOL is_tf_dest_group(TransactionFlags flags)
  49. {
  50. return ((flags & TRANSACTION_FLAG_DEST_GROUP) == TRANSACTION_FLAG_DEST_GROUP);
  51. }
  52. BOOL is_tf_owner_group(TransactionFlags flags)
  53. {
  54. return ((flags & TRANSACTION_FLAG_OWNER_GROUP) == TRANSACTION_FLAG_OWNER_GROUP);
  55. }
  56. void append_reason(
  57. std::ostream& ostr,
  58. S32 transaction_type,
  59. const std::string& description)
  60. {
  61. switch( transaction_type )
  62. {
  63. case TRANS_OBJECT_SALE:
  64. ostr << " for " << (description.length() > 0 ? description : std::string("<unknown>"));
  65. break;
  66. case TRANS_LAND_SALE:
  67. ostr << " for a parcel of land";
  68. break;
  69. case TRANS_LAND_PASS_SALE:
  70. ostr << " for a land access pass";
  71. break;
  72. case TRANS_GROUP_LAND_DEED:
  73. ostr << " for deeding land";
  74. default:
  75. break;
  76. }
  77. }
  78. std::string build_transfer_message_to_source(
  79. S32 amount,
  80. const LLUUID& source_id,
  81. const LLUUID& dest_id,
  82. const std::string& dest_name,
  83. S32 transaction_type,
  84. const std::string& description)
  85. {
  86. lldebugs << "build_transfer_message_to_source: " << amount << " "
  87. << source_id << " " << dest_id << " " << dest_name << " "
  88. << transaction_type << " "
  89. << (description.empty() ? "(no desc)" : description)
  90. << llendl;
  91. if(source_id.isNull())
  92. {
  93. return description;
  94. }
  95. if((0 == amount) && description.empty())
  96. {
  97. return description;
  98. }
  99. std::ostringstream ostr;
  100. if(dest_id.isNull())
  101. {
  102. // *NOTE: Do not change these strings! The viewer matches
  103. // them in llviewermessage.cpp to perform localization.
  104. // If you need to make changes, add a new, localizable message. JC
  105. ostr << "You paid L$" << amount;
  106. switch(transaction_type)
  107. {
  108. case TRANS_GROUP_CREATE:
  109. ostr << " to create a group";
  110. break;
  111. case TRANS_GROUP_JOIN:
  112. ostr << " to join a group";
  113. break;
  114. case TRANS_UPLOAD_CHARGE:
  115. ostr << " to upload";
  116. break;
  117. default:
  118. break;
  119. }
  120. }
  121. else
  122. {
  123. ostr << "You paid " << dest_name << " L$" << amount;
  124. append_reason(ostr, transaction_type, description);
  125. }
  126. ostr << ".";
  127. return ostr.str();
  128. }
  129. std::string build_transfer_message_to_destination(
  130. S32 amount,
  131. const LLUUID& dest_id,
  132. const LLUUID& source_id,
  133. const std::string& source_name,
  134. S32 transaction_type,
  135. const std::string& description)
  136. {
  137. lldebugs << "build_transfer_message_to_dest: " << amount << " "
  138. << dest_id << " " << source_id << " " << source_name << " "
  139. << transaction_type << " " << (description.empty() ? "(no desc)" : description)
  140. << llendl;
  141. if(0 == amount)
  142. {
  143. return std::string();
  144. }
  145. if(dest_id.isNull())
  146. {
  147. return description;
  148. }
  149. std::ostringstream ostr;
  150. // *NOTE: Do not change these strings! The viewer matches
  151. // them in llviewermessage.cpp to perform localization.
  152. // If you need to make changes, add a new, localizable message. JC
  153. ostr << source_name << " paid you L$" << amount;
  154. append_reason(ostr, transaction_type, description);
  155. ostr << ".";
  156. return ostr.str();
  157. }