00001 
00032 #ifndef LL_LLSALEINFO_H
00033 #define LL_LLSALEINFO_H
00034 
00035 #include "llpermissionsflags.h"
00036 #include "llsd.h"
00037 #include "llxmlnode.h"
00038 
00039 
00040 
00041 
00042 
00043 
00044 const S32 DEFAULT_PRICE = 10;
00045 
00046 class LLMessageSystem;
00047 
00048 class LLSaleInfo
00049 {
00050 public:
00051         
00052         static const LLSaleInfo DEFAULT;
00053 
00054         enum EForSale
00055         {
00056                 
00057                 FS_NOT = 0,
00058 
00059                 
00060                 FS_ORIGINAL = 1,
00061 
00062                 
00063                 FS_COPY = 2,
00064 
00065                 
00066                 
00067                 FS_CONTENTS = 3,
00068 
00069                 FS_COUNT
00070         };
00071 
00072 protected:
00073         EForSale mSaleType;
00074         S32 mSalePrice;
00075 
00076 public:
00077         
00078         LLSaleInfo();
00079         LLSaleInfo(EForSale sale_type, S32 sale_price);
00080 
00081         
00082         BOOL isForSale() const;
00083         EForSale getSaleType() const { return mSaleType; }
00084         S32 getSalePrice() const { return mSalePrice; }
00085         U32 getCRC32() const;
00086 
00087         
00088         void setSaleType(EForSale type)         { mSaleType = type; }
00089         void setSalePrice(S32 price);
00090         
00091 
00092 
00093         
00094         BOOL exportFile(FILE* fp) const;
00095         BOOL importFile(FILE* fp, BOOL& has_perm_mask, U32& perm_mask);
00096 
00097         BOOL exportLegacyStream(std::ostream& output_stream) const;
00098         LLSD asLLSD() const;
00099         operator LLSD() const { return asLLSD(); }
00100         bool fromLLSD(LLSD& sd, BOOL& has_perm_mask, U32& perm_mask);
00101         BOOL importLegacyStream(std::istream& input_stream, BOOL& has_perm_mask, U32& perm_mask);
00102 
00103         LLXMLNode *exportFileXML() const;
00104         BOOL importXML(LLXMLNode* node);
00105 
00106         
00107         void packMessage(LLMessageSystem* msg) const;
00108         void unpackMessage(LLMessageSystem* msg, const char* block);
00109         void unpackMultiMessage(LLMessageSystem* msg, const char* block,
00110                                                         S32 block_num);
00111 
00112         
00113         static EForSale lookup(const char* name);
00114         static const char* lookup(EForSale type);
00115 
00116         
00117         
00118         
00119         void accumulate(const LLSaleInfo& sale_info);
00120 
00121         bool operator==(const LLSaleInfo &rhs) const;
00122         bool operator!=(const LLSaleInfo &rhs) const;
00123 };
00124 
00125 
00126 
00127 LLSD ll_create_sd_from_sale_info(const LLSaleInfo& sale);
00128 LLSaleInfo ll_sale_info_from_sd(const LLSD& sd);
00129 
00130 #endif // LL_LLSALEINFO_H