Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: NFC M2M_2016_STM32 MyongjiElec_capstone1 IDW01M1_Cloud_IBM ... more
Fork of NDefLib by
RecordMail.h
00001 /** 00002 ****************************************************************************** 00003 * @file RecordMail.h 00004 * @author ST / Central Labs 00005 * @version V2.0.0 00006 * @date 28 Apr 2017 00007 * @brief Class that specializes the {@link RecordUri} to store a mail content. 00008 ****************************************************************************** 00009 * @attention 00010 * 00011 * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> 00012 * 00013 * Redistribution and use in source and binary forms, with or without modification, 00014 * are permitted provided that the following conditions are met: 00015 * 1. Redistributions of source code must retain the above copyright notice, 00016 * this list of conditions and the following disclaimer. 00017 * 2. Redistributions in binary form must reproduce the above copyright notice, 00018 * this list of conditions and the following disclaimer in the documentation 00019 * and/or other materials provided with the distribution. 00020 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00021 * may be used to endorse or promote products derived from this software 00022 * without specific prior written permission. 00023 * 00024 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00025 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00026 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00027 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00028 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00029 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00030 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00031 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00032 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00033 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00034 * 00035 ****************************************************************************** 00036 */ 00037 #ifndef NDEFLIB_RECORDTYPE_RECORDMAIL_H_s 00038 #define NDEFLIB_RECORDTYPE_RECORDMAIL_H_ 00039 00040 #include "RecordURI.h" 00041 00042 namespace NDefLib { 00043 00044 /** 00045 * Class that specializes the {@link RecordUri} to store a mail content. 00046 */ 00047 class RecordMail: public RecordURI { 00048 00049 public: 00050 00051 /** 00052 * Create a RecordMail reading the data from the buffer. 00053 * @param header Record header. 00054 * @param buffer Buffer to read the data from. 00055 * @return an object of type RecordMail or NULL 00056 * @par User is in charge of freeing the pointer returned by this function. 00057 */ 00058 static RecordMail* parse(const RecordHeader &header, 00059 const uint8_t* buffer); 00060 00061 /** 00062 * Create a mail. 00063 * @param toAddress Mail recipient. 00064 * @param subject Mail subject. 00065 * @param msg Message. 00066 */ 00067 RecordMail(const std::string &toAddress, const std::string &subject, 00068 const std::string &msg) : 00069 RecordURI(RecordURI::MAIL), mToAddress(toAddress), mSubject( 00070 subject), mBody(msg),mContentIsChange(true) { } ; 00071 00072 virtual ~RecordMail() { }; 00073 00074 /** 00075 * @return the mail recipient address 00076 */ 00077 const std::string& get_to_address () const { 00078 return mToAddress; 00079 } 00080 00081 /** 00082 * @return the mail subject 00083 */ 00084 const std::string& get_subject () const { 00085 return mSubject; 00086 } 00087 00088 /** 00089 * @return the mail body 00090 */ 00091 const std::string& get_body () const { 00092 return mBody; 00093 } 00094 00095 /** 00096 * Change the mail recipient. 00097 * @param dest Recipient address. 00098 * @par The string is copied inside the class. 00099 */ 00100 void set_to_address(const std::string& dest){ 00101 mContentIsChange=true; 00102 mToAddress=dest; 00103 } 00104 00105 /** 00106 * Change the mail subject. 00107 * @param subj New mail subject. 00108 * @par The string is copied inside the class. 00109 */ 00110 void set_subject(const std::string& subj) { 00111 mContentIsChange=true; 00112 mSubject=subj; 00113 } 00114 00115 /** 00116 * Change the mail body. 00117 * @param body New mail body. 00118 * @par The string is copied inside the class. 00119 */ 00120 void set_body(const std::string& body) { 00121 mContentIsChange=true; 00122 mBody=body; 00123 } 00124 00125 /** 00126 * Get the record type. 00127 * @return TYPE_URI_MAIL 00128 */ 00129 virtual RecordType_t get_type() const { 00130 return TYPE_URI_MAIL; 00131 } //getType 00132 00133 /** 00134 * Compare 2 RecordMails. 00135 *Â @return true if both the tags have the same addresses,subjects and bodies 00136 */ 00137 bool operator==(const RecordMail& other)const{ 00138 return mToAddress == other.mToAddress && 00139 mSubject == other.mSubject && 00140 mBody == other.mBody; 00141 } 00142 00143 protected: 00144 00145 /** 00146 * Generate the uri content that encodes the mail content. 00147 * @see RecordUri#updateContent 00148 */ 00149 virtual void update_content(); 00150 00151 private: 00152 00153 std::string mToAddress; ///< Mail address. 00154 std::string mSubject; ///< Mail subject. 00155 std::string mBody; ///< Mail body. 00156 bool mContentIsChange; ///< True if the use update some mail field. 00157 00158 static const std::string sSubjectTag; ///< String to use bofore the subject. 00159 static const std::string sBodyTag; ///< String to use before the mail body. 00160 }; 00161 00162 } /* namespace NDefLib */ 00163 00164 #endif /* NDEFLIB_RECORDTYPE_RECORDMAIL_H_ */
Generated on Tue Jul 12 2022 14:14:48 by
1.7.2
