Skip to content

Commit 6cc9995

Browse files
Merge pull request #156 from bosim/add-wrapped-message-id-option
Add option to specify if vmime should wrap (Message|Content)-Id.
2 parents 3f91900 + 3efaba7 commit 6cc9995

3 files changed

Lines changed: 33 additions & 1 deletion

File tree

src/vmime/generationContext.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ generationContext::generationContext()
3333
m_prologText("This is a multi-part message in MIME format. Your mail reader " \
3434
"does not understand MIME message format."),
3535
m_epilogText(""),
36+
m_wrapMessageId(true),
3637
m_paramValueMode(PARAMETER_VALUE_RFC2231_ONLY)
3738
{
3839
}
@@ -43,6 +44,7 @@ generationContext::generationContext(const generationContext& ctx)
4344
m_maxLineLength(ctx.m_maxLineLength),
4445
m_prologText(ctx.m_prologText),
4546
m_epilogText(ctx.m_epilogText),
47+
m_wrapMessageId(ctx.m_wrapMessageId),
4648
m_paramValueMode(ctx.m_paramValueMode)
4749
{
4850
}
@@ -67,6 +69,7 @@ void generationContext::setMaxLineLength(const size_t maxLineLength)
6769
}
6870

6971

72+
7073
const string generationContext::getPrologText() const
7174
{
7275
return m_prologText;
@@ -90,6 +93,15 @@ void generationContext::setEpilogText(const string& epilogText)
9093
m_epilogText = epilogText;
9194
}
9295

96+
bool generationContext::getWrapMessageId() const
97+
{
98+
return m_wrapMessageId;
99+
}
100+
101+
void generationContext::setWrapMessageId(const bool& wrapMessageId)
102+
{
103+
m_wrapMessageId = wrapMessageId;
104+
}
93105

94106
void generationContext::setEncodedParameterValueMode(const EncodedParameterValueModes mode)
95107
{

src/vmime/generationContext.hpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,25 @@ class VMIME_EXPORT generationContext : public context
8282
*/
8383
void setEpilogText(const string& epilogText);
8484

85+
/** Returns a boolean variable that indicates whether the
86+
* message id can be wrapped or not, i.e. from
87+
*
88+
* Message-Id: <very very long@domain>
89+
*
90+
* to
91+
*
92+
* Message-Id:
93+
* <very very long@domain>
94+
*
95+
* @return boolean indicating if the Message-Id can be wrapped
96+
*/
97+
bool getWrapMessageId() const;
98+
99+
/** Sets the boolean variable that indicates whether the
100+
* Message-Id can be wrapped or not
101+
*/
102+
void setWrapMessageId(const bool& wrapMessageId);
103+
85104
/** Modes available for generating values in parameterized header fields.
86105
*/
87106
enum EncodedParameterValueModes
@@ -142,6 +161,7 @@ class VMIME_EXPORT generationContext : public context
142161

143162
string m_prologText;
144163
string m_epilogText;
164+
bool m_wrapMessageId;
145165

146166
EncodedParameterValueModes m_paramValueMode;
147167
};

src/vmime/messageId.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ void messageId::generateImpl
193193
{
194194
size_t pos = curLinePos;
195195

196-
if (curLinePos + m_left.length() + m_right.length() + 3 > ctx.getMaxLineLength())
196+
if (ctx.getWrapMessageId() && (curLinePos + m_left.length() + m_right.length() + 3 > ctx.getMaxLineLength()))
197197
{
198198
os << NEW_LINE_SEQUENCE;
199199
pos = NEW_LINE_SEQUENCE_LENGTH;

0 commit comments

Comments
 (0)