ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/proj/trunk/WinXPFAQPoll/Message.cpp
Revision: 128
Committed: 2003-04-03T20:59:00-08:00 (22 years, 2 months ago) by douglas
File size: 3661 byte(s)
Log Message:
Fixed some stuff to work right with GCC 3.1.

File Contents

# User Rev Content
1 douglas 104 /* ============================================================================
2     * Douglas Thrift's Web Contact License
3     *
4     * Copyright (C) 2002, Douglas Thrift. All Rights Reserved.
5     *
6     * Redistribution and use in source and binary forms, with or without
7     * modification, are permitted provided that the following conditions are met:
8     *
9     * 1. Redistributions of source code must retain the above copyright notice,
10     * this list of conditions and the following disclaimer.
11     *
12     * 2. Redistributions in binary form must reproduce the above copyright notice,
13     * this list of conditions and the following disclaimer in the documentation
14     * and/or other materials provided with the distribution.
15     *
16     * 3. The end-user documentation included with the redistribution, if any, must
17     * include the following acknowledgment:
18     *
19     * "This product includes software developed by Douglas Thrift
20     * (http://computers.douglasthrift.net/webcontact.html)."
21     *
22     * Alternately, this acknowledgment may appear in the software itself, if
23     * and wherever such third-party acknowledgments normally appear.
24     *
25     * 4. The names "Douglas Thrift" and "Douglas Thrift's Web Contact" must not be
26     * used to endorse or promote products derived from this software without
27     * specific prior written permission. For written permission, please visit
28     * http://www.douglasthrift.net/contact.html for contact information.
29     *
30     * 5. Products derived from this software may not be called "Douglas Thrift's
31     * Web Contact", nor may "Douglas Thrift's Web Contact" appear in their
32     * name, without prior written permission.
33     *
34     * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
35     * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
36     * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
37     * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
38     * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
39     * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
40     * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
41     * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
42     * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
43     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44     * ============================================================================
45     */
46     // Windows XP FAQ Poll
47     //
48     // Douglas Thrift
49     //
50     // Message.cpp
51    
52     #include "Message.h"
53    
54     void Message::setMessage()
55     {
56     message = "Date: " + date + "\r\n" + "From: " + from + "\r\n"
57     + "To: " + to + "\r\n" + "Subject: " + subject + "\r\n";
58    
59     if (recieved.size() < 1)
60     {
61     message += "Recieved: \r\n";
62     }
63     else
64     {
65     for (unsigned index = 0; index < recieved.size(); index++)
66     {
67     message += "Recieved: " + recieved[index] + "\r\n";
68     }
69     }
70    
71     message += string("MIME-Version: 1.0\r\n")
72     + "Content-Type: text/plain; charset=\"us-ascii\"\r\n"
73     + "Content-Transfer-Encoding: 7bit\r\n"
74     + "X-Mailer: " + programName + " " + programVersion + "\r\n"
75     + "X-WebContact-Post-Host: " + host + "\r\n\r\n" + text;
76     }
77    
78     string Message::getLength()
79     {
80     char* clength = new char[1024];
81    
82     sprintf(clength, "%u", message.length());
83    
84     string length = clength;
85    
86     delete [] clength;
87    
88     return length;
89     }
90    
91     string Message::getImapDate()
92     {
93     string imapDate = date;
94    
95     imapDate.erase(0, 5);
96     imapDate.erase(imapDate.length() - 6);
97    
98     if (isspace(imapDate[1]))
99     {
100     imapDate.replace(1, 1, 1, '-');
101     imapDate.replace(5, 1, 1, '-');
102     }
103     else
104     {
105     imapDate.replace(2, 1, 1, '-');
106     imapDate.replace(6, 1, 1, '-');
107     }
108    
109     return imapDate;
110 douglas 128 }