Dependents:   TimeZoneDemo EthernetJackTestCode MMEx_Challenge ntp_mem ... more

Committer:
segundo
Date:
Wed Dec 15 18:01:30 2010 +0000
Revision:
7:4e2468d7d5cb
Parent:
5:fa27dde97304

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
segundo 5:fa27dde97304 1
segundo 5:fa27dde97304 2 /*
segundo 5:fa27dde97304 3 Copyright (c) 2010 Donatien Garnier (donatiengar [at] gmail [dot] com) y Segundo Equipo
segundo 5:fa27dde97304 4
segundo 5:fa27dde97304 5 Permission is hereby granted, free of charge, to any person obtaining a copy
segundo 5:fa27dde97304 6 of this software and associated documentation files (the "Software"), to deal
segundo 5:fa27dde97304 7 in the Software without restriction, including without limitation the rights
segundo 5:fa27dde97304 8 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
segundo 5:fa27dde97304 9 copies of the Software, and to permit persons to whom the Software is
segundo 5:fa27dde97304 10 furnished to do so, subject to the following conditions:
segundo 5:fa27dde97304 11
segundo 5:fa27dde97304 12 The above copyright notice and this permission notice shall be included in
segundo 5:fa27dde97304 13 all copies or substantial portions of the Software.
segundo 5:fa27dde97304 14
segundo 5:fa27dde97304 15 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
segundo 5:fa27dde97304 16 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
segundo 5:fa27dde97304 17 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
segundo 5:fa27dde97304 18 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
segundo 5:fa27dde97304 19 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
segundo 5:fa27dde97304 20 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
segundo 5:fa27dde97304 21 THE SOFTWARE.
segundo 5:fa27dde97304 22 */
segundo 5:fa27dde97304 23
segundo 5:fa27dde97304 24 #include "EmailMessage.h"
segundo 5:fa27dde97304 25
segundo 5:fa27dde97304 26 #include <stdio.h>
segundo 5:fa27dde97304 27 #include <stdarg.h>
segundo 5:fa27dde97304 28
segundo 5:fa27dde97304 29 #define BUF_SIZE 512
segundo 5:fa27dde97304 30
segundo 5:fa27dde97304 31 EmailMessage::EmailMessage() : m_from(), m_lTo(), m_content() {
segundo 5:fa27dde97304 32 }
segundo 5:fa27dde97304 33
segundo 5:fa27dde97304 34 EmailMessage::~EmailMessage() {
segundo 5:fa27dde97304 35 }
segundo 5:fa27dde97304 36
segundo 5:fa27dde97304 37 void EmailMessage::setFrom(const char* from) {
segundo 5:fa27dde97304 38 m_from = from;
segundo 5:fa27dde97304 39 }
segundo 5:fa27dde97304 40
segundo 5:fa27dde97304 41 void EmailMessage::addTo(const char* to) {
segundo 5:fa27dde97304 42 m_lTo.push_back(to);
segundo 5:fa27dde97304 43 }
segundo 5:fa27dde97304 44
segundo 5:fa27dde97304 45 void EmailMessage::clearTo() {
segundo 5:fa27dde97304 46 m_lTo.clear();
segundo 5:fa27dde97304 47 }
segundo 5:fa27dde97304 48
segundo 5:fa27dde97304 49 int EmailMessage::printf(const char* format, ... ) { // Can be called multiple times to write the message
segundo 5:fa27dde97304 50
segundo 5:fa27dde97304 51 char buf[BUF_SIZE] = {0};
segundo 5:fa27dde97304 52 int len = 0;
segundo 5:fa27dde97304 53
segundo 5:fa27dde97304 54 va_list argp;
segundo 5:fa27dde97304 55
segundo 5:fa27dde97304 56 va_start(argp, format);
segundo 5:fa27dde97304 57 len += vsnprintf(buf, BUF_SIZE, format, argp);
segundo 5:fa27dde97304 58 va_end(argp);
segundo 5:fa27dde97304 59
segundo 5:fa27dde97304 60 if (len > 0)
segundo 5:fa27dde97304 61 m_content.append(buf);
segundo 5:fa27dde97304 62
segundo 5:fa27dde97304 63 return len;
segundo 5:fa27dde97304 64 }
segundo 5:fa27dde97304 65
segundo 5:fa27dde97304 66 void EmailMessage::clearContent() {
segundo 5:fa27dde97304 67 m_content.clear();
segundo 5:fa27dde97304 68 }