From b8f9685565a64b1d04d545bfa1ffead2a84547cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20P=C3=B6sel?= Date: Wed, 4 Mar 2015 12:05:53 +0000 Subject: Facebook: Use participant names in chatroom name / seen info in "Firstname S." format git-svn-id: http://svn.miranda-ng.org/main/trunk@12312 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/FacebookRM/src/utils.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'protocols/FacebookRM/src/utils.cpp') diff --git a/protocols/FacebookRM/src/utils.cpp b/protocols/FacebookRM/src/utils.cpp index f277103203..383aac5d4b 100644 --- a/protocols/FacebookRM/src/utils.cpp +++ b/protocols/FacebookRM/src/utils.cpp @@ -456,6 +456,24 @@ std::string utils::text::source_get_form_data(std::string* data) return values; } +std::tstring utils::text::prepare_name(const std::tstring &name, bool withSurnameLetter) +{ + std::tstring::size_type pos = name.find(_T(" ")); + if (pos == std::tstring::npos) + return name; + + std::tstring result = name.substr(0, pos); + + if (withSurnameLetter) { + pos = name.rfind(_T(" ")) + 1; // we're sure there is some space in name so we can do +1 safely + + if (pos < name.length()) + result += _T(" ") + name.substr(pos, 1) + std::tstring(_T(".")); + } + + return result; +} + std::string utils::text::rand_string(int len, const char *chars, unsigned int *number) { std::stringstream out; -- cgit v1.2.3