1 //
2 // VMime library (http://www.vmime.org)
3 // Copyright (C) 2002-2013 Vincent Richard <vincent@vmime.org>
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License as
7 // published by the Free Software Foundation; either version 3 of
8 // the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License along
16 // with this program; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 //
19 // Linking this library statically or dynamically with other modules is making
20 // a combined work based on this library. Thus, the terms and conditions of
21 // the GNU General Public License cover the whole combination.
22 //
23
24 #include "vmime/generationContext.hpp"
25
26
27 namespace vmime
28 {
29
30
generationContext()31 generationContext::generationContext()
32 : m_maxLineLength(lineLengthLimits::convenient),
33 m_prologText("This is a multi-part message in MIME format. Your mail reader " \
34 "does not understand MIME message format."),
35 m_epilogText(""),
36 m_wrapMessageId(true),
37 m_paramValueMode(PARAMETER_VALUE_RFC2231_ONLY)
38 {
39 }
40
41
generationContext(const generationContext & ctx)42 generationContext::generationContext(const generationContext& ctx)
43 : context(ctx),
44 m_maxLineLength(ctx.m_maxLineLength),
45 m_prologText(ctx.m_prologText),
46 m_epilogText(ctx.m_epilogText),
47 m_wrapMessageId(ctx.m_wrapMessageId),
48 m_paramValueMode(ctx.m_paramValueMode)
49 {
50 }
51
52
getDefaultContext()53 generationContext& generationContext::getDefaultContext()
54 {
55 static generationContext ctx;
56 return ctx;
57 }
58
59
getMaxLineLength() const60 size_t generationContext::getMaxLineLength() const
61 {
62 return m_maxLineLength;
63 }
64
65
setMaxLineLength(const size_t maxLineLength)66 void generationContext::setMaxLineLength(const size_t maxLineLength)
67 {
68 m_maxLineLength = maxLineLength;
69 }
70
71
72
getPrologText() const73 const string generationContext::getPrologText() const
74 {
75 return m_prologText;
76 }
77
78
setPrologText(const string & prologText)79 void generationContext::setPrologText(const string& prologText)
80 {
81 m_prologText = prologText;
82 }
83
84
getEpilogText() const85 const string generationContext::getEpilogText() const
86 {
87 return m_epilogText;
88 }
89
90
setEpilogText(const string & epilogText)91 void generationContext::setEpilogText(const string& epilogText)
92 {
93 m_epilogText = epilogText;
94 }
95
getWrapMessageId() const96 bool generationContext::getWrapMessageId() const
97 {
98 return m_wrapMessageId;
99 }
100
setWrapMessageId(const bool & wrapMessageId)101 void generationContext::setWrapMessageId(const bool& wrapMessageId)
102 {
103 m_wrapMessageId = wrapMessageId;
104 }
105
setEncodedParameterValueMode(const EncodedParameterValueModes mode)106 void generationContext::setEncodedParameterValueMode(const EncodedParameterValueModes mode)
107 {
108 m_paramValueMode = mode;
109 }
110
111
112 generationContext::EncodedParameterValueModes
getEncodedParameterValueMode() const113 generationContext::getEncodedParameterValueMode() const
114 {
115 return m_paramValueMode;
116 }
117
118
operator =(const generationContext & ctx)119 generationContext& generationContext::operator=(const generationContext& ctx)
120 {
121 copyFrom(ctx);
122 return *this;
123 }
124
125
copyFrom(const generationContext & ctx)126 void generationContext::copyFrom(const generationContext& ctx)
127 {
128 context::copyFrom(ctx);
129
130 m_maxLineLength = ctx.m_maxLineLength;
131 m_prologText = ctx.m_prologText;
132 m_epilogText = ctx.m_epilogText;
133 m_paramValueMode = ctx.m_paramValueMode;
134 }
135
136
137 } // vmime
138