diff --git a/common/fileformat.h b/common/fileformat.h
index d181567..acb8337 100644
--- a/common/fileformat.h
+++ b/common/fileformat.h
@@ -49,7 +49,7 @@ private:
// Native file format version
static const uint kFileFormatVersionMajor = 0;
static const uint kFileFormatVersionMinor = 1;
- static const uint kFileFormatVersionRevision = 0;
+ static const uint kFileFormatVersionRevision = 1;
void initFileMetaData(OstProto::FileMetaData &metaData);
};
diff --git a/common/textproto.cpp b/common/textproto.cpp
index c86f7ff..9834530 100644
--- a/common/textproto.cpp
+++ b/common/textproto.cpp
@@ -107,6 +107,7 @@ AbstractProtocol::FieldFlags TextProtocol::fieldFlags(int index) const
break;
case textProto_portNum:
+ case textProto_eol:
case textProto_encoding:
flags &= ~FrameField;
flags |= MetaField;
@@ -136,8 +137,18 @@ QVariant TextProtocol::fieldData(int index, FieldAttrib attrib,
case FieldTextValue:
return QString().fromStdString(data.text());
case FieldFrameValue:
+ {
+ QString text;
Q_ASSERT(data.encoding() == OstProto::TextProtocol::kUtf8);
- return QString().fromStdString(data.text()).toUtf8();
+ text = QString().fromStdString(data.text());
+
+ if (data.eol() == OstProto::TextProtocol::kCrLf)
+ text.replace('\n', "\r\n");
+ else if (data.eol() == OstProto::TextProtocol::kCr)
+ text.replace('\n', '\r');
+
+ return text.toUtf8();
+ }
default:
break;
}
@@ -157,6 +168,17 @@ QVariant TextProtocol::fieldData(int index, FieldAttrib attrib,
}
break;
}
+ case textProto_eol:
+ {
+ switch(attrib)
+ {
+ case FieldValue:
+ return data.eol();
+ default:
+ break;
+ }
+ break;
+ }
case textProto_encoding:
{
switch(attrib)
@@ -200,6 +222,15 @@ bool TextProtocol::setFieldData(int index, const QVariant &value,
data.set_port_num(portNum);
break;
}
+ case textProto_eol:
+ {
+ uint eol = value.toUInt(&isOk);
+ if (isOk && data.EndOfLine_IsValid(eol))
+ data.set_eol((OstProto::TextProtocol::EndOfLine) eol);
+ else
+ isOk = false;
+ break;
+ }
case textProto_encoding:
{
uint enc = value.toUInt(&isOk);
@@ -243,6 +274,8 @@ void TextProtocol::loadConfigWidget()
configForm->portNumCombo->setValue(
fieldData(textProto_portNum, FieldValue).toUInt());
+ configForm->eolCombo->setCurrentIndex(
+ fieldData(textProto_eol, FieldValue).toUInt());
configForm->encodingCombo->setCurrentIndex(
fieldData(textProto_encoding, FieldValue).toUInt());
configForm->protoText->setText(
@@ -254,6 +287,7 @@ void TextProtocol::storeConfigWidget()
configWidget();
setFieldData(textProto_portNum, configForm->portNumCombo->currentValue());
+ setFieldData(textProto_eol, configForm->eolCombo->currentIndex());
setFieldData(textProto_encoding, configForm->encodingCombo->currentIndex());
setFieldData(textProto_text, configForm->protoText->toPlainText());
diff --git a/common/textproto.h b/common/textproto.h
index 57b71cc..1ec5fc0 100644
--- a/common/textproto.h
+++ b/common/textproto.h
@@ -27,7 +27,8 @@ along with this program. If not, see
/*
TextProtocol Protocol Frame Format -
- specified text encoded with the specified encoding
+ specified text with the specified line ending and encoded with the
+ specified encoding
*/
class TextProtocolConfigForm : public QWidget, public Ui::TextProtocol
@@ -50,6 +51,7 @@ private:
// Meta Fields
textProto_portNum,
+ textProto_eol,
textProto_encoding,
textProto_fieldCount
diff --git a/common/textproto.proto b/common/textproto.proto
index 12e5b4e..e20e496 100644
--- a/common/textproto.proto
+++ b/common/textproto.proto
@@ -26,10 +26,17 @@ message TextProtocol {
enum TextEncoding {
kUtf8 = 0;
}
+
+ enum EndOfLine {
+ kCr = 0;
+ kLf = 1;
+ kCrLf = 2;
+ }
optional uint32 port_num = 1 [default = 80];
optional TextEncoding encoding = 2 [default = kUtf8];
optional string text = 3;
+ optional EndOfLine eol = 4 [default = kLf];
}
extend Protocol {
diff --git a/common/textproto.ui b/common/textproto.ui
index b3cf278..f6996aa 100644
--- a/common/textproto.ui
+++ b/common/textproto.ui
@@ -5,7 +5,7 @@
0
0
- 493
+ 535
300
@@ -33,7 +33,36 @@
+ -
+
+
+ Line Ending
+
+
+
-
+
+
+ 2
+
+
-
+
+ CR
+
+
+ -
+
+ LF
+
+
+ -
+
+ CRLF
+
+
+
+
+ -
Encode as
@@ -43,7 +72,7 @@
- -
+
-
@@ -58,7 +87,7 @@
- -
+
-
false