summaryrefslogtreecommitdiff
path: root/protocols/FacebookRM/src/contacts.cpp
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2013-09-27 11:44:58 +0000
committerRobert Pösel <robyer@seznam.cz>2013-09-27 11:44:58 +0000
commit0c7b52a9973306c6896f3dd8e46eb9bcc4cffffb (patch)
tree2f345aa6bd587e5593cc262ad4a9bcbbf2231230 /protocols/FacebookRM/src/contacts.cpp
parentdae67fa8059f77a0bd2cbf7e69e0a2d6a3e59a3f (diff)
Facebook: Save names separately into first, second and last name fields
git-svn-id: http://svn.miranda-ng.org/main/trunk@6247 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM/src/contacts.cpp')
-rw-r--r--protocols/FacebookRM/src/contacts.cpp36
1 files changed, 34 insertions, 2 deletions
diff --git a/protocols/FacebookRM/src/contacts.cpp b/protocols/FacebookRM/src/contacts.cpp
index b4b2a28603..5449847d08 100644
--- a/protocols/FacebookRM/src/contacts.cpp
+++ b/protocols/FacebookRM/src/contacts.cpp
@@ -22,6 +22,39 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "common.h"
+void FacebookProto::SaveName(HANDLE hContact, const facebook_user *fbu)
+{
+ if (fbu->real_name.empty()) {
+ delSetting(hContact, FACEBOOK_KEY_NICK);
+ delSetting(hContact, FACEBOOK_KEY_FIRST_NAME);
+ delSetting(hContact, FACEBOOK_KEY_SECOND_NAME);
+ delSetting(hContact, FACEBOOK_KEY_LAST_NAME);
+ return;
+ }
+
+ db_set_utf(hContact, m_szModuleName, FACEBOOK_KEY_NICK, fbu->real_name.c_str());
+
+ // Explode whole name into first, second and last name
+ std::vector<std::string> names;
+ utils::text::explode(fbu->real_name, " ", &names);
+
+ db_set_utf(hContact, m_szModuleName, FACEBOOK_KEY_FIRST_NAME, names.front().c_str());
+ db_set_utf(hContact, m_szModuleName, FACEBOOK_KEY_LAST_NAME, names.back().c_str());
+
+ if (names.size() > 2) {
+ std::string middle = "";
+ for (std::string::size_type i = 1; i < names.size() - 1; i++) {
+ if (!middle.empty())
+ middle += " ";
+
+ middle += names.at(i);
+ }
+ db_set_utf(hContact, m_szModuleName, FACEBOOK_KEY_SECOND_NAME, middle.c_str());
+ } else {
+ delSetting(hContact, FACEBOOK_KEY_SECOND_NAME);
+ }
+}
+
bool FacebookProto::IsMyContact(HANDLE hContact, bool include_chat)
{
const char *proto = GetContactProto(hContact);
@@ -91,8 +124,7 @@ HANDLE FacebookProto::AddToContactList(facebook_user* fbu, ContactType type, boo
db_set_ts(hContact, "CList", "Group", group);
if (!fbu->real_name.empty()) {
- db_set_utf(hContact, m_szModuleName, FACEBOOK_KEY_NAME, fbu->real_name.c_str());
- db_set_utf(hContact, m_szModuleName, FACEBOOK_KEY_NICK, fbu->real_name.c_str());
+ SaveName(hContact, fbu);
}
if (fbu->gender)