mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Modifications to chat and msgs to allow wchar_t messages
(support for multiple languages) git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@317 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
c4e1d73837
commit
bfb0b2be2b
@ -152,8 +152,10 @@ void NotifyTxt::displayMessages()
|
||||
for(it = msgs.begin(); it != msgs.end(); it++)
|
||||
{
|
||||
out << "Message: ";
|
||||
out << it->title << std::endl;
|
||||
out << "\t" << it->msg << std::endl;
|
||||
std::string cnv_title(it->title.begin(), it->title.end());
|
||||
out << cnv_title << std::endl;
|
||||
std::string cnv_msg(it->msg.begin(), it->msg.end());
|
||||
out << "\t" << cnv_msg << std::endl;
|
||||
const std::list<FileInfo> &files = it -> files;
|
||||
for(fit = files.begin(), i = 1; fit != files.end(); fit++, i++)
|
||||
{
|
||||
|
@ -187,11 +187,11 @@ class MessageInfo: public BaseInfo
|
||||
std::list<PersonInfo> msgcc;
|
||||
std::list<PersonInfo> msgbcc;
|
||||
|
||||
std::string title;
|
||||
std::string msg;
|
||||
std::wstring title;
|
||||
std::wstring msg;
|
||||
|
||||
std::string attach_title;
|
||||
std::string attach_comment;
|
||||
std::wstring attach_title;
|
||||
std::wstring attach_comment;
|
||||
std::list<FileInfo> files;
|
||||
int size; /* total of files */
|
||||
int count; /* file count */
|
||||
@ -228,7 +228,7 @@ class ChatInfo: public BaseInfo
|
||||
std::string rsid;
|
||||
unsigned int chatflags;
|
||||
std::string name;
|
||||
std::string msg;
|
||||
std::wstring msg;
|
||||
};
|
||||
|
||||
/* matched to the uPnP states */
|
||||
|
@ -619,7 +619,6 @@ int RsServer::StartupRetroShare(RsInit *config)
|
||||
msgSrv->loadWelcomeMsg();
|
||||
}
|
||||
|
||||
|
||||
// load up the help page
|
||||
std::string helppage = config->basedir + config->dirSeperator;
|
||||
helppage += configHelpName;
|
||||
|
@ -741,7 +741,7 @@ bool RsCacheConfigSerialiser::serialise(RsItem *i, void *data, uint32_t *size)
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_NAME, item->name);
|
||||
std::cerr << "RsCacheConfigSerialiser::serialise() name: " << ok << std::endl;
|
||||
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_HASH, item->hash);
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_HASH_SHA1, item->hash);
|
||||
std::cerr << "RsCacheConfigSerialiser::serialise() hash: " << ok << std::endl;
|
||||
|
||||
|
||||
@ -811,7 +811,7 @@ RsItem *RsCacheConfigSerialiser::deserialise(void *data, uint32_t *size)
|
||||
case TLV_TYPE_STR_NAME:
|
||||
ok &= GetTlvString(data, tlvend, offset, tlvsubtype, item->name);
|
||||
break;
|
||||
case TLV_TYPE_STR_HASH:
|
||||
case TLV_TYPE_STR_HASH_SHA1:
|
||||
ok &= GetTlvString(data, tlvend, offset, tlvsubtype, item->hash);
|
||||
break;
|
||||
default:
|
||||
|
@ -42,7 +42,7 @@ void RsChatItem::clear()
|
||||
{
|
||||
chatFlags = 0;
|
||||
sendTime = 0;
|
||||
message = "";
|
||||
message.clear();
|
||||
}
|
||||
|
||||
std::ostream &RsChatItem::print(std::ostream &out, uint16_t indent)
|
||||
@ -56,7 +56,9 @@ std::ostream &RsChatItem::print(std::ostream &out, uint16_t indent)
|
||||
out << "sendTime: " << sendTime << std::endl;
|
||||
|
||||
printIndent(out, int_Indent);
|
||||
out << "msg: " << message << std::endl;
|
||||
|
||||
std::string cnv_message(message.begin(), message.end());
|
||||
out << "msg: " << cnv_message << std::endl;
|
||||
|
||||
printRsItemEnd(out, "RsChatItem", indent);
|
||||
return out;
|
||||
@ -68,7 +70,7 @@ uint32_t RsChatSerialiser::sizeItem(RsChatItem *item)
|
||||
uint32_t s = 8; /* header */
|
||||
s += 4; /* chatFlags */
|
||||
s += 4; /* sendTime */
|
||||
s += GetTlvStringSize(item->message);
|
||||
s += GetTlvWideStringSize(item->message);
|
||||
|
||||
return s;
|
||||
}
|
||||
@ -99,7 +101,7 @@ bool RsChatSerialiser::serialiseItem(RsChatItem *item, void *data, uint32_t
|
||||
std::cerr << "RsChatSerialiser::serialiseItem() chatFlags: " << ok << std::endl;
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->sendTime);
|
||||
std::cerr << "RsChatSerialiser::serialiseItem() sendTime: " << ok << std::endl;
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_MSG, item->message);
|
||||
ok &= SetTlvWideString(data, tlvsize, &offset, TLV_TYPE_WSTR_MSG, item->message);
|
||||
std::cerr << "RsChatSerialiser::serialiseItem() Message: " << ok << std::endl;
|
||||
|
||||
if (offset != tlvsize)
|
||||
@ -145,7 +147,7 @@ RsChatItem *RsChatSerialiser::deserialiseItem(void *data, uint32_t *pktsize)
|
||||
/* get mandatory parts first */
|
||||
ok &= getRawUInt32(data, rssize, &offset, &(item->chatFlags));
|
||||
ok &= getRawUInt32(data, rssize, &offset, &(item->sendTime));
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_MSG, item->message);
|
||||
ok &= GetTlvWideString(data, rssize, &offset, TLV_TYPE_WSTR_MSG, item->message);
|
||||
|
||||
if (offset != rssize)
|
||||
{
|
||||
@ -195,8 +197,8 @@ void RsMsgItem::clear()
|
||||
msgFlags = 0;
|
||||
sendTime = 0;
|
||||
recvTime = 0;
|
||||
subject = "";
|
||||
message = "";
|
||||
subject.clear();
|
||||
message.clear();
|
||||
|
||||
msgto.TlvClear();
|
||||
msgcc.TlvClear();
|
||||
@ -232,9 +234,12 @@ std::ostream &RsMsgItem::print(std::ostream &out, uint16_t indent)
|
||||
msgbcc.print(out, int_Indent);
|
||||
|
||||
printIndent(out, int_Indent);
|
||||
out << "subject: " << subject << std::endl;
|
||||
std::string cnv_subject(subject.begin(), subject.end());
|
||||
out << "subject: " << cnv_subject << std::endl;
|
||||
|
||||
printIndent(out, int_Indent);
|
||||
out << "msg: " << message << std::endl;
|
||||
std::string cnv_message(message.begin(), message.end());
|
||||
out << "msg: " << cnv_message << std::endl;
|
||||
|
||||
printIndent(out, int_Indent);
|
||||
out << "Attachment: " << std::endl;
|
||||
@ -252,8 +257,8 @@ uint32_t RsMsgSerialiser::sizeItem(RsMsgItem *item)
|
||||
s += 4; /* sendTime */
|
||||
s += 4; /* recvTime */
|
||||
|
||||
s += GetTlvStringSize(item->subject);
|
||||
s += GetTlvStringSize(item->message);
|
||||
s += GetTlvWideStringSize(item->subject);
|
||||
s += GetTlvWideStringSize(item->message);
|
||||
|
||||
s += item->msgto.TlvSize();
|
||||
s += item->msgcc.TlvSize();
|
||||
@ -292,9 +297,9 @@ bool RsMsgSerialiser::serialiseItem(RsMsgItem *item, void *data, uint32_t *p
|
||||
ok &= setRawUInt32(data, tlvsize, &offset, item->recvTime);
|
||||
std::cerr << "RsMsgSerialiser::serialiseItem() recvTime: " << ok << std::endl;
|
||||
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_SUBJECT, item->subject);
|
||||
ok &= SetTlvWideString(data,tlvsize,&offset,TLV_TYPE_WSTR_SUBJECT,item->subject);
|
||||
std::cerr << "RsMsgSerialiser::serialiseItem() Subject: " << ok << std::endl;
|
||||
ok &= SetTlvString(data, tlvsize, &offset, TLV_TYPE_STR_MSG, item->message);
|
||||
ok &= SetTlvWideString(data, tlvsize, &offset, TLV_TYPE_WSTR_MSG, item->message);
|
||||
std::cerr << "RsMsgSerialiser::serialiseItem() Message: " << ok << std::endl;
|
||||
|
||||
ok &= item->msgto.SetTlv(data, tlvsize, &offset);
|
||||
@ -351,8 +356,8 @@ RsMsgItem *RsMsgSerialiser::deserialiseItem(void *data, uint32_t *pktsize)
|
||||
ok &= getRawUInt32(data, rssize, &offset, &(item->sendTime));
|
||||
ok &= getRawUInt32(data, rssize, &offset, &(item->recvTime));
|
||||
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_SUBJECT, item->message);
|
||||
ok &= GetTlvString(data, rssize, &offset, TLV_TYPE_STR_MSG, item->message);
|
||||
ok &= GetTlvWideString(data,rssize,&offset,TLV_TYPE_WSTR_SUBJECT,item->subject);
|
||||
ok &= GetTlvWideString(data, rssize, &offset, TLV_TYPE_WSTR_MSG, item->message);
|
||||
ok &= item->msgto.GetTlv(data, rssize, &offset);
|
||||
ok &= item->msgcc.GetTlv(data, rssize, &offset);
|
||||
ok &= item->msgbcc.GetTlv(data, rssize, &offset);
|
||||
|
@ -52,7 +52,7 @@ std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
||||
uint32_t chatFlags;
|
||||
uint32_t sendTime;
|
||||
|
||||
std::string message;
|
||||
std::wstring message;
|
||||
|
||||
/* not serialised */
|
||||
uint32_t recvTime;
|
||||
@ -104,8 +104,8 @@ std::ostream &print(std::ostream &out, uint16_t indent = 0);
|
||||
uint32_t sendTime;
|
||||
uint32_t recvTime;
|
||||
|
||||
std::string subject;
|
||||
std::string message;
|
||||
std::wstring subject;
|
||||
std::wstring message;
|
||||
|
||||
RsTlvPeerIdSet msgto;
|
||||
RsTlvPeerIdSet msgcc;
|
||||
|
@ -446,6 +446,112 @@ uint32_t GetTlvStringSize(std::string &in) {
|
||||
return 4 + in.size();
|
||||
}
|
||||
|
||||
|
||||
/* We must use a consistent wchar size for cross platform ness.
|
||||
* As unix uses 4bytes, and windows 2bytes? we'll go with 4bytes for maximum flexibility
|
||||
*/
|
||||
|
||||
const uint32_t RS_WCHAR_SIZE = 4;
|
||||
|
||||
bool SetTlvWideString(void *data, uint32_t size, uint32_t *offset,
|
||||
uint16_t type, std::wstring out)
|
||||
{
|
||||
if (!data)
|
||||
return false;
|
||||
uint16_t tlvsize = GetTlvWideStringSize(out);
|
||||
uint32_t tlvend = *offset + tlvsize; /* where the data will extend to */
|
||||
|
||||
if (size < tlvend)
|
||||
{
|
||||
#ifdef TLV_BASE_DEBUG
|
||||
std::cerr << "SetTlvWideString() FAILED - not enough space" << std::endl;
|
||||
std::cerr << "SetTlvWideString() size: " << size << std::endl;
|
||||
std::cerr << "SetTlvWideString() tlvsize: " << tlvsize << std::endl;
|
||||
std::cerr << "SetTlvWideString() tlvend: " << tlvend << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ok = true;
|
||||
ok &= SetTlvBase(data, tlvend, offset, type, tlvsize);
|
||||
|
||||
uint16_t strlen = out.length();
|
||||
|
||||
/* Must convert manually to ensure its always the same! */
|
||||
for(uint16_t i = 0; i < strlen; i++)
|
||||
{
|
||||
uint32_t widechar = out[i];
|
||||
ok &= setRawUInt32(data, tlvend, offset, widechar);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
//tested
|
||||
bool GetTlvWideString(void *data, uint32_t size, uint32_t *offset,
|
||||
uint16_t type, std::wstring &in)
|
||||
{
|
||||
if (!data)
|
||||
return false;
|
||||
|
||||
if (size < *offset + 4)
|
||||
{
|
||||
#ifdef TLV_BASE_DEBUG
|
||||
std::cerr << "GetTlvWideString() FAILED - not enough space" << std::endl;
|
||||
std::cerr << "GetTlvWideString() size: " << size << std::endl;
|
||||
std::cerr << "GetTlvWideString() *offset: " << *offset << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
/* extract the type and size */
|
||||
void *tlvstart = right_shift_void_pointer(data, *offset);
|
||||
uint16_t tlvtype = GetTlvType(tlvstart);
|
||||
uint16_t tlvsize = GetTlvSize(tlvstart);
|
||||
|
||||
/* check that there is size */
|
||||
uint32_t tlvend = *offset + tlvsize;
|
||||
if (size < tlvend)
|
||||
{
|
||||
#ifdef TLV_BASE_DEBUG
|
||||
std::cerr << "GetTlvWideString() FAILED - not enough space" << std::endl;
|
||||
std::cerr << "GetTlvWideString() size: " << size << std::endl;
|
||||
std::cerr << "GetTlvWideString() tlvsize: " << tlvsize << std::endl;
|
||||
std::cerr << "GetTlvWideString() tlvend: " << tlvend << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
if (type != tlvtype)
|
||||
{
|
||||
#ifdef TLV_BASE_DEBUG
|
||||
std::cerr << "GetTlvWideString() FAILED - invalid type" << std::endl;
|
||||
std::cerr << "GetTlvWideString() type: " << type << std::endl;
|
||||
std::cerr << "GetTlvWideString() tlvtype: " << tlvtype << std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool ok = true;
|
||||
/* remove the header, calc string length */
|
||||
*offset += 4;
|
||||
uint16_t strlen = (tlvsize - 4) / RS_WCHAR_SIZE;
|
||||
|
||||
/* Must convert manually to ensure its always the same! */
|
||||
for(uint16_t i = 0; i < strlen; i++)
|
||||
{
|
||||
uint32_t widechar;
|
||||
ok &= getRawUInt32(data, tlvend, offset, &widechar);
|
||||
in += widechar;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
uint32_t GetTlvWideStringSize(std::wstring &in) {
|
||||
return 4 + in.size() * RS_WCHAR_SIZE;
|
||||
}
|
||||
|
||||
|
||||
bool SetTlvIpAddrPortV4(void *data, uint32_t size, uint32_t *offset,
|
||||
uint16_t type, struct sockaddr_in *out) {
|
||||
if (!data)
|
||||
|
@ -66,16 +66,22 @@
|
||||
/* 0b 0000 0000 0011 XXXX UInt32 */
|
||||
/* 0b 0000 0000 0100 XXXX UInt64 */
|
||||
/* 0b 0000 0000 0101 XXXX String */
|
||||
/* 0b 0000 0000 0110 XXXX IP:Port V4 */
|
||||
/* 0b 0000 0000 0111 XXXX ?????? */
|
||||
/* 0b 0000 0000 0110 XXXX Wide String */
|
||||
/* 0b 0000 0000 0111 XXXX Hashes */
|
||||
/* 0b 0000 0000 1000 XXXX IP:Port V4 */
|
||||
|
||||
/******* BINARY TYPES *****************/
|
||||
/* 0b 0000 0000 1000 XXXX CERT */
|
||||
/* 0b 0000 0000 1001 XXXX Priv Key */
|
||||
/* 0b 0000 0000 1010 XXXX Pub Key */
|
||||
/* 0b 0000 0000 1011 XXXX Signature */
|
||||
/* 0b 0000 0001 0000 XXXX CERT */
|
||||
/* 0b 0000 0001 0001 XXXX Priv Key */
|
||||
/* 0b 0000 0001 0010 XXXX Pub Key */
|
||||
/* 0b 0000 0001 0011 XXXX Signature */
|
||||
|
||||
/******* COMPOUND TYPES ***************/
|
||||
/* 0b 0001 XXXX XXXX XXXX Compound */
|
||||
/* 0b 0001 0000 0000 XXXX FILE */
|
||||
/* 0b 0001 0000 0001 XXXX KEY VALUE */
|
||||
/* 0b 0001 0000 0010 XXXX PEERS */
|
||||
/* 0b 0001 0000 0011 XXXX SERVICES */
|
||||
|
||||
const uint16_t TLV_TYPE_UINT8_SERID = 0x0010;
|
||||
|
||||
@ -90,45 +96,59 @@ const uint16_t TLV_TYPE_UINT32_SERID = 0x0034;
|
||||
const uint16_t TLV_TYPE_UINT64_SIZE = 0x0040;
|
||||
const uint16_t TLV_TYPE_UINT64_OFFSET = 0x0041;
|
||||
|
||||
const uint16_t TLV_TYPE_STR_HASH = 0x0050;
|
||||
const uint16_t TLV_TYPE_STR_PEERID = 0x0050;
|
||||
const uint16_t TLV_TYPE_STR_NAME = 0x0051;
|
||||
const uint16_t TLV_TYPE_STR_PATH = 0x0052;
|
||||
const uint16_t TLV_TYPE_STR_PEERID = 0x0053;
|
||||
const uint16_t TLV_TYPE_STR_KEY = 0x0054;
|
||||
const uint16_t TLV_TYPE_STR_VALUE = 0x0055;
|
||||
const uint16_t TLV_TYPE_STR_COMMENT = 0x0056;
|
||||
const uint16_t TLV_TYPE_STR_TITLE = 0x0057;
|
||||
const uint16_t TLV_TYPE_STR_MSG = 0x0058;
|
||||
const uint16_t TLV_TYPE_STR_SUBJECT = 0x0059;
|
||||
const uint16_t TLV_TYPE_STR_KEY = 0x0053;
|
||||
const uint16_t TLV_TYPE_STR_VALUE = 0x0054;
|
||||
const uint16_t TLV_TYPE_STR_COMMENT = 0x0055;
|
||||
const uint16_t TLV_TYPE_STR_TITLE = 0x0056;
|
||||
const uint16_t TLV_TYPE_STR_MSG = 0x0057;
|
||||
const uint16_t TLV_TYPE_STR_SUBJECT = 0x0058;
|
||||
|
||||
/* Wide Chars (4 bytes per char) for internationalisation */
|
||||
const uint16_t TLV_TYPE_WSTR_PEERID = 0x0060;
|
||||
const uint16_t TLV_TYPE_WSTR_NAME = 0x0061;
|
||||
const uint16_t TLV_TYPE_WSTR_PATH = 0x0062;
|
||||
const uint16_t TLV_TYPE_WSTR_KEY = 0x0063;
|
||||
const uint16_t TLV_TYPE_WSTR_VALUE = 0x0064;
|
||||
const uint16_t TLV_TYPE_WSTR_COMMENT = 0x0065;
|
||||
const uint16_t TLV_TYPE_WSTR_TITLE = 0x0066;
|
||||
const uint16_t TLV_TYPE_WSTR_MSG = 0x0067;
|
||||
const uint16_t TLV_TYPE_WSTR_SUBJECT = 0x0068;
|
||||
|
||||
/* Hashs are always strings */
|
||||
const uint16_t TLV_TYPE_STR_HASH_SHA1 = 0x0070;
|
||||
const uint16_t TLV_TYPE_STR_HASH_ED2K = 0x0071;
|
||||
|
||||
const uint16_t TLV_TYPE_IPV4_LOCAL = 0x0080;
|
||||
const uint16_t TLV_TYPE_IPV4_SERVER = 0x0081;
|
||||
const uint16_t TLV_TYPE_IPV4_LAST = 0x0082;
|
||||
|
||||
const uint16_t TLV_TYPE_IPV4_LOCAL = 0x0060;
|
||||
const uint16_t TLV_TYPE_IPV4_SERVER = 0x0061;
|
||||
const uint16_t TLV_TYPE_IPV4_LAST = 0x0062;
|
||||
|
||||
/**** Binary Types ****/
|
||||
const uint16_t TLV_TYPE_CERT_XPGP_DER = 0x0080;
|
||||
const uint16_t TLV_TYPE_CERT_X509 = 0x0081;
|
||||
const uint16_t TLV_TYPE_CERT_OPENPGP = 0x0082;
|
||||
const uint16_t TLV_TYPE_CERT_XPGP_DER = 0x0100;
|
||||
const uint16_t TLV_TYPE_CERT_X509 = 0x0101;
|
||||
const uint16_t TLV_TYPE_CERT_OPENPGP = 0x0102;
|
||||
|
||||
const uint16_t TLV_TYPE_PRIV_KEY_RSA = 0x0090;
|
||||
const uint16_t TLV_TYPE_PRIV_KEY_RSA = 0x0110;
|
||||
|
||||
const uint16_t TLV_TYPE_PUB_KEY_RSA = 0x00A0;
|
||||
const uint16_t TLV_TYPE_PUB_KEY_RSA = 0x0120;
|
||||
|
||||
const uint16_t TLV_TYPE_SIGN_RSA_SHA1 = 0x00B0;
|
||||
const uint16_t TLV_TYPE_SIGN_RSA_SHA1 = 0x0130;
|
||||
|
||||
const uint16_t TLV_TYPE_BIN_FILEDATA = 0x00C0;
|
||||
const uint16_t TLV_TYPE_BIN_FILEDATA = 0x0140;
|
||||
|
||||
/**** Compound Types ****/
|
||||
const uint16_t TLV_TYPE_FILEITEM = 0x1001;
|
||||
const uint16_t TLV_TYPE_FILESET = 0x1002;
|
||||
const uint16_t TLV_TYPE_FILEDATA = 0x1003;
|
||||
const uint16_t TLV_TYPE_FILEITEM = 0x1000;
|
||||
const uint16_t TLV_TYPE_FILESET = 0x1001;
|
||||
const uint16_t TLV_TYPE_FILEDATA = 0x1002;
|
||||
|
||||
const uint16_t TLV_TYPE_KEYVALUE = 0x1005;
|
||||
const uint16_t TLV_TYPE_KEYVALUESET = 0x1006;
|
||||
const uint16_t TLV_TYPE_KEYVALUE = 0x1010;
|
||||
const uint16_t TLV_TYPE_KEYVALUESET = 0x1011;
|
||||
|
||||
const uint16_t TLV_TYPE_PEERSET = 0x1007;
|
||||
const uint16_t TLV_TYPE_SERVICESET = 0x1008;
|
||||
const uint16_t TLV_TYPE_PEERSET = 0x1020;
|
||||
const uint16_t TLV_TYPE_SERVICESET = 0x1030;
|
||||
|
||||
|
||||
/**** Basic TLV Functions ****/
|
||||
@ -166,6 +186,10 @@ bool SetTlvString(void *data, uint32_t size, uint32_t *offset, uint16_t type
|
||||
bool GetTlvString(void *data, uint32_t size, uint32_t *offset, uint16_t type, std::string &in);
|
||||
uint32_t GetTlvStringSize(std::string &in);
|
||||
|
||||
bool SetTlvWideString(void *data, uint32_t size, uint32_t *offset, uint16_t type, std::wstring out);
|
||||
bool GetTlvWideString(void *data, uint32_t size, uint32_t *offset, uint16_t type, std::wstring &in);
|
||||
uint32_t GetTlvWideStringSize(std::wstring &in);
|
||||
|
||||
bool SetTlvIpAddrPortV4(void *data, uint32_t size, uint32_t *offset, uint16_t type, struct sockaddr_in *out);
|
||||
bool GetTlvIpAddrPortV4(void *data, uint32_t size, uint32_t *offset, uint16_t type, struct sockaddr_in *in);
|
||||
uint32_t GetTlvIpAddrPortV4Size();
|
||||
|
@ -139,7 +139,7 @@ bool RsTlvFileItem::SetTlv(void *data, uint32_t size, uint32_t *offset)
|
||||
std::cerr << std::endl;
|
||||
#endif
|
||||
|
||||
ok &= SetTlvString(data, tlvend, offset, TLV_TYPE_STR_HASH, hash);
|
||||
ok &= SetTlvString(data, tlvend, offset, TLV_TYPE_STR_HASH_SHA1, hash);
|
||||
|
||||
|
||||
#ifdef TLV_FI_DEBUG
|
||||
@ -237,7 +237,7 @@ bool RsTlvFileItem::GetTlv(void *data, uint32_t size, uint32_t *offset)
|
||||
|
||||
/* get mandatory parts first */
|
||||
ok &= getRawUInt64(data, tlvend, offset, &filesize);
|
||||
ok &= GetTlvString(data, tlvend, offset, TLV_TYPE_STR_HASH, hash);
|
||||
ok &= GetTlvString(data, tlvend, offset, TLV_TYPE_STR_HASH_SHA1, hash);
|
||||
|
||||
/* while there is more TLV (optional part) */
|
||||
while((*offset) + 2 < tlvend)
|
||||
@ -316,8 +316,8 @@ std::ostream &RsTlvFileItem::print(std::ostream &out, uint16_t indent)
|
||||
|
||||
void RsTlvFileSet::TlvClear()
|
||||
{
|
||||
title = "";
|
||||
comment = "";
|
||||
title.clear();
|
||||
comment.clear();
|
||||
items.clear();
|
||||
}
|
||||
|
||||
@ -337,9 +337,9 @@ uint16_t RsTlvFileSet::TlvSize()
|
||||
/* now add comment and title length of this tlv object */
|
||||
|
||||
if (title.length() > 0)
|
||||
s += GetTlvStringSize(title);
|
||||
s += GetTlvWideStringSize(title);
|
||||
if (comment.length() > 0)
|
||||
s += GetTlvStringSize(comment);
|
||||
s += GetTlvWideStringSize(comment);
|
||||
|
||||
return s;
|
||||
}
|
||||
@ -374,9 +374,9 @@ bool RsTlvFileSet::SetTlv(void *data, uint32_t size, uint32_t *offset) /* se
|
||||
|
||||
/* now optional ones */
|
||||
if (title.length() > 0)
|
||||
ok &= SetTlvString(data, tlvend, offset, TLV_TYPE_STR_TITLE, title); // no base tlv type for title?
|
||||
ok &= SetTlvWideString(data, tlvend, offset, TLV_TYPE_WSTR_TITLE, title);
|
||||
if (comment.length() > 0)
|
||||
ok &= SetTlvString(data, tlvend, offset, TLV_TYPE_STR_COMMENT, comment); // no base tlv type for comment?
|
||||
ok &= SetTlvWideString(data, tlvend, offset, TLV_TYPE_WSTR_COMMENT, comment);
|
||||
|
||||
return ok;
|
||||
|
||||
@ -420,15 +420,15 @@ bool RsTlvFileSet::GetTlv(void *data, uint32_t size, uint32_t *offset)
|
||||
items.push_back(newitem);
|
||||
}
|
||||
}
|
||||
else if (tlvsubtype == TLV_TYPE_STR_TITLE)
|
||||
else if (tlvsubtype == TLV_TYPE_WSTR_TITLE)
|
||||
{
|
||||
ok &= GetTlvString(data, tlvend, offset,
|
||||
TLV_TYPE_STR_TITLE, title);
|
||||
ok &= GetTlvWideString(data, tlvend, offset,
|
||||
TLV_TYPE_WSTR_TITLE, title);
|
||||
}
|
||||
else if (tlvsubtype == TLV_TYPE_STR_COMMENT)
|
||||
else if (tlvsubtype == TLV_TYPE_WSTR_COMMENT)
|
||||
{
|
||||
ok &= GetTlvString(data, tlvend, offset,
|
||||
TLV_TYPE_STR_COMMENT, comment);
|
||||
ok &= GetTlvWideString(data, tlvend, offset,
|
||||
TLV_TYPE_WSTR_COMMENT, comment);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -468,12 +468,14 @@ std::ostream &RsTlvFileSet::print(std::ostream &out, uint16_t indent)
|
||||
if (title.length() > 0)
|
||||
{
|
||||
printIndent(out, int_Indent);
|
||||
out << "Title: " << title << std::endl;
|
||||
std::string cnv_title(title.begin(), title.end());
|
||||
out << "Title: " << cnv_title << std::endl;
|
||||
}
|
||||
if (comment.length() > 0)
|
||||
{
|
||||
printIndent(out, int_Indent);
|
||||
out << "Comment: " << comment << std::endl;
|
||||
std::string cnv_comment(comment.begin(), comment.end());
|
||||
out << "Comment: " << cnv_comment << std::endl;
|
||||
}
|
||||
|
||||
printEnd(out, "RsTlvFileSet", indent);
|
||||
|
@ -34,7 +34,7 @@
|
||||
#include <string>
|
||||
#include <list>
|
||||
|
||||
#define RS_TLV_TYPE_FILE_ITEM 0x0000
|
||||
//#define RS_TLV_TYPE_FILE_ITEM 0x0000
|
||||
|
||||
//! A base class for all tlv items
|
||||
/*! This class is provided to allow the serialisation and deserialization of compund
|
||||
@ -112,8 +112,8 @@ virtual bool GetTlv(void *data, uint32_t size, uint32_t *offset); /* deseria
|
||||
virtual std::ostream &print(std::ostream &out, uint16_t indent);
|
||||
|
||||
std::list<RsTlvFileItem> items; /// Mandatory
|
||||
std::string title; /// Optional: title of file set
|
||||
std::string comment; /// Optional: comments for file
|
||||
std::wstring title; /// Optional: title of file set
|
||||
std::wstring comment; /// Optional: comments for file
|
||||
};
|
||||
|
||||
|
||||
|
@ -67,7 +67,7 @@ int p3ChatService::status()
|
||||
|
||||
/***************** Chat Stuff **********************/
|
||||
|
||||
int p3ChatService::sendChat(std::string msg)
|
||||
int p3ChatService::sendChat(std::wstring msg)
|
||||
{
|
||||
/* go through all the peers */
|
||||
|
||||
@ -103,7 +103,7 @@ int p3ChatService::sendChat(std::string msg)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int p3ChatService::sendPrivateChat(std::string msg, std::string id)
|
||||
int p3ChatService::sendPrivateChat(std::wstring msg, std::string id)
|
||||
{
|
||||
// make chat item....
|
||||
pqioutput(PQL_DEBUG_BASIC, p3chatzone,
|
||||
|
@ -49,8 +49,8 @@ class p3ChatService: public p3Service
|
||||
virtual int tick();
|
||||
virtual int status();
|
||||
|
||||
int sendChat(std::string msg);
|
||||
int sendPrivateChat(std::string msg, std::string id);
|
||||
int sendChat(std::wstring msg);
|
||||
int sendPrivateChat(std::wstring msg, std::string id);
|
||||
|
||||
std::list<RsChatItem *> getChatQueue();
|
||||
|
||||
|
@ -352,18 +352,18 @@ void p3MsgService::loadWelcomeMsg()
|
||||
|
||||
msg -> sendTime = 0;
|
||||
|
||||
msg -> subject = "Welcome to Retroshare";
|
||||
msg -> subject = L"Welcome to Retroshare";
|
||||
|
||||
msg -> message = "Send and receive messages\n";
|
||||
msg -> message += "with your friends...\n\n";
|
||||
msg -> message = L"Send and receive messages\n";
|
||||
msg -> message += L"with your friends...\n\n";
|
||||
|
||||
msg -> message += "These can hold recommendations\n";
|
||||
msg -> message += "from your local shared files\n\n";
|
||||
msg -> message += L"These can hold recommendations\n";
|
||||
msg -> message += L"from your local shared files\n\n";
|
||||
|
||||
msg -> message += "Add recommendations through\n";
|
||||
msg -> message += "the Local Files Dialog\n\n";
|
||||
msg -> message += L"Add recommendations through\n";
|
||||
msg -> message += L"the Local Files Dialog\n\n";
|
||||
|
||||
msg -> message += "Enjoy.\n";
|
||||
msg -> message += L"Enjoy.\n";
|
||||
|
||||
imsg.push_back(msg);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user