diff options
| -rw-r--r-- | protocols/FacebookRM/src/communication.cpp | 3 | ||||
| -rw-r--r-- | protocols/FacebookRM/src/contacts.cpp | 36 | ||||
| -rw-r--r-- | protocols/FacebookRM/src/db.h | 5 | ||||
| -rw-r--r-- | protocols/FacebookRM/src/dialogs.cpp | 13 | ||||
| -rw-r--r-- | protocols/FacebookRM/src/process.cpp | 20 | ||||
| -rw-r--r-- | protocols/FacebookRM/src/proto.cpp | 4 | ||||
| -rw-r--r-- | protocols/FacebookRM/src/proto.h | 1 | 
7 files changed, 57 insertions, 25 deletions
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp index 27ddd33c68..e48bfd676c 100644 --- a/protocols/FacebookRM/src/communication.cpp +++ b/protocols/FacebookRM/src/communication.cpp @@ -874,8 +874,7 @@ bool facebook_client::home()  		// Get real_name
  		this->self_.real_name = utils::text::source_get_value(&resp.data, 2, "<strong class=\"profileName\">", "</strong>");
  		if (!this->self_.real_name.empty()) {
 -			db_set_utf(NULL, parent->m_szModuleName, FACEBOOK_KEY_NAME, this->self_.real_name.c_str());
 -			db_set_utf(NULL, parent->m_szModuleName, FACEBOOK_KEY_NICK, this->self_.real_name.c_str());
 +			parent->SaveName(NULL, &this->self_);
  			parent->Log("      Got self real name: %s", this->self_.real_name.c_str());
  		} else {
  			client_notify(TranslateT("Something happened to Facebook. Maybe there was some major update so you should wait for an update."));
 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)
 diff --git a/protocols/FacebookRM/src/db.h b/protocols/FacebookRM/src/db.h index df5877abf7..cfe3140711 100644 --- a/protocols/FacebookRM/src/db.h +++ b/protocols/FacebookRM/src/db.h @@ -26,10 +26,11 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.  #define FACEBOOK_KEY_LOGIN					"Email"
  #define FACEBOOK_KEY_ID						"ID"
  #define FACEBOOK_KEY_TID					"ThreadID"
 -#define FACEBOOK_KEY_NAME					"RealName"
 +#define FACEBOOK_KEY_FIRST_NAME				"FirstName"
 +#define FACEBOOK_KEY_SECOND_NAME			"SecondName"
 +#define FACEBOOK_KEY_LAST_NAME				"LastName"
  #define FACEBOOK_KEY_NICK					"Nick"
  #define FACEBOOK_KEY_PASS					"Password"
 -#define FACEBOOK_KEY_UPD_NAMES				"UpdateNames"
  #define FACEBOOK_KEY_DEVICE_ID				"DeviceID"
  #define FACEBOOK_KEY_AV_URL					"AvatarURL"
  #define FACEBOOK_KEY_DELETED				"Deleted"
 diff --git a/protocols/FacebookRM/src/dialogs.cpp b/protocols/FacebookRM/src/dialogs.cpp index 9f545181af..72ed6ecd75 100644 --- a/protocols/FacebookRM/src/dialogs.cpp +++ b/protocols/FacebookRM/src/dialogs.cpp @@ -159,7 +159,7 @@ void GetSelectedContacts(FacebookProto *proto, HANDLE hItem, HWND hwndList, std:  			if (SendMessage(hwndList, CLM_GETCHECKMARK, (WPARAM)hItem, 0)) {
  				facebook_user *fu = new facebook_user();
  				fu->user_id = ptrA(proto->getStringA(hItem, FACEBOOK_KEY_ID));
 -				fu->real_name = _T2A(ptrT(proto->getTStringA(hItem, FACEBOOK_KEY_NAME)));
 +				fu->real_name = _T2A(ptrT(proto->getTStringA(hItem, FACEBOOK_KEY_NICK)));
  				contacts->push_back(fu);
  			}
  		}
 @@ -213,15 +213,10 @@ INT_PTR CALLBACK FBMindProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lpara  		SendDlgItemMessage(hwnd, IDC_WALL, CB_SETCURSEL, data->proto->getByte(FACEBOOK_KEY_LAST_WALL, 0), 0);
  		RefreshPrivacy(hwnd, data);
 -		ptrA name(data->proto->getStringA(FACEBOOK_KEY_NAME));
 -		if (name != NULL) {
 -			std::string firstname = name;
 -			std::string::size_type pos = firstname.find(" ");
 -			if (pos != std::string::npos)
 -				firstname = firstname.substr(0, pos);
 -
 +		ptrA firstname(data->proto->getStringA(FACEBOOK_KEY_FIRST_NAME));
 +		if (firstname != NULL) {
  			char title[100];
 -			mir_snprintf(title, SIZEOF(title), Translate("What's on your mind, %s?"), firstname.c_str());
 +			mir_snprintf(title, SIZEOF(title), Translate("What's on your mind, %s?"), firstname);
  			SetWindowTextA(hwnd, title);
  		}
  	}
 diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp index edb554f9f8..2643a899ab 100644 --- a/protocols/FacebookRM/src/process.cpp +++ b/protocols/FacebookRM/src/process.cpp @@ -173,25 +173,29 @@ void FacebookProto::ProcessFriendList(void* data)  				// Found contact, update it and remove from map
  				fbu = iter->second;
 -				DBVARIANT dbv;
 -				bool update_required = true;
 -
  				// TODO RM: remove, because contacts cant change it, so its only for "first run"
  					// - but what with contacts, that was added after logon?
  				// Update gender
  				if (getByte(hContact, "Gender", 0) != fbu->gender)
  					setByte(hContact, "Gender", fbu->gender);
 -				// Update real name
 -				if (!db_get_utf(hContact, m_szModuleName, FACEBOOK_KEY_NAME, &dbv))
 +				// Update name
 +				DBVARIANT dbv;
 +				bool update_required = true;
 +
 +				// TODO: remove in some future version?
 +				ptrA realname(getStringA(hContact, "RealName"));
 +				if (realname != NULL) {
 +					delSetting(hContact, "RealName");
 +				}
 +				else if (!db_get_utf(hContact, m_szModuleName, FACEBOOK_KEY_NICK, &dbv))
  				{
  					update_required = strcmp(dbv.pszVal, fbu->real_name.c_str()) != 0;
  					db_free(&dbv);
  				}
  				if (update_required)
  				{
 -					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 (getByte(hContact, FACEBOOK_KEY_CONTACT_TYPE, 0) != CONTACT_FRIEND) {
 @@ -224,7 +228,7 @@ void FacebookProto::ProcessFriendList(void* data)  					setByte(hContact, FACEBOOK_KEY_CONTACT_TYPE, CONTACT_NONE);
  					std::string contactname = id;
 -					if (!db_get_utf(hContact, m_szModuleName, FACEBOOK_KEY_NAME, &dbv)) {
 +					if (!db_get_utf(hContact, m_szModuleName, FACEBOOK_KEY_NICK, &dbv)) {
  						contactname = dbv.pszVal;
  						db_free(&dbv);
  					}
 diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp index b35a1e230e..b07a209a2d 100644 --- a/protocols/FacebookRM/src/proto.cpp +++ b/protocols/FacebookRM/src/proto.cpp @@ -463,7 +463,7 @@ INT_PTR FacebookProto::OnMind(WPARAM wParam, LPARAM lParam)  	if (wall->user_id == facy.self_.user_id) {
  		wall->title = _tcsdup(TranslateT("Own wall"));
  	} else
 -		wall->title = getTStringA(hContact, FACEBOOK_KEY_NAME);
 +		wall->title = getTStringA(hContact, FACEBOOK_KEY_NICK);
  	post_status_data *data = new post_status_data(this, wall);
 @@ -577,7 +577,7 @@ INT_PTR FacebookProto::CancelFriendship(WPARAM wParam,LPARAM lParam)  	if (isChatRoom(hContact) || (deleting && getByte(hContact, FACEBOOK_KEY_CONTACT_TYPE, 0) != CONTACT_FRIEND))
  		return 0;
 -	ptrT tname(getTStringA(hContact, FACEBOOK_KEY_NAME));
 +	ptrT tname(getTStringA(hContact, FACEBOOK_KEY_NICK));
  	if (tname == NULL)
  		tname = getTStringA(hContact, FACEBOOK_KEY_ID);
 diff --git a/protocols/FacebookRM/src/proto.h b/protocols/FacebookRM/src/proto.h index 7f90c9fa44..8105d921a7 100644 --- a/protocols/FacebookRM/src/proto.h +++ b/protocols/FacebookRM/src/proto.h @@ -200,6 +200,7 @@ public:  	void ToggleStatusMenuItems(BOOL bEnable);
  	void ParseSmileys(std::string message, HANDLE hContact);
  	void OpenUrl(std::string url);
 +	void SaveName(HANDLE hContact, const facebook_user *fbu);
  	// Handles, Locks
  	HGENMENU m_hMenuRoot, m_hMenuServicesRoot, m_hStatusMind;
  | 
