diff options
Diffstat (limited to 'protocols/FacebookRM/src')
-rw-r--r-- | protocols/FacebookRM/src/client.h | 2 | ||||
-rw-r--r-- | protocols/FacebookRM/src/communication.cpp | 16 | ||||
-rw-r--r-- | protocols/FacebookRM/src/connection.cpp | 36 |
3 files changed, 19 insertions, 35 deletions
diff --git a/protocols/FacebookRM/src/client.h b/protocols/FacebookRM/src/client.h index d38a0ca528..5009389098 100644 --- a/protocols/FacebookRM/src/client.h +++ b/protocols/FacebookRM/src/client.h @@ -124,7 +124,7 @@ public: // Login handling
- bool login(const std::string &username, const std::string &password);
+ bool login(const char *username, const char *password);
bool logout();
const std::string & get_username() const;
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp index e48bfd676c..6cd98e11e7 100644 --- a/protocols/FacebookRM/src/communication.cpp +++ b/protocols/FacebookRM/src/communication.cpp @@ -675,15 +675,22 @@ void loginError(FacebookProto *proto, std::string error_str) { proto->facy.client_notify(buf);
}
-bool facebook_client::login(const std::string &username,const std::string &password)
+bool facebook_client::login(const char *username, const char *password)
{
handle_entry("login");
username_ = username;
password_ = password;
-
- // Get initial cookies
- flap(REQUEST_LOGIN);
+
+ if (cookies.empty()) {
+ // Set device ID
+ ptrA device( parent->getStringA(FACEBOOK_KEY_DEVICE_ID));
+ if (device != NULL)
+ cookies["datr"] = device;
+
+ // Get initial cookies
+ flap(REQUEST_HOME);
+ }
// Prepare login data
std::string data = "charset_test=%e2%82%ac%2c%c2%b4%2c%e2%82%ac%2c%c2%b4%2c%e6%b0%b4%2c%d0%94%2c%d0%84&pass_placeHolder=Password&login=Login&persistent=1";
@@ -718,7 +725,6 @@ bool facebook_client::login(const std::string &username,const std::string &passw client_notify(TranslateT("Your account requires HTTPS connection. Activating."));
parent->setByte(FACEBOOK_KEY_FORCE_HTTPS, 1);
this->https_ = true;
- return login(username, password);
}
// Check whether some Facebook things are required
diff --git a/protocols/FacebookRM/src/connection.cpp b/protocols/FacebookRM/src/connection.cpp index 38e00a4fc2..9c2f866f4c 100644 --- a/protocols/FacebookRM/src/connection.cpp +++ b/protocols/FacebookRM/src/connection.cpp @@ -139,44 +139,22 @@ bool FacebookProto::NegotiateConnection() {
LOG("***** Negotiating connection with Facebook");
- bool error;
- std::string user, pass;
DBVARIANT dbv = {0};
- error = true;
- if (!getString(FACEBOOK_KEY_LOGIN, &dbv))
- {
- user = dbv.pszVal;
- db_free(&dbv);
- error = user.empty();
- }
- if (error)
- {
+ ptrA username( getStringA(FACEBOOK_KEY_LOGIN));
+ if (!username || !strlen(username)) {
NotifyEvent(m_tszUserName,TranslateT("Please enter a username."),NULL,FACEBOOK_EVENT_CLIENT);
return false;
}
- error = true;
- if (!getString(FACEBOOK_KEY_PASS, &dbv))
- {
- CallService(MS_DB_CRYPT_DECODESTRING,strlen(dbv.pszVal)+1,
- reinterpret_cast<LPARAM>(dbv.pszVal));
- pass = dbv.pszVal;
- db_free(&dbv);
- error = pass.empty();
- }
- if (error)
- {
+ ptrA password( getStringA(FACEBOOK_KEY_PASS));
+ if (!password || !strlen(password)) {
NotifyEvent(m_tszUserName,TranslateT("Please enter a password."),NULL,FACEBOOK_EVENT_CLIENT);
return false;
}
- // Load machine name
- if (!getString(FACEBOOK_KEY_DEVICE_ID, &dbv))
- {
- facy.cookies["datr"] = dbv.pszVal;
- db_free(&dbv);
- }
+ CallService(MS_DB_CRYPT_DECODESTRING, strlen(password) + 1, password);
+ password = mir_utf8encode(password);
// Refresh last time of feeds update
facy.last_feeds_update_ = ::time(NULL);
@@ -189,7 +167,7 @@ bool FacebookProto::NegotiateConnection() if (groupName != NULL)
Clist_CreateGroup(0, groupName);
- return facy.login(user, pass);
+ return facy.login(username, password);
}
void FacebookProto::UpdateLoop(void *)
|