lltransactionflags.cpp

Go to the documentation of this file.
00001 
00033 #include "linden_common.h"
00034 
00035 #include "lltransactionflags.h"
00036 #include "lltransactiontypes.h"
00037 #include "lluuid.h"
00038  
00039 const U8 TRANSACTION_FLAGS_NONE = 0;
00040 const U8 TRANSACTION_FLAG_SOURCE_GROUP = 1;
00041 const U8 TRANSACTION_FLAG_DEST_GROUP = 2;
00042 const U8 TRANSACTION_FLAG_OWNER_GROUP = 4;
00043 const U8 TRANSACTION_FLAG_SIMULTANEOUS_CONTRIBUTION = 8;
00044 const U8 TRANSACTION_FLAG_SIMULTANEOUS_CONTRIBUTION_REMOVAL = 16;
00045 
00046 U8 pack_transaction_flags(BOOL is_source_group, BOOL is_dest_group)
00047 {
00048         U8 rv = 0;
00049         if(is_source_group) rv |= TRANSACTION_FLAG_SOURCE_GROUP;
00050         if(is_dest_group) rv |= TRANSACTION_FLAG_DEST_GROUP;
00051         return rv;
00052 }
00053 
00054 BOOL is_tf_source_group(TransactionFlags flags)
00055 {
00056         return ((flags & TRANSACTION_FLAG_SOURCE_GROUP) == TRANSACTION_FLAG_SOURCE_GROUP);
00057 }
00058 
00059 BOOL is_tf_dest_group(TransactionFlags flags)
00060 {
00061         return ((flags & TRANSACTION_FLAG_DEST_GROUP) == TRANSACTION_FLAG_DEST_GROUP);
00062 }
00063 
00064 BOOL is_tf_owner_group(TransactionFlags flags)
00065 {
00066         return ((flags & TRANSACTION_FLAG_OWNER_GROUP) == TRANSACTION_FLAG_OWNER_GROUP);
00067 }
00068 
00069 void append_reason(
00070         std::ostream& ostr,
00071         S32 transaction_type,
00072         const char* description)
00073 {
00074         switch( transaction_type )
00075         {
00076         case TRANS_OBJECT_SALE:
00077                 ostr << " for " << (description ? description : "<unknown>");
00078                 break;
00079         case TRANS_LAND_SALE:
00080                 ostr << " for a parcel of land";
00081                 break;
00082         case TRANS_LAND_PASS_SALE:
00083                 ostr << " for a land access pass";
00084                 break;
00085         case TRANS_GROUP_LAND_DEED:
00086                 ostr << " for deeding land";
00087         default:
00088                 break;
00089         }
00090 }
00091 
00092 std::string build_transfer_message_to_source(
00093         S32 amount,
00094         const LLUUID& source_id,
00095         const LLUUID& dest_id,
00096         const std::string& dest_name,
00097         S32 transaction_type,
00098         const char* description)
00099 {
00100         lldebugs << "build_transfer_message_to_source: " << amount << " "
00101                 << source_id << " " << dest_id << " " << dest_name << " "
00102                 << (description?description:"(no desc)") << llendl;
00103         if((0 == amount) || source_id.isNull()) return ll_safe_string(description);
00104         std::ostringstream ostr;
00105         if(dest_id.isNull())
00106         {
00107                 ostr << "You paid L$" << amount;
00108                 switch(transaction_type)
00109                 {
00110                 case TRANS_GROUP_CREATE:
00111                         ostr << " to create a group";
00112                         break;
00113                 case TRANS_GROUP_JOIN:
00114                         ostr << " to join a group";
00115                         break;
00116                 case TRANS_UPLOAD_CHARGE:
00117                         ostr << " to upload";
00118                         break;
00119                 default:
00120                         break;
00121                 }
00122         }
00123         else
00124         {
00125                 ostr << "You paid " << dest_name << " L$" << amount;
00126                 append_reason(ostr, transaction_type, description);
00127         }
00128         ostr << ".";
00129         return ostr.str();
00130 }
00131 
00132 std::string build_transfer_message_to_destination(
00133         S32 amount,
00134         const LLUUID& dest_id,
00135         const LLUUID& source_id,
00136         const std::string& source_name,
00137         S32 transaction_type,
00138         const char* description)
00139 {
00140         lldebugs << "build_transfer_message_to_dest: " << amount << " "
00141                 << dest_id << " " << source_id << " " << source_name << " "
00142                 << (description?description:"(no desc)") << llendl;
00143         if(0 == amount) return std::string();
00144         if(dest_id.isNull()) return ll_safe_string(description);
00145         std::ostringstream ostr;
00146         ostr << source_name << " paid you L$" << amount;
00147         append_reason(ostr, transaction_type, description);
00148         ostr << ".";
00149         return ostr.str();
00150 }

Generated on Thu Jul 1 06:09:22 2010 for Second Life Viewer by  doxygen 1.4.7