diff options
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/FacebookRM/src/avatars.cpp | 10 | ||||
-rw-r--r-- | protocols/FacebookRM/src/captcha.cpp | 6 | ||||
-rw-r--r-- | protocols/FacebookRM/src/chat.cpp | 4 | ||||
-rw-r--r-- | protocols/FacebookRM/src/communication.cpp | 122 | ||||
-rw-r--r-- | protocols/FacebookRM/src/connection.cpp | 30 | ||||
-rw-r--r-- | protocols/FacebookRM/src/contacts.cpp | 12 | ||||
-rw-r--r-- | protocols/FacebookRM/src/json.cpp | 5 | ||||
-rw-r--r-- | protocols/FacebookRM/src/messages.cpp | 2 | ||||
-rw-r--r-- | protocols/FacebookRM/src/process.cpp | 109 | ||||
-rw-r--r-- | protocols/FacebookRM/src/proto.cpp | 6 |
10 files changed, 138 insertions, 168 deletions
diff --git a/protocols/FacebookRM/src/avatars.cpp b/protocols/FacebookRM/src/avatars.cpp index a97a9f0a9e..91a1591a05 100644 --- a/protocols/FacebookRM/src/avatars.cpp +++ b/protocols/FacebookRM/src/avatars.cpp @@ -89,7 +89,7 @@ void FacebookProto::UpdateAvatarWorker(void *) {
HANDLE nlc = NULL;
- debugLogA("***** UpdateAvatarWorker");
+ debugLogA("*** UpdateAvatarWorker");
std::string params = getBool(FACEBOOK_KEY_BIG_AVATARS, DEFAULT_BIG_AVATARS) ? "?width=200&height=200" : "?width=80&height=80";
@@ -101,13 +101,13 @@ void FacebookProto::UpdateAvatarWorker(void *) if (Miranda_Terminated())
{
- debugLogA("***** Terminating avatar update early: %s", url.c_str());
+ debugLogA("*** Terminating avatar update early: %s", url.c_str());
break;
}
if (GetDbAvatarInfo(ai, &url))
{
- debugLogA("***** Updating avatar: %s", url.c_str());
+ debugLogA("*** Updating avatar: %s", url.c_str());
bool success = facy.save_url(url + params, ai.filename, nlc);
if (ai.hContact)
@@ -187,7 +187,7 @@ INT_PTR FacebookProto::GetAvatarInfo(WPARAM wParam, LPARAM lParam) if (needLoad)
{
- debugLogA("***** Starting avatar request thread for %s", _T2A(AI->filename));
+ debugLogA("*** Starting avatar request thread for %s", _T2A(AI->filename));
ScopedLock s(avatar_lock_);
if (std::find(avatar_queue.begin(), avatar_queue.end(), AI->hContact) == avatar_queue.end())
@@ -208,7 +208,7 @@ INT_PTR FacebookProto::GetAvatarInfo(WPARAM wParam, LPARAM lParam) INT_PTR FacebookProto::GetMyAvatar(WPARAM wParam, LPARAM lParam)
{
- debugLogA("***** GetMyAvatar");
+ debugLogA("*** GetMyAvatar");
if (!wParam || !lParam)
return -3;
diff --git a/protocols/FacebookRM/src/captcha.cpp b/protocols/FacebookRM/src/captcha.cpp index d5f33a4479..355cd7acd1 100644 --- a/protocols/FacebookRM/src/captcha.cpp +++ b/protocols/FacebookRM/src/captcha.cpp @@ -105,7 +105,7 @@ static INT_PTR CALLBACK CaptchaFormDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam bool FacebookProto::RunCaptchaForm(std::string captchaUrl, std::string &result) { - debugLogA("RunCaptchaForm: reading picture from %s", captchaUrl.c_str()); + debugLogA(" RunCaptchaForm: reading picture from %s", captchaUrl.c_str()); result.clear(); NETLIBHTTPREQUEST req = { sizeof(req) }; @@ -118,7 +118,7 @@ bool FacebookProto::RunCaptchaForm(std::string captchaUrl, std::string &result) return false; if (reply->resultCode != HTTP_CODE_OK) { - debugLogA("RunCaptchaForm: failed with code %d", reply->resultCode); + debugLogA(" RunCaptchaForm: failed with code %d", reply->resultCode); return false; } @@ -138,7 +138,7 @@ bool FacebookProto::RunCaptchaForm(std::string captchaUrl, std::string &result) if (res == 0) return false; - debugLogA("RunCaptchaForm: user entered text %s", param.Result); + debugLogA(" RunCaptchaForm: user entered text %s", param.Result); result = param.Result; return true; } diff --git a/protocols/FacebookRM/src/chat.cpp b/protocols/FacebookRM/src/chat.cpp index 477ea81355..e516b6aec7 100644 --- a/protocols/FacebookRM/src/chat.cpp +++ b/protocols/FacebookRM/src/chat.cpp @@ -86,7 +86,7 @@ int FacebookProto::OnGCEvent(WPARAM, LPARAM lParam) std::string chat_id = _T2A(hook->pDest->ptszID, CP_UTF8); if (isOnline()) { - debugLogA("**Chat - Outgoing message: %s", msg.c_str()); + debugLogA(" > Chat - Outgoing message"); ForkThread(&FacebookProto::SendChatMsgWorker, new send_chat(chat_id, msg)); } @@ -227,8 +227,6 @@ char *FacebookProto::GetChatUsers(const TCHAR *chat_id) gci.pszID = chat_id; CallService(MS_GC_GETINFO, 0, (LPARAM)&gci); - debugLogA("**Chat - Users in chat %s: %s", _T2A(chat_id), gci.pszUsers); - // mir_free(gci.pszUsers); return gci.pszUsers; } diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp index f366814d60..cfcbdfbff6 100644 --- a/protocols/FacebookRM/src/communication.cpp +++ b/protocols/FacebookRM/src/communication.cpp @@ -70,7 +70,7 @@ http::response facebook_client::flap(RequestType request_type, std::string* requ nlhr.dataLength = (int)request_data->length(); } - parent->debugLogA("@@@@@ Sending request to '%s'", nlhr.szUrl); + parent->debugLogA("@@@ Sending request to '%s'", nlhr.szUrl); switch (request_type) { @@ -113,7 +113,7 @@ http::response facebook_client::flap(RequestType request_type, std::string* requ if (pnlhr != NULL) { - parent->debugLogA("@@@@@ Got response with code %d", pnlhr->resultCode); + parent->debugLogA("@@@ Got response with code %d", pnlhr->resultCode); store_headers(&resp, pnlhr->headers, pnlhr->headersCount); resp.code = pnlhr->resultCode; resp.data = pnlhr->pData ? pnlhr->pData : ""; @@ -121,7 +121,7 @@ http::response facebook_client::flap(RequestType request_type, std::string* requ CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)pnlhr); } else { - parent->debugLogA("!!!!! No response from server (time-out)"); + parent->debugLogA("!!! No response from server (time-out)"); resp.code = HTTP_CODE_FAKE_DISCONNECTED; // Better to have something set explicitely as this value is compaired in all communication requests } @@ -159,7 +159,7 @@ http::response facebook_client::flap(RequestType request_type, std::string* requ resp.error_title = title; resp.code = HTTP_CODE_FAKE_ERROR; - parent->debugLogA(" ! ! Received Facebook error: %d -- %s", error_num, error.c_str()); + parent->debugLogA("!!! Received Facebook error: %d -- %s", error_num, error.c_str()); if (notify_errors(request_type) && !silent) client_notify(_A2T(error.c_str())); } @@ -171,13 +171,13 @@ http::response facebook_client::flap(RequestType request_type, std::string* requ bool facebook_client::handle_entry(const std::string &method) { - parent->debugLogA(" >> Entering %s()", method.c_str()); + parent->debugLogA(" >> Entering %s()", method.c_str()); return true; } bool facebook_client::handle_success(const std::string &method) { - parent->debugLogA(" << Quitting %s()", method.c_str()); + parent->debugLogA(" << Quitting %s()", method.c_str()); reset_error(); return true; } @@ -185,7 +185,7 @@ bool facebook_client::handle_success(const std::string &method) bool facebook_client::handle_error(const std::string &method, int action) { increment_error(); - parent->debugLogA("!!!!! %s(): Something with Facebook went wrong", method.c_str()); + parent->debugLogA("!!! %s(): Something with Facebook went wrong", method.c_str()); bool result = (error_count_ <= (UINT)parent->getByte(FACEBOOK_KEY_TIMEOUTS_LIMIT, FACEBOOK_TIMEOUTS_LIMIT)); if (action == FORCE_DISCONNECT || action == FORCE_QUIT) @@ -697,28 +697,19 @@ void facebook_client::store_headers(http::response* resp, NETLIBHTTPHEADER* head { ScopedLock c(cookies_lock_); - for (int i = 0; i < headersCount; i++) - { - std::string header_name = headers[i].szName; // TODO: Casting? - std::string header_value = headers[i].szValue; // TODO: Casting? + for (int i = 0; i < headersCount; i++) { + std::string header_name = headers[i].szName; + std::string header_value = headers[i].szValue; - if (header_name == "Set-Cookie") - { + if (header_name == "Set-Cookie") { std::string cookie_name = header_value.substr(0, header_value.find("=")); std::string cookie_value = header_value.substr(header_value.find("=") + 1, header_value.find(";") - header_value.find("=") - 1); + if (cookie_value == "deleted") - { - parent->debugLogA(" Deleted cookie '%s'", cookie_name.c_str()); cookies.erase(cookie_name); - } - else { - parent->debugLogA(" New cookie '%s'", cookie_name.c_str()); + else cookies[cookie_name] = cookie_value; - } - } - else - { // TODO RM: (un)comment - //parent->debugLogA("----- Got header '%s': %s", header_name.c_str(), header_value.c_str()); + } else { resp->headers[header_name] = header_value; } } @@ -794,7 +785,7 @@ void loginError(FacebookProto *proto, std::string error_str) { utils::text::remove_html( utils::text::edit_html(error_str)))); - proto->debugLogA(" ! ! Login error: %s", !error_str.empty() ? error_str.c_str() : "Unknown error"); + proto->debugLogA("!!! Login error: %s", !error_str.empty() ? error_str.c_str() : "Unknown error"); TCHAR buf[200]; mir_sntprintf(buf, SIZEOF(buf), TranslateT("Login error: %s"), @@ -838,7 +829,7 @@ bool facebook_client::login(const char *username, const char *password) // Check for invalid requests if (location.find("invalid_request.php") != std::string::npos) { client_notify(TranslateT("Login error: Invalid request.")); - parent->debugLogA(" ! ! Login error: Invalid request."); + parent->debugLogA("!!! Login error: Invalid request."); return handle_error("login", FORCE_QUIT); } @@ -846,7 +837,7 @@ bool facebook_client::login(const char *username, const char *password) if (location.find("help.php") != std::string::npos) { client_notify(TranslateT("Login error: Some Facebook things are required.")); - parent->debugLogA(" ! ! Login error: Some Facebook things are required."); + parent->debugLogA("!!! Login error: Some Facebook things are required."); // return handle_error("login", FORCE_QUIT); } @@ -876,7 +867,7 @@ bool facebook_client::login(const char *username, const char *password) if (resp.data.find("name=\"birthday_captcha_") != std::string::npos) { // Account is locked and needs identity confirmation client_notify(TranslateT("Login error: Your account is temporarily locked. You need to confirm this device from web browser.")); - parent->debugLogA(" ! ! Login error: Birthday confirmation."); + parent->debugLogA("!!! Login error: Birthday confirmation."); return handle_error("login", FORCE_QUIT); } @@ -941,7 +932,7 @@ bool facebook_client::login(const char *username, const char *password) // Check whether captcha code is required if (resp.data.find("id=\"captcha\"") != std::string::npos) { client_notify(TranslateT("Login error: Captcha code is required. You need to confirm this device from web browser.")); - parent->debugLogA(" ! ! Login error: Captcha code is required."); + parent->debugLogA("!!! Login error: Captcha code is required."); return handle_error("login", FORCE_QUIT); } @@ -970,7 +961,7 @@ bool facebook_client::login(const char *username, const char *password) if (redirectUrl != expectedUrl) { // Unexpected redirect, but we try to ignore it - maybe we were logged in anyway - parent->debugLogA(" ! ! Login error: Unexpected redirect: %s (Original: %s) (Expected: %s)", redirectUrl.c_str(), resp.headers["Location"].c_str(), expectedUrl.c_str()); + parent->debugLogA("!!! Login error: Unexpected redirect: %s (Original: %s) (Expected: %s)", redirectUrl.c_str(), resp.headers["Location"].c_str(), expectedUrl.c_str()); } } @@ -978,12 +969,12 @@ bool facebook_client::login(const char *username, const char *password) // Probably logged in, everything seems OK this->self_.user_id = cookies.find("c_user")->second; parent->setString(FACEBOOK_KEY_ID, this->self_.user_id.c_str()); - parent->debugLogA(" Got self user id: %s", this->self_.user_id.c_str()); + parent->debugLogA(" Got self user id: %s", this->self_.user_id.c_str()); return handle_success("login"); } else { client_notify(TranslateT("Login error, probably bad login credentials.")); - parent->debugLogA(" ! ! Login error, probably bad login credentials."); + parent->debugLogA("!!! Login error, probably bad login credentials."); return handle_error("login", FORCE_QUIT); } } @@ -1037,13 +1028,14 @@ bool facebook_client::home() csrf << (int)this->dtsg_.at(i); } this->csrf_ = csrf.str(); - } - parent->debugLogA(" Got self dtsg: %s (csrf: %s)", this->dtsg_.c_str(), this->csrf_.c_str()); + } if (this->dtsg_.empty()) { - parent->debugLogA("!!!!! Empty dtsg. Source code:\n%s", resp.data.c_str()); + parent->debugLogA("!!! Empty dtsg. Source code:\n%s", resp.data.c_str()); client_notify(TranslateT("Could not load communication token. You should report this and wait for plugin update.")); return handle_error("home", FORCE_QUIT); + } else { + parent->debugLogA(" Got self dtsg"); } resp = flap(REQUEST_HOME); @@ -1067,13 +1059,13 @@ bool facebook_client::home() std::string::size_type pos = this->self_.real_name.find("<span class=\"alternate_name\">"); if (pos != std::string::npos) { this->self_.nick = utils::text::source_get_value(&this->self_.real_name, 2, "<span class=\"alternate_name\">(", ")</span>"); - parent->debugLogA(" Got self nick name: %s", this->self_.nick.c_str()); + parent->debugLogA(" Got self nick name: %s", this->self_.nick.c_str()); this->self_.real_name = this->self_.real_name.substr(0, pos - 1); } this->self_.real_name = utils::text::remove_html(this->self_.real_name); - parent->debugLogA(" Got self real name: %s", this->self_.real_name.c_str()); + parent->debugLogA(" Got self real name: %s", this->self_.real_name.c_str()); parent->SaveName(NULL, &this->self_); // Get avatar @@ -1089,15 +1081,15 @@ bool facebook_client::home() this->self_.image_url = "/" + this->self_.image_url; } - parent->debugLogA(" Got self avatar: %s", this->self_.image_url.c_str()); + parent->debugLogA(" Got self avatar: %s", this->self_.image_url.c_str()); parent->CheckAvatarChange(NULL, this->self_.image_url); // Get logout hash this->logout_hash_ = utils::text::source_get_value2(&resp.data, "/logout.php?h=", "&\""); - parent->debugLogA(" Got self logout hash: %s", this->logout_hash_.c_str()); + parent->debugLogA(" Got self logout hash: %s", this->logout_hash_.c_str()); if (this->self_.real_name.empty() || this->self_.image_url.empty() || this->logout_hash_.empty()) { - parent->debugLogA("!!!!! Empty nick/avatar/hash. Source code:\n%s", resp.data.c_str()); + parent->debugLogA("!!! Empty nick/avatar/hash. Source code:\n%s", resp.data.c_str()); client_notify(TranslateT("Could not load all required data. Plugin may still work correctly, but you should report this and wait for plugin update.")); } @@ -1105,7 +1097,7 @@ bool facebook_client::home() } case HTTP_CODE_FOUND: // Work-around for replica_down, f**king hell what's that? - parent->debugLogA(" REPLICA_DOWN is back in force!"); + parent->debugLogA("!!! REPLICA_DOWN is back in force!"); return this->home(); default: @@ -1141,28 +1133,28 @@ bool facebook_client::reconnect() case HTTP_CODE_OK: { this->chat_channel_ = utils::text::source_get_value(&resp.data, 2, "\"user_channel\":\"", "\""); - parent->debugLogA(" Got self channel: %s", this->chat_channel_.c_str()); + parent->debugLogA(" Got self channel: %s", this->chat_channel_.c_str()); this->chat_channel_partition_ = utils::text::source_get_value2(&resp.data, "\"partition\":", ",}"); - parent->debugLogA(" Got self channel partition: %s", this->chat_channel_partition_.c_str()); + parent->debugLogA(" Got self channel partition: %s", this->chat_channel_partition_.c_str()); this->chat_channel_host_ = utils::text::source_get_value(&resp.data, 2, "\"host\":\"", "\""); - parent->debugLogA(" Got self channel host: %s", this->chat_channel_host_.c_str()); + parent->debugLogA(" Got self channel host: %s", this->chat_channel_host_.c_str()); this->chat_sequence_num_ = utils::text::source_get_value2(&resp.data, "\"seq\":", ",}"); - parent->debugLogA(" Got self sequence number: %s", this->chat_sequence_num_.c_str()); + parent->debugLogA(" Got self sequence number: %s", this->chat_sequence_num_.c_str()); this->chat_conn_num_ = utils::text::source_get_value2(&resp.data, "\"max_conn\":", ",}"); - parent->debugLogA(" Got self max_conn: %s", this->chat_conn_num_.c_str()); + parent->debugLogA(" Got self max_conn: %s", this->chat_conn_num_.c_str()); this->chat_sticky_num_ = utils::text::source_get_value(&resp.data, 2, "\"sticky_token\":\"", "\""); - parent->debugLogA(" Got self sticky_token: %s", this->chat_sticky_num_.c_str()); + parent->debugLogA(" Got self sticky_token: %s", this->chat_sticky_num_.c_str()); //std::string retry_interval = utils::text::source_get_value2(&resp.data, "\"retry_interval\":", ",}"); - //parent->debugLogA(" Got self retry_interval: %s", retry_interval.c_str()); + //parent->debugLogA(" Got self retry_interval: %s", retry_interval.c_str()); //std::string visibility = utils::text::source_get_value2(&resp.data, "\"visibility\":", ",}"); - //parent->debugLogA(" Got self visibility: %s", visibility.c_str()); + //parent->debugLogA(" Got self visibility: %s", visibility.c_str()); // Send activity_ping after each reconnect activity_ping(); @@ -1200,21 +1192,21 @@ bool facebook_client::channel() else if (type == "lb") { // Some new stuff (idk how does it work yet) this->chat_sticky_pool_ = utils::text::source_get_value(&resp.data, 2, "\"pool\":\"", "\""); - parent->debugLogA(" Got self sticky pool: %s", this->chat_sticky_pool_.c_str()); + parent->debugLogA(" Got self sticky pool: %s", this->chat_sticky_pool_.c_str()); this->chat_sticky_num_ = utils::text::source_get_value2(&resp.data, "\"sticky\":\"", "\""); - parent->debugLogA(" Got self sticky number: %s", this->chat_sticky_num_.c_str()); + parent->debugLogA(" Got self sticky number: %s", this->chat_sticky_num_.c_str()); } else if (type == "fullReload" || type == "refresh") { // Requested reload of page or relogin (due to some settings change, removing this session, etc.) - parent->debugLogA("! ! ! Requested %s", type.c_str()); + parent->debugLogA("!!! Requested %s", type.c_str()); this->chat_sequence_num_ = utils::text::source_get_value2(&resp.data, "\"seq\":", ",}"); - parent->debugLogA(" Got self sequence number: %s", this->chat_sequence_num_.c_str()); + parent->debugLogA(" Got self sequence number: %s", this->chat_sequence_num_.c_str()); if (type == "refresh") { this->chat_reconnect_reason_ = utils::text::source_get_value2(&resp.data, "\"reason\":", ",}"); - parent->debugLogA(" Reconnect reason: %s", this->chat_reconnect_reason_.c_str()); + parent->debugLogA(" Got reconnect reason: %s", this->chat_reconnect_reason_.c_str()); return this->reconnect(); } @@ -1226,7 +1218,7 @@ bool facebook_client::channel() // Get new sequence number std::string seq = utils::text::source_get_value2(&resp.data, "\"seq\":", ",}"); - parent->debugLogA(" Got self sequence number: %s", seq.c_str()); + parent->debugLogA(" Got self sequence number: %s", seq.c_str()); // Check if it's different from our old one (which means we should increment our old one) if (seq != this->chat_sequence_num_) { @@ -1240,7 +1232,7 @@ bool facebook_client::channel() // Check if we have different seq than the one from Facebook if (newSeq != seq) { - parent->debugLogA("! ! ! Use self incremented sequence number: %s (instead of: %s)", newSeq.c_str(), seq.c_str()); + parent->debugLogA("!!! Use self incremented sequence number: %s (instead of: %s)", newSeq.c_str(), seq.c_str()); seq = newSeq; } } @@ -1306,7 +1298,7 @@ int facebook_client::send_message(int seqid, MCONTACT hContact, const std::strin switch (method) { case MESSAGE_INBOX: { - parent->debugLogA(" > Sending message through INBOX"); + parent->debugLogA(" > Sending message through INBOX"); data += "&action=send"; data += "&body=" + utils::url::encode(message_text); data += "&recipients[0]=" + message_recipient; @@ -1320,7 +1312,7 @@ int facebook_client::send_message(int seqid, MCONTACT hContact, const std::strin } case MESSAGE_MERCURY: { - parent->debugLogA(" > Sending message through CHAT"); + parent->debugLogA(" > Sending message through CHAT"); data += "&message_batch[0][action_type]=ma-type:user-generated-message"; data += "&message_batch[0][thread_id]"; data += "&message_batch[0][author]=fbid:" + this->self_.user_id; @@ -1354,7 +1346,7 @@ int facebook_client::send_message(int seqid, MCONTACT hContact, const std::strin } case MESSAGE_TID: { - parent->debugLogA(" > Sending message through MERCURY (TID)"); + parent->debugLogA(" > Sending message through MERCURY (TID)"); data += "&message_batch[0][action_type]=ma-type:user-generated-message"; data += "&message_batch[0][thread_id]=" + message_recipient; data += "&message_batch[0][author]=fbid:" + this->self_.user_id; @@ -1378,7 +1370,7 @@ int facebook_client::send_message(int seqid, MCONTACT hContact, const std::strin } case MESSAGE_ASYNC: { - parent->debugLogA(" > Sending message through ASYNC"); + parent->debugLogA(" > Sending message through ASYNC"); data += "&action=send"; data += "&body=" + utils::url::encode(message_text); data += "&recipients[0]=" + message_recipient; @@ -1439,8 +1431,8 @@ int facebook_client::send_message(int seqid, MCONTACT hContact, const std::strin std::string imageUrl = utils::text::html_entities_decode(utils::text::slashu_to_utf8(utils::text::source_get_value(&resp.data, 3, "img class=\\\"img\\\"", "src=\\\"", "\\\""))); std::string captchaPersistData = utils::text::source_get_value(&resp.data, 3, "\\\"captcha_persist_data\\\"", "value=\\\"", "\\\""); - parent->debugLogA("Got imageUrl (first): %s", imageUrl.c_str()); - parent->debugLogA("Got captchaPersistData (first): %s", captchaPersistData.c_str()); + parent->debugLogA(" Got imageUrl (first): %s", imageUrl.c_str()); + parent->debugLogA(" Got captchaPersistData (first): %s", captchaPersistData.c_str()); std::string data = "new_captcha_type=TFBCaptcha&skipped_captcha_data=" + captchaPersistData; data += "&__dyn=&__req=&__rev=&__user=" + this->self_.user_id; @@ -1450,8 +1442,8 @@ int facebook_client::send_message(int seqid, MCONTACT hContact, const std::strin imageUrl = utils::text::html_entities_decode(utils::text::slashu_to_utf8(utils::text::source_get_value(&resp.data, 3, "img class=\\\"img\\\"", "src=\\\"", "\\\""))); captchaPersistData = utils::text::source_get_value(&resp.data, 3, "\\\"captcha_persist_data\\\"", "value=\\\"", "\\\""); - parent->debugLogA("Got imageUrl (second): %s", imageUrl.c_str()); - parent->debugLogA("Got captchaPersistData (second): %s", captchaPersistData.c_str()); + parent->debugLogA(" Got imageUrl (second): %s", imageUrl.c_str()); + parent->debugLogA(" Got captchaPersistData (second): %s", captchaPersistData.c_str()); std::string result; if (!parent->RunCaptchaForm(imageUrl, result)) { @@ -1466,7 +1458,7 @@ int facebook_client::send_message(int seqid, MCONTACT hContact, const std::strin } default: // Other error - parent->debugLogA(" !!! Send message error #%d: %s", resp.error_number, resp.error_text.c_str()); + parent->debugLogA("!!! Send message error #%d: %s", resp.error_number, resp.error_text.c_str()); return SEND_MESSAGE_ERROR; } @@ -1577,7 +1569,7 @@ bool facebook_client::save_url(const std::string &url, const std::tstring &filen if (resp) { nlc = resp->nlc; - parent->debugLogA("@@@@@ Saving URL %s to file %s", url.c_str(), _T2A(filename.c_str())); + parent->debugLogA("@@@ Saving URL %s to file %s", url.c_str(), _T2A(filename.c_str())); // Create folder if necessary std::tstring dir = filename.substr(0, filename.rfind('\\')); diff --git a/protocols/FacebookRM/src/connection.cpp b/protocols/FacebookRM/src/connection.cpp index 4548d2965e..42f1526e38 100644 --- a/protocols/FacebookRM/src/connection.cpp +++ b/protocols/FacebookRM/src/connection.cpp @@ -32,7 +32,7 @@ void FacebookProto::ChangeStatus(void*) if (new_status == ID_STATUS_OFFLINE) { // Logout - debugLogA("##### Beginning SignOff process"); + debugLogA("### Beginning SignOff process"); m_signingOut = true; SetEvent(update_loop_lock_); @@ -80,7 +80,7 @@ void FacebookProto::ChangeStatus(void*) ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, m_iStatus); m_signingOut = false; - debugLogA("##### SignOff complete"); + debugLogA("### SignOff complete"); return; } @@ -90,7 +90,7 @@ void FacebookProto::ChangeStatus(void*) GetLocalTime(&t); debugLogA("[%d.%d.%d] Using Facebook Protocol RM %s", t.wDay, t.wMonth, t.wYear, __VERSION_STRING_DOTS); - debugLogA("***** Beginning SignOn process"); + debugLogA("*** Beginning SignOn process"); m_enableChat = getBool(FACEBOOK_KEY_ENABLE_CHATS, DEFAULT_ENABLE_CHATS); @@ -139,13 +139,13 @@ void FacebookProto::ChangeStatus(void*) m_iStatus = m_iDesiredStatus = facy.self_.status_id = ID_STATUS_OFFLINE; ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, m_iStatus); - debugLogA("***** SignOn failed"); + debugLogA("*** SignOn failed"); return; } ToggleStatusMenuItems(true); - debugLogA("***** SignOn complete"); + debugLogA("*** SignOn complete"); } m_invisible = (new_status == ID_STATUS_INVISIBLE); @@ -157,13 +157,13 @@ void FacebookProto::ChangeStatus(void*) m_iStatus = facy.self_.status_id = new_status; ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, m_iStatus); - debugLogA("***** ChangeStatus complete"); + debugLogA("*** ChangeStatus complete"); } /** Return true on success, false on error. */ bool FacebookProto::NegotiateConnection() { - debugLogA("***** Negotiating connection with Facebook"); + debugLogA("*** Negotiating connection with Facebook"); ptrA username(getStringA(FACEBOOK_KEY_LOGIN)); if (!username || !strlen(username)) { @@ -198,7 +198,7 @@ bool FacebookProto::NegotiateConnection() void FacebookProto::UpdateLoop(void *) { time_t tim = ::time(NULL); - debugLogA(">>>>> Entering Facebook::UpdateLoop[%d]", tim); + debugLogA(">>> Entering Facebook::UpdateLoop[%d]", tim); for (int i = -1; !isOffline(); i = (i + 1) % 50) { @@ -209,20 +209,20 @@ void FacebookProto::UpdateLoop(void *) ProcessFeeds(NULL); } - debugLogA("***** FacebookProto::UpdateLoop[%d] going to sleep...", tim); + debugLogA("*** FacebookProto::UpdateLoop[%d] going to sleep...", tim); if (WaitForSingleObjectEx(update_loop_lock_, GetPollRate() * 1000, true) != WAIT_TIMEOUT) break; - debugLogA("***** FacebookProto::UpdateLoop[%d] waking up...", tim); + debugLogA("*** FacebookProto::UpdateLoop[%d] waking up...", tim); } ResetEvent(update_loop_lock_); - debugLogA("<<<<< Exiting FacebookProto::UpdateLoop[%d]", tim); + debugLogA("<<< Exiting FacebookProto::UpdateLoop[%d]", tim); } void FacebookProto::MessageLoop(void *) { time_t tim = ::time(NULL); - debugLogA(">>>>> Entering Facebook::MessageLoop[%d]", tim); + debugLogA(">>> Entering Facebook::MessageLoop[%d]", tim); while (facy.channel()) { @@ -231,14 +231,14 @@ void FacebookProto::MessageLoop(void *) // If we're not idle, send activity_ping every few minutes... if (!m_idleTS && (::time(NULL) - m_pingTS) > FACEBOOK_PING_TIME) { - debugLogA("***** FacebookProto::MessageLoop[%d] pinging...", tim); + debugLogA("*** FacebookProto::MessageLoop[%d] pinging...", tim); facy.activity_ping(); } - debugLogA("***** FacebookProto::MessageLoop[%d] refreshing...", tim); + debugLogA("*** FacebookProto::MessageLoop[%d] refreshing...", tim); } - debugLogA("<<<<< Exiting FacebookProto::MessageLoop[%d]", tim); + debugLogA("<<< Exiting FacebookProto::MessageLoop[%d]", tim); } BYTE FacebookProto::GetPollRate() diff --git a/protocols/FacebookRM/src/contacts.cpp b/protocols/FacebookRM/src/contacts.cpp index 7a8e0849a7..fdc8f5e2a0 100644 --- a/protocols/FacebookRM/src/contacts.cpp +++ b/protocols/FacebookRM/src/contacts.cpp @@ -192,11 +192,11 @@ std::string FacebookProto::ThreadIDToContactID(const std::string &thread_id) if (!user_id.empty()) facy.thread_id_to_user_id.insert(std::make_pair(thread_id, user_id)); - debugLogA("***** Thread info processed"); + debugLogA("*** Thread info processed"); CODE_BLOCK_CATCH - debugLogA("***** Error processing thread info: %s", e.what()); + debugLogA("*** Error processing thread info: %s", e.what()); CODE_BLOCK_END } @@ -221,11 +221,11 @@ void FacebookProto::LoadContactInfo(facebook_user* fbu) p->parse_user_info(&resp.data, fbu); delete p; - debugLogA("***** Contact thread info processed"); + debugLogA("*** Contact thread info processed"); CODE_BLOCK_CATCH - debugLogA("***** Error processing contact thread info: %s", e.what()); + debugLogA("*** Error processing contact thread info: %s", e.what()); CODE_BLOCK_END } @@ -325,11 +325,11 @@ void FacebookProto::LoadChatInfo(facebook_chatroom *fbc) //ReceiveMessages(messages, true); // don't let it fall into infinite cycle, solve it somehow... - debugLogA("***** Chat thread info processed"); + debugLogA("*** Chat thread info processed"); CODE_BLOCK_CATCH - debugLogA("***** Error processing chat thread info: %s", e.what()); + debugLogA("*** Error processing chat thread info: %s", e.what()); CODE_BLOCK_END diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp index cf715a9aba..5597baebff 100644 --- a/protocols/FacebookRM/src/json.cpp +++ b/protocols/FacebookRM/src/json.cpp @@ -283,8 +283,7 @@ bool ignore_duplicits(FacebookProto *proto, const std::string &mid, const std::s std::map<std::string, int>::iterator it = proto->facy.messages_ignore.find(mid); if (it != proto->facy.messages_ignore.end()) { - proto->debugLogA("????? Ignoring duplicit/sent message\n%s", text.c_str()); - + proto->debugLogA("??? Ignoring duplicit/sent message ID: %s", mid.c_str()); it->second++; // increase counter (for deleting it later) return true; } @@ -727,7 +726,7 @@ int facebook_json_parser::parse_messages(std::string *data, std::vector< faceboo JSONNODE *visibility = json_get(event_data, "visibility"); bool isVisible = (visibility != NULL) && json_as_bool(visibility); - proto->debugLogA(" Requested chat switch to %s", isVisible ? "Online" : "Offline"); + proto->debugLogA(" Requested chat switch to %s", isVisible ? "Online" : "Offline"); proto->SetStatus(isVisible ? ID_STATUS_ONLINE : ID_STATUS_INVISIBLE); } } diff --git a/protocols/FacebookRM/src/messages.cpp b/protocols/FacebookRM/src/messages.cpp index f21ccda608..ec37efcb68 100644 --- a/protocols/FacebookRM/src/messages.cpp +++ b/protocols/FacebookRM/src/messages.cpp @@ -97,7 +97,7 @@ void FacebookProto::SendChatMsgWorker(void *p) tid = utils::text::source_get_value(&resp.data, 2, "\"thread_id\":\"", "\""); setString(hContact, FACEBOOK_KEY_TID, tid.c_str()); - debugLogA(" Got thread info: %s = %s", data->chat_id.c_str(), tid.c_str()); + debugLogA(" Got thread info: %s = %s", data->chat_id.c_str(), tid.c_str()); } if (!tid.empty()) { diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp index cb2e5ab9de..9799856a77 100644 --- a/protocols/FacebookRM/src/process.cpp +++ b/protocols/FacebookRM/src/process.cpp @@ -67,7 +67,7 @@ void FacebookProto::ProcessBuddyList(void*) return; } - debugLogA("***** Starting processing buddy list"); + debugLogA("*** Starting processing buddy list"); CODE_BLOCK_TRY @@ -79,23 +79,7 @@ void FacebookProto::ProcessBuddyList(void*) { facebook_user* fbu = i->data; - std::string status; - switch (fbu->status_id) { - case ID_STATUS_OFFLINE: - status = "Offline"; break; - case ID_STATUS_ONLINE: - status = "Online"; break; - case ID_STATUS_ONTHEPHONE: - status = "Mobile"; break; - } - - if (fbu->idle) - status += " (idle)"; - - debugLogA(" Now %s: %s", status.c_str(), fbu->user_id.c_str()); - - if (!fbu->deleted) - { + if (!fbu->deleted) { if (!fbu->handle) // just been added fbu->handle = AddToContactList(fbu, CONTACT_FRIEND); @@ -111,16 +95,14 @@ void FacebookProto::ProcessBuddyList(void*) } } - if (fbu->status_id == ID_STATUS_OFFLINE || fbu->deleted) - { + if (fbu->status_id == ID_STATUS_OFFLINE || fbu->deleted) { if (fbu->handle) setWord(fbu->handle, "Status", ID_STATUS_OFFLINE); std::string to_delete(i->key); i = i->next; facy.buddies.erase(to_delete); - } - else { + } else { i = i->next; if (!fbu->handle) // just been added @@ -157,11 +139,11 @@ void FacebookProto::ProcessBuddyList(void*) } } - debugLogA("***** Buddy list processed"); + debugLogA("*** Buddy list processed"); CODE_BLOCK_CATCH - debugLogA("***** Error processing buddy list: %s", e.what()); + debugLogA("*** Error processing buddy list: %s", e.what()); CODE_BLOCK_END } @@ -183,7 +165,7 @@ void FacebookProto::ProcessFriendList(void*) return; } - debugLogA("***** Starting processing friend list"); + debugLogA("*** Starting processing friend list"); CODE_BLOCK_TRY @@ -293,11 +275,11 @@ void FacebookProto::ProcessFriendList(void*) } friends.clear(); - debugLogA("***** Friend list processed"); + debugLogA("*** Friend list processed"); CODE_BLOCK_CATCH - debugLogA("***** Error processing friend list: %s", e.what()); + debugLogA("*** Error processing friend list: %s", e.what()); CODE_BLOCK_END } @@ -337,11 +319,11 @@ void FacebookProto::ProcessUnreadMessages(void*) ForkThread(&FacebookProto::ProcessUnreadMessage, new std::vector<std::string>(threads)); - debugLogA("***** Unread threads list processed"); + debugLogA("*** Unread threads list processed"); CODE_BLOCK_CATCH - debugLogA("***** Error processing unread threads list: %s", e.what()); + debugLogA("*** Error processing unread threads list: %s", e.what()); CODE_BLOCK_END @@ -434,11 +416,11 @@ void FacebookProto::ProcessUnreadMessage(void *data) ReceiveMessages(messages, true); - debugLogA("***** Unread messages processed"); + debugLogA("*** Unread messages processed"); CODE_BLOCK_CATCH - debugLogA("***** Error processing unread messages: %s", e.what()); + debugLogA("*** Error processing unread messages: %s", e.what()); CODE_BLOCK_END @@ -487,7 +469,7 @@ void FacebookProto::LoadLastMessages(void *p) ptrA item_id(getStringA(hContact, isChat ? FACEBOOK_KEY_TID : FACEBOOK_KEY_ID)); if (item_id == NULL) { - debugLogA("!!!!! LoadLastMessages: Contact has no TID/ID"); + debugLogA("!!! LoadLastMessages(): Contact has no TID/ID"); return; } @@ -554,11 +536,11 @@ void FacebookProto::LoadLastMessages(void *p) ReceiveMessages(messages, true); - debugLogA("***** Thread messages processed"); + debugLogA("*** Thread messages processed"); CODE_BLOCK_CATCH - debugLogA("***** Error processing thread messages: %s", e.what()); + debugLogA("*** Error processing thread messages: %s", e.what()); CODE_BLOCK_END @@ -584,7 +566,7 @@ void FacebookProto::SyncThreads(void*) // If last event is older than 1 day, we force sync to be 1 day old time_t yesterday = ::time(NULL) - 24 * 60 * 60; if (timestamp < yesterday) { - debugLogA("Last action timestamp is too old: %d, use 24 hours old instead: %d", timestamp, yesterday); + debugLogA(" Last action timestamp is too old: %d, use 24 hours old instead: %d", timestamp, yesterday); timestamp = yesterday; // And load older unread messages that we might not get otherwise @@ -606,7 +588,7 @@ void FacebookProto::SyncThreads(void*) data += "&folders[1]=other"; data += "&__req=7&__a=1&__dyn=&__req=&__rev=&ttstamp=" + facy.ttstamp(); - debugLogA("Facebook's milli timestamp for sync: %s", time.c_str()); + debugLogA(" Facebook's milli timestamp for sync: %s", time.c_str()); http::response resp = facy.flap(REQUEST_THREAD_SYNC, &data); @@ -626,11 +608,11 @@ void FacebookProto::SyncThreads(void*) ReceiveMessages(messages, true); - debugLogA("***** Thread messages processed"); + debugLogA("*** Thread messages processed"); CODE_BLOCK_CATCH - debugLogA("***** Error processing thread messages: %s", e.what()); + debugLogA("*** Error processing thread messages: %s", e.what()); CODE_BLOCK_END @@ -690,7 +672,7 @@ void FacebookProto::ReceiveMessages(std::vector<facebook_message*> messages, boo } // Multi-user message - debugLogA(" Got chat message: %s", messages[i]->message_text.c_str()); + debugLogA(" < Got chat message ID: %s", messages[i]->message_id.c_str()); facebook_chatroom *fbc; std::tstring tthread_id = _A2T(messages[i]->thread_id.c_str()); @@ -732,7 +714,7 @@ void FacebookProto::ReceiveMessages(std::vector<facebook_message*> messages, boo if (!hChatContact) { // hopefully shouldn't happen, but who knows? - debugLog(_T("! ! ! No hChatContact for %s"), fbc->thread_id.c_str()); + debugLog(_T("!!! No hChatContact for %s"), fbc->thread_id.c_str()); delete messages[i]; continue; } @@ -761,7 +743,7 @@ void FacebookProto::ReceiveMessages(std::vector<facebook_message*> messages, boo } else { // Single-user message - debugLogA(" Got message: %s", messages[i]->message_text.c_str()); + debugLogA(" < Got message ID: %s", messages[i]->message_id.c_str()); facebook_user fbu; fbu.user_id = messages[i]->user_id; @@ -783,7 +765,7 @@ void FacebookProto::ReceiveMessages(std::vector<facebook_message*> messages, boo if (!hContact) { // hopefully shouldn't happen, but who knows? - debugLogA("! ! ! No hContact for %s", messages[i]->user_id.c_str()); + debugLogA("!!! No hContact for %s", messages[i]->user_id.c_str()); delete messages[i]; continue; } @@ -854,7 +836,7 @@ void FacebookProto::ProcessMessages(void* data) // receive messages from all folders by default, use hidden setting to receive only inbox messages bool inboxOnly = getBool(FACEBOOK_KEY_INBOX_ONLY, 0); - debugLogA("***** Starting processing messages"); + debugLogA("*** Starting processing messages"); CODE_BLOCK_TRY @@ -868,11 +850,11 @@ void FacebookProto::ProcessMessages(void* data) ShowNotifications(); - debugLogA("***** Messages processed"); + debugLogA("*** Messages processed"); CODE_BLOCK_CATCH - debugLogA("***** Error processing messages: %s", e.what()); + debugLogA("*** Error processing messages: %s", e.what()); CODE_BLOCK_END @@ -889,7 +871,7 @@ void FacebookProto::ShowNotifications() { for (std::map<std::string, facebook_notification*>::iterator it = facy.notifications.begin(); it != facy.notifications.end(); ++it) { facebook_notification *notification = it->second; if (notification != NULL && !notification->seen) { - debugLogA(" Showing popup for notification: %s", notification->text.c_str()); + debugLogA(" Showing popup for notification ID: %s", notification->id.c_str()); ptrT szText(mir_utf8decodeT(notification->text.c_str())); MCONTACT hContact = (notification->user_id.empty() ? NULL : ContactIDToHContact(notification->user_id)); notification->hWndPopup = NotifyEvent(m_tszUserName, szText, hContact, FACEBOOK_EVENT_NOTIFICATION, ¬ification->link, ¬ification->id); @@ -915,7 +897,7 @@ void FacebookProto::ProcessNotifications(void*) // Process notifications - debugLogA("***** Starting processing notifications"); + debugLogA("*** Starting processing notifications"); CODE_BLOCK_TRY @@ -925,11 +907,11 @@ void FacebookProto::ProcessNotifications(void*) ShowNotifications(); - debugLogA("***** Notifications processed"); + debugLogA("*** Notifications processed"); CODE_BLOCK_CATCH - debugLogA("***** Error processing notifications: %s", e.what()); + debugLogA("*** Error processing notifications: %s", e.what()); CODE_BLOCK_END } @@ -1006,10 +988,9 @@ void FacebookProto::ProcessFriendRequests(void*) db_event_add(0, &dbei); } - debugLogA(" (%s) Friendship request from: %s (%s) [%s]", (isNew ? "New" : "Old"), fbu.real_name.c_str(), fbu.user_id.c_str(), time.c_str()); + debugLogA(" < (%s) Friendship request [%s]", (isNew ? "New" : "Old"), time.c_str()); } else { - debugLogA(" !!! Wrong friendship request"); - debugLogA("%s", req.c_str()); + debugLogA("!!! Wrong friendship request:\n%s", req.c_str()); } } @@ -1033,7 +1014,7 @@ void FacebookProto::ProcessFeeds(void*) CODE_BLOCK_TRY - debugLogA("***** Starting processing feeds"); + debugLogA("*** Starting processing feeds"); std::vector< facebook_newsfeed* > news; @@ -1043,7 +1024,7 @@ void FacebookProto::ProcessFeeds(void*) DWORD new_time = facy.last_feeds_update_; bool filterAds = getBool(FACEBOOK_KEY_FILTER_ADS, DEFAULT_FILTER_ADS); - debugLogA(" Last feeds update (old): %d", facy.last_feeds_update_); + debugLogA(" Last feeds update (old): %d", facy.last_feeds_update_); while ((pos = resp.data.find("<div class=\"userContentWrapper", pos)) != std::string::npos && limit <= 25) { @@ -1072,20 +1053,20 @@ void FacebookProto::ProcessFeeds(void*) DWORD ttime; if (!utils::conversion::from_string<DWORD>(ttime, time, std::dec)) { - debugLogA("! ! ! - Newsfeed with wrong/empty time (probably wrong parsing)\n%s", post.c_str()); + debugLogA("!!! - Newsfeed with wrong/empty time (probably wrong parsing)\n%s", post.c_str()); continue; } if (ttime > new_time) { new_time = ttime; // remember newest time from all these posts - debugLogA(" - Newsfeed time: %d (new)", ttime); + debugLogA(" - Newsfeed time: %d (new)", ttime); } else if (ttime <= facy.last_feeds_update_) { - debugLogA(" - Newsfeed time: %d (ignored)", ttime); + debugLogA(" - Newsfeed time: %d (ignored)", ttime); continue; // ignore posts older than newest post of previous check } else { - debugLogA(" - Newsfeed time: %d (normal)", ttime); + debugLogA(" - Newsfeed time: %d (normal)", ttime); } std::string post_place = utils::text::source_get_value(&post, 4, "</abbr>", "<a", ">", "</a>"); @@ -1148,12 +1129,12 @@ void FacebookProto::ProcessFeeds(void*) utils::text::edit_html(post_message)))); if (filtered || nf->title.empty() || nf->text.empty()) { - debugLogA(" \\ Newsfeed (time: %d) is filtered: %s", ttime, filtered ? "advertisement" : (nf->title.empty() ? "title empty" : "text empty")); + debugLogA(" \\ Newsfeed (time: %d) is filtered: %s", ttime, filtered ? "advertisement" : (nf->title.empty() ? "title empty" : "text empty")); delete nf; continue; } else { - debugLogA(" Got newsfeed (time: %d): %s %s", ttime, nf->title.c_str(), nf->text.c_str()); + debugLogA(" Got newsfeed (time: %d)", ttime); } news.push_back(nf); @@ -1161,7 +1142,7 @@ void FacebookProto::ProcessFeeds(void*) limit++; } - debugLogA(" Last feeds update (new): %d", new_time); + debugLogA(" Last feeds update (new): %d", new_time); for (std::vector<facebook_newsfeed*>::size_type i = 0; i < news.size(); i++) { @@ -1181,11 +1162,11 @@ void FacebookProto::ProcessFeeds(void*) // Set time of last update to time of newest post this->facy.last_feeds_update_ = new_time; - debugLogA("***** Feeds processed"); + debugLogA("*** Feeds processed"); CODE_BLOCK_CATCH - debugLogA("***** Error processing feeds: %s", e.what()); + debugLogA("*** Error processing feeds: %s", e.what()); CODE_BLOCK_END @@ -1232,7 +1213,7 @@ void FacebookProto::ProcessPages(void*) if (id.empty() || title.empty()) continue; - debugLogA(" Got page: %s (%s)", title.c_str(), id.c_str()); + debugLogA(" Got page ID: %s", id.c_str()); facy.pages[id] = title; } diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp index 0626e0d677..cdfd1cdeca 100644 --- a/protocols/FacebookRM/src/proto.cpp +++ b/protocols/FacebookRM/src/proto.cpp @@ -180,7 +180,7 @@ DWORD_PTR FacebookProto::GetCaps(int type, MCONTACT) int FacebookProto::SetStatus(int new_status) { - debugLogA("===== Beginning SetStatus process"); + debugLogA("=== Beginning SetStatus process"); // Routing statuses not supported by Facebook switch (new_status) @@ -201,12 +201,12 @@ int FacebookProto::SetStatus(int new_status) } if (new_status != ID_STATUS_OFFLINE && m_iStatus == ID_STATUS_CONNECTING) { - debugLogA("===== Status is already connecting, no change"); + debugLogA("=== Status is already connecting, no change"); return 0; } if (m_iStatus == m_iDesiredStatus) { - debugLogA("===== Statuses are same, no change"); + debugLogA("=== Statuses are same, no change"); return 0; } |