lltransactionflags.cpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. /**
  2. * @file lltransactionflags.cpp
  3. * @brief Some exported symbols and functions for dealing with
  4. * transaction flags.
  5. *
  6. * $LicenseInfo:firstyear=2003&license=viewergpl$
  7. *
  8. * Copyright (c) 2003-2009, Linden Research, Inc.
  9. *
  10. * Second Life Viewer Source Code
  11. * The source code in this file ("Source Code") is provided by Linden Lab
  12. * to you under the terms of the GNU General Public License, version 2.0
  13. * ("GPL"), unless you have obtained a separate licensing agreement
  14. * ("Other License"), formally executed by you and Linden Lab. Terms of
  15. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  16. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  17. *
  18. * There are special exceptions to the terms and conditions of the GPL as
  19. * it is applied to this Source Code. View the full text of the exception
  20. * in the file doc/FLOSS-exception.txt in this software distribution, or
  21. * online at
  22. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  23. *
  24. * By copying, modifying or distributing this software, you acknowledge
  25. * that you have read and understood your obligations described above,
  26. * and agree to abide by those obligations.
  27. *
  28. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  29. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  30. * COMPLETENESS OR PERFORMANCE.
  31. * $/LicenseInfo$
  32. */
  33. #include "linden_common.h"
  34. #include "lltransactionflags.h"
  35. #include "lltransactiontypes.h"
  36. U8 pack_transaction_flags(bool is_source_group, bool is_dest_group)
  37. {
  38. U8 rv = 0;
  39. if (is_source_group)
  40. {
  41. rv |= TRANSACTION_FLAG_SOURCE_GROUP;
  42. }
  43. if (is_dest_group)
  44. {
  45. rv |= TRANSACTION_FLAG_DEST_GROUP;
  46. }
  47. return rv;
  48. }
  49. void append_reason(std::ostream& ostr, S32 transaction_type,
  50. const std::string& description)
  51. {
  52. switch (transaction_type)
  53. {
  54. case TRANS_OBJECT_SALE:
  55. ostr << " for " << (description.length() > 0 ? description
  56. : std::string("<unknown>"));
  57. break;
  58. case TRANS_LAND_SALE:
  59. ostr << " for a parcel of land";
  60. break;
  61. case TRANS_LAND_PASS_SALE:
  62. ostr << " for a land access pass";
  63. break;
  64. case TRANS_GROUP_LAND_DEED:
  65. ostr << " for deeding land";
  66. break;
  67. default:
  68. break;
  69. }
  70. }
  71. std::string build_transfer_message_to_source(S32 amount,
  72. const LLUUID& source_id,
  73. const LLUUID& dest_id,
  74. const std::string& dest_name,
  75. S32 transaction_type,
  76. const std::string& description)
  77. {
  78. LL_DEBUGS("Transaction") << "build_transfer_message_to_source: "
  79. << amount << " " << source_id << " " << dest_id
  80. << " " << dest_name << " " << transaction_type
  81. << " "
  82. << (description.empty() ? "(no desc)" : description)
  83. << LL_ENDL;
  84. if (source_id.isNull())
  85. {
  86. return description;
  87. }
  88. if (amount == 0 && description.empty())
  89. {
  90. return description;
  91. }
  92. std::ostringstream ostr;
  93. if (dest_id.isNull())
  94. {
  95. // *NOTE: Do not change these strings! The viewer matches
  96. // them in llviewermessage.cpp to perform localization.
  97. // If you need to make changes, add a new, localizable message. JC
  98. ostr << "You paid L$" << amount;
  99. switch (transaction_type)
  100. {
  101. case TRANS_GROUP_CREATE:
  102. ostr << " to create a group";
  103. break;
  104. case TRANS_GROUP_JOIN:
  105. ostr << " to join a group";
  106. break;
  107. case TRANS_UPLOAD_CHARGE:
  108. ostr << " to upload";
  109. break;
  110. default:
  111. break;
  112. }
  113. }
  114. else
  115. {
  116. ostr << "You paid " << dest_name << " L$" << amount;
  117. append_reason(ostr, transaction_type, description);
  118. }
  119. ostr << ".";
  120. return ostr.str();
  121. }
  122. std::string build_transfer_message_to_destination(S32 amount,
  123. const LLUUID& dest_id,
  124. const LLUUID& source_id,
  125. const std::string& source_name,
  126. S32 transaction_type,
  127. const std::string& description)
  128. {
  129. LL_DEBUGS("Transaction") << "build_transfer_message_to_dest: " << amount
  130. << " " << dest_id << " " << source_id << " "
  131. << source_name << " " << transaction_type << " "
  132. << (description.empty() ? "(no desc)" : description)
  133. << LL_ENDL;
  134. if (amount == 0)
  135. {
  136. return std::string();
  137. }
  138. if (dest_id.isNull())
  139. {
  140. return description;
  141. }
  142. std::ostringstream ostr;
  143. // *NOTE: Do not change these strings! The viewer matches
  144. // them in llviewermessage.cpp to perform localization.
  145. // If you need to make changes, add a new, localizable message. JC
  146. ostr << source_name << " paid you L$" << amount;
  147. append_reason(ostr, transaction_type, description);
  148. ostr << ".";
  149. return ostr.str();
  150. }