summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-05-03 20:39:27 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-05-05 19:43:14 (GMT)
commit772b2ec0243d7b55d91e4027d828881d18093ed0 (patch)
tree83a58b2b97f3992165ee20c05e0630452eb50457 /Swiften/LinkLocal/LinkLocalServiceInfo.cpp
parent0b3db8fd68abee7269d5a38aabd8a816e099eae5 (diff)
downloadswift-contrib-772b2ec0243d7b55d91e4027d828881d18093ed0.zip
swift-contrib-772b2ec0243d7b55d91e4027d828881d18093ed0.tar.bz2
Replace ByteArray by typedef.
Diffstat (limited to 'Swiften/LinkLocal/LinkLocalServiceInfo.cpp')
-rw-r--r--Swiften/LinkLocal/LinkLocalServiceInfo.cpp29
1 files changed, 16 insertions, 13 deletions
diff --git a/Swiften/LinkLocal/LinkLocalServiceInfo.cpp b/Swiften/LinkLocal/LinkLocalServiceInfo.cpp
index 2be0049..f437fc2 100644
--- a/Swiften/LinkLocal/LinkLocalServiceInfo.cpp
+++ b/Swiften/LinkLocal/LinkLocalServiceInfo.cpp
@@ -8,36 +8,39 @@
#include <boost/lexical_cast.hpp>
+#include <Swiften/Base/Algorithm.h>
+#include <Swiften/Base/Concat.h>
+
namespace Swift {
ByteArray LinkLocalServiceInfo::toTXTRecord() const {
ByteArray result(getEncoded("txtvers=1"));
if (!firstName.empty()) {
- result += getEncoded("1st=" + firstName);
+ append(result, getEncoded("1st=" + firstName));
}
if (!lastName.empty()) {
- result += getEncoded("last=" + lastName);
+ append(result, getEncoded("last=" + lastName));
}
if (!email.empty()) {
- result += getEncoded("email=" + email);
+ append(result, getEncoded("email=" + email));
}
if (jid.isValid()) {
- result += getEncoded("jid=" + jid.toString());
+ append(result, getEncoded("jid=" + jid.toString()));
}
if (!message.empty()) {
- result += getEncoded("msg=" + message);
+ append(result, getEncoded("msg=" + message));
}
if (!nick.empty()) {
- result += getEncoded("nick=" + nick);
+ append(result, getEncoded("nick=" + nick));
}
if (port) {
- result += getEncoded("port.p2pj=" + std::string(boost::lexical_cast<std::string>(*port)));
+ append(result, getEncoded("port.p2pj=" + std::string(boost::lexical_cast<std::string>(*port))));
}
switch (status) {
- case Available: result += getEncoded("status=avail"); break;
- case Away: result += getEncoded("status=away"); break;
- case DND: result += getEncoded("status=dnd"); break;
+ case Available: append(result, getEncoded("status=avail")); break;
+ case Away: append(result, getEncoded("status=away")); break;
+ case DND: append(result, getEncoded("status=dnd")); break;
}
return result;
@@ -47,13 +50,13 @@ ByteArray LinkLocalServiceInfo::getEncoded(const std::string& s) {
ByteArray sizeByte;
sizeByte.resize(1);
sizeByte[0] = s.size();
- return sizeByte + ByteArray(s);
+ return concat(sizeByte, createByteArray(s));
}
LinkLocalServiceInfo LinkLocalServiceInfo::createFromTXTRecord(const ByteArray& record) {
LinkLocalServiceInfo info;
size_t i = 0;
- while (i < record.getSize()) {
+ while (i < record.size()) {
std::pair<std::string,std::string> entry = readEntry(record, &i);
if (entry.first.empty()) {
break;
@@ -99,7 +102,7 @@ std::pair<std::string,std::string> LinkLocalServiceInfo::readEntry(const ByteArr
size_t entryEnd = i + 1 + record[i];
++i;
bool inKey = true;
- while (i < entryEnd && i < record.getSize()) {
+ while (i < entryEnd && i < record.size()) {
if (inKey) {
if (record[i] == '=') {
inKey = false;