diff options
author | George Hazan <ghazan@miranda.im> | 2018-01-09 13:14:57 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-01-09 13:14:57 +0300 |
commit | 9d31ed4619e1614f98c39b9d224ff22b629ac123 (patch) | |
tree | f53fac1ad138d037f9065e41bf52bd9d72ef08e3 /protocols/FacebookRM/src | |
parent | 8587a88b4bd8c48fa524876d872773deb6fb2efc (diff) |
Facebook: code cleaning
Diffstat (limited to 'protocols/FacebookRM/src')
-rw-r--r-- | protocols/FacebookRM/src/contacts.cpp | 7 | ||||
-rw-r--r-- | protocols/FacebookRM/src/login.cpp | 2 | ||||
-rw-r--r-- | protocols/FacebookRM/src/notifications.cpp | 4 | ||||
-rw-r--r-- | protocols/FacebookRM/src/process.cpp | 22 |
4 files changed, 7 insertions, 28 deletions
diff --git a/protocols/FacebookRM/src/contacts.cpp b/protocols/FacebookRM/src/contacts.cpp index a224978f0e..be4c056871 100644 --- a/protocols/FacebookRM/src/contacts.cpp +++ b/protocols/FacebookRM/src/contacts.cpp @@ -290,9 +290,7 @@ void FacebookProto::DeleteContactFromServer(void *data) return; // Delete contact from server - HttpRequest *request = facy.deleteFriendRequest(id.c_str()); - http::response resp = facy.sendRequest(request); - + http::response resp = facy.sendRequest(facy.deleteFriendRequest(id.c_str())); if (resp.data.find("\"payload\":null", 0) != std::string::npos) { // If contact wasn't deleted from database MCONTACT hContact = ContactIDToHContact(id); @@ -324,8 +322,7 @@ void FacebookProto::AddContactToServer(void *data) return; // Request friendship - HttpRequest *request = facy.addFriendRequest(id.c_str()); - http::response resp = facy.sendRequest(request); + http::response resp = facy.sendRequest(facy.addFriendRequest(id.c_str())); if (resp.data.find("\"success\":true", 0) != std::string::npos) { MCONTACT hContact = ContactIDToHContact(id); diff --git a/protocols/FacebookRM/src/login.cpp b/protocols/FacebookRM/src/login.cpp index 5d88d81a56..694bd5dc24 100644 --- a/protocols/FacebookRM/src/login.cpp +++ b/protocols/FacebookRM/src/login.cpp @@ -108,6 +108,8 @@ HttpRequest* facebook_client::logoutRequest() { HttpRequest *p = new HttpRequest(REQUEST_POST, FACEBOOK_SERVER_REGULAR "/logout.php"); + p->flags |= NLHRF_REDIRECT; + p->Body << CHAR_PARAM("fb_dtsg", dtsg_.c_str()) << CHAR_PARAM("h", logout_hash_.c_str()); diff --git a/protocols/FacebookRM/src/notifications.cpp b/protocols/FacebookRM/src/notifications.cpp index 5904eece86..516b80be20 100644 --- a/protocols/FacebookRM/src/notifications.cpp +++ b/protocols/FacebookRM/src/notifications.cpp @@ -34,9 +34,7 @@ HttpRequest* facebook_client::getNotificationsRequest(int count) p->Body << CHAR_PARAM("__user", self_.user_id.c_str()) << CHAR_PARAM("fb_dtsg", dtsg_.c_str()) - // << "cursor=" // when loading more << INT_PARAM("length", count) // number of items to load - // << "businessID=" // probably for pages? << CHAR_PARAM("ttstamp", ttstamp_.c_str()) << CHAR_PARAM("__dyn", __dyn()) << CHAR_PARAM("__req", __req()) @@ -64,7 +62,7 @@ HttpRequest* facebook_client::markNotificationReadRequest(const char *id) << CHAR_PARAM("__dyn", __dyn()) << CHAR_PARAM("__req", __req()) << CHAR_PARAM("__rev", __rev()) - << CHAR_PARAM("alert_ids%5B0%5D", id); + << CHAR_PARAM("alert_ids[0]", id); return p; } diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp index cf11d945bf..39053d2d8a 100644 --- a/protocols/FacebookRM/src/process.cpp +++ b/protocols/FacebookRM/src/process.cpp @@ -25,18 +25,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. /** * Helper function for loading name from database (or use default one specified as parameter), used for title of few notifications. */ -std::string getContactName(FacebookProto *proto, MCONTACT hContact, const char *defaultName) -{ - std::string name = defaultName; - - DBVARIANT dbv; - if (!proto->getStringUtf(hContact, FACEBOOK_KEY_NICK, &dbv)) { - name = dbv.pszVal; - db_free(&dbv); - } - - return name; -} void FacebookProto::ProcessFriendList(void*) { @@ -116,10 +104,7 @@ void FacebookProto::ProcessFriendList(void*) // Notify it, if user wants to be notified if (getByte(FACEBOOK_KEY_EVENT_FRIENDSHIP_ENABLE, DEFAULT_EVENT_FRIENDSHIP_ENABLE)) { std::string url = FACEBOOK_URL_PROFILE + fbu->user_id; - std::string contactname = getContactName(this, hContact, !fbu->real_name.empty() ? fbu->real_name.c_str() : fbu->user_id.c_str()); - - ptrW szTitle(mir_utf8decodeW(contactname.c_str())); - NotifyEvent(szTitle, TranslateT("Contact is back on server-list."), hContact, EVENT_FRIENDSHIP, &url); + NotifyEvent(pcli->pfnGetContactDisplayName(hContact, 0), TranslateT("Contact is back on server-list."), hContact, EVENT_FRIENDSHIP, &url); } } @@ -143,10 +128,7 @@ void FacebookProto::ProcessFriendList(void*) // Notify it, if user wants to be notified if (getByte(FACEBOOK_KEY_EVENT_FRIENDSHIP_ENABLE, DEFAULT_EVENT_FRIENDSHIP_ENABLE)) { std::string url = FACEBOOK_URL_PROFILE + std::string(id); - std::string contactname = getContactName(this, hContact, id); - - ptrW szTitle(mir_utf8decodeW(contactname.c_str())); - NotifyEvent(szTitle, TranslateT("Contact is no longer on server-list."), hContact, EVENT_FRIENDSHIP, &url); + NotifyEvent(pcli->pfnGetContactDisplayName(hContact, 0), TranslateT("Contact is no longer on server-list."), hContact, EVENT_FRIENDSHIP, &url); } } } |