summaryrefslogtreecommitdiff
path: root/protocols/FacebookRM/src
diff options
context:
space:
mode:
authorKirill Volinsky <mataes2007@gmail.com>2014-12-14 19:07:00 +0000
committerKirill Volinsky <mataes2007@gmail.com>2014-12-14 19:07:00 +0000
commit967c43ea2061ddd25e69927780e534ac93ce576a (patch)
treef8107e199ad90316444cb06c3c9cc2c29b590ee7 /protocols/FacebookRM/src
parentf942a0a8f658c92c2597272d0af5e8d364426a3b (diff)
FacebookRM: changed warning lavel to w4
git-svn-id: http://svn.miranda-ng.org/main/trunk@11420 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM/src')
-rw-r--r--protocols/FacebookRM/src/avatars.cpp21
-rw-r--r--protocols/FacebookRM/src/captcha.cpp16
-rw-r--r--protocols/FacebookRM/src/chat.cpp109
-rw-r--r--protocols/FacebookRM/src/client.h4
-rw-r--r--protocols/FacebookRM/src/communication.cpp449
-rw-r--r--protocols/FacebookRM/src/connection.cpp26
-rw-r--r--protocols/FacebookRM/src/contacts.cpp31
-rw-r--r--protocols/FacebookRM/src/dialogs.cpp112
-rw-r--r--protocols/FacebookRM/src/events.cpp21
-rw-r--r--protocols/FacebookRM/src/json.cpp189
-rw-r--r--protocols/FacebookRM/src/json.h2
-rw-r--r--protocols/FacebookRM/src/main.cpp24
-rw-r--r--protocols/FacebookRM/src/messages.cpp41
-rw-r--r--protocols/FacebookRM/src/process.cpp301
-rw-r--r--protocols/FacebookRM/src/proto.cpp208
-rw-r--r--protocols/FacebookRM/src/stubs.cpp32
-rw-r--r--protocols/FacebookRM/src/theme.cpp112
-rw-r--r--protocols/FacebookRM/src/utils.cpp70
18 files changed, 909 insertions, 859 deletions
diff --git a/protocols/FacebookRM/src/avatars.cpp b/protocols/FacebookRM/src/avatars.cpp
index 0be1b41b65..43af49fa35 100644
--- a/protocols/FacebookRM/src/avatars.cpp
+++ b/protocols/FacebookRM/src/avatars.cpp
@@ -44,7 +44,7 @@ bool FacebookProto::GetDbAvatarInfo(PROTO_AVATAR_INFORMATIONT &ai, std::string *
void FacebookProto::CheckAvatarChange(MCONTACT hContact, const std::string &image_url)
{
std::tstring::size_type pos = image_url.rfind("/");
-
+
// Facebook contacts always have some avatar - keep avatar in database even if we have loaded empty one (e.g. for 'On Mobile' contacts)
if (image_url.empty() || pos == std::tstring::npos)
return;
@@ -56,11 +56,11 @@ void FacebookProto::CheckAvatarChange(MCONTACT hContact, const std::string &imag
pos = image_name.rfind("?");
if (pos != std::tstring::npos)
image_name = image_name.substr(0, pos);
-
+
// Append our parameters to allow comparing for avatar/settings change
if (getBool(FACEBOOK_KEY_BIG_AVATARS, DEFAULT_BIG_AVATARS))
image_name += "?big";
-
+
// Check for avatar change
ptrA old_name(getStringA(hContact, FACEBOOK_KEY_AVATAR));
bool update_required = (old_name == NULL || image_name.compare(old_name) != 0);
@@ -78,7 +78,8 @@ void FacebookProto::CheckAvatarChange(MCONTACT hContact, const std::string &imag
PROTO_AVATAR_INFORMATIONT ai = { sizeof(ai) };
if (GetAvatarInfo(update_required ? GAIF_FORCE : 0, (LPARAM)&ai) != GAIR_WAITFOR)
CallService(MS_AV_REPORTMYAVATARCHANGED, (WPARAM)m_szModuleName, 0);
- } else if (update_required) {
+ }
+ else if (update_required) {
db_set_b(hContact, "ContactPhoto", "NeedUpdate", 1);
ProtoBroadcastAck(hContact, ACKTYPE_AVATAR, ACKRESULT_STATUS, NULL, 0);
}
@@ -95,14 +96,14 @@ void FacebookProto::UpdateAvatarWorker(void *)
for (;;)
{
std::string url;
- PROTO_AVATAR_INFORMATIONT ai = {sizeof(ai)};
+ PROTO_AVATAR_INFORMATIONT ai = { sizeof(ai) };
ai.hContact = avatar_queue[0];
if (Miranda_Terminated())
{
debugLogA("***** Terminating avatar update early: %s", url.c_str());
break;
- }
+ }
if (GetDbAvatarInfo(ai, &url))
{
@@ -177,7 +178,7 @@ INT_PTR FacebookProto::GetAvatarInfo(WPARAM wParam, LPARAM lParam)
if (GetDbAvatarInfo(*AI, NULL))
{
bool fileExist = _taccess(AI->filename, 0) == 0;
-
+
bool needLoad;
if (AI->hContact)
needLoad = (wParam & GAIF_FORCE) && (!fileExist || db_get_b(AI->hContact, "ContactPhoto", "NeedUpdate", 0));
@@ -185,7 +186,7 @@ INT_PTR FacebookProto::GetAvatarInfo(WPARAM wParam, LPARAM lParam)
needLoad = (wParam & GAIF_FORCE) || !fileExist;
if (needLoad)
- {
+ {
debugLogA("***** Starting avatar request thread for %s", _T2A(AI->filename));
ScopedLock s(avatar_lock_);
@@ -215,11 +216,11 @@ INT_PTR FacebookProto::GetMyAvatar(WPARAM wParam, LPARAM lParam)
TCHAR* buf = (TCHAR*)wParam;
int size = (int)lParam;
- PROTO_AVATAR_INFORMATIONT ai = {sizeof(ai)};
+ PROTO_AVATAR_INFORMATIONT ai = { sizeof(ai) };
switch (GetAvatarInfo(0, (LPARAM)&ai)) {
case GAIR_SUCCESS:
_tcsncpy(buf, ai.filename, size);
- buf[size-1] = 0;
+ buf[size - 1] = 0;
return 0;
case GAIR_WAITFOR:
diff --git a/protocols/FacebookRM/src/captcha.cpp b/protocols/FacebookRM/src/captcha.cpp
index b3909e53d1..ca583f669d 100644
--- a/protocols/FacebookRM/src/captcha.cpp
+++ b/protocols/FacebookRM/src/captcha.cpp
@@ -29,7 +29,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
struct CAPTCHA_FORM_PARAMS
{
HBITMAP bmp;
- int w,h;
+ int w, h;
char Result[100];
};
@@ -39,8 +39,8 @@ static INT_PTR CALLBACK CaptchaFormDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam
switch (msg) {
case WM_INITDIALOG: {
TranslateDialogDefault(hwndDlg);
- SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)Skin_GetIconByHandle( GetIconHandle("key"), TRUE));
- SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)Skin_GetIconByHandle( GetIconHandle("key")));
+ SendMessage(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)Skin_GetIconByHandle(GetIconHandle("key"), TRUE));
+ SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)Skin_GetIconByHandle(GetIconHandle("key")));
params = (CAPTCHA_FORM_PARAMS*)lParam;
SetDlgItemText(hwndDlg, IDC_INSTRUCTION, TranslateT("Enter the text you see"));
@@ -49,7 +49,7 @@ static INT_PTR CALLBACK CaptchaFormDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam
return TRUE;
}
case WM_CTLCOLORSTATIC:
- switch(GetWindowLongPtr((HWND)lParam, GWL_ID)) {
+ switch (GetWindowLongPtr((HWND)lParam, GWL_ID)) {
case IDC_WHITERECT:
case IDC_INSTRUCTION:
case IDC_TITLE:
@@ -70,7 +70,7 @@ static INT_PTR CALLBACK CaptchaFormDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam
int y = (rc.bottom + rc.top - params->h) / 2;
int x = (rc.right + rc.left - params->w) / 2;
- BitBlt(hdc, x, y, params->w, params->h, hdcMem, 0,0, SRCCOPY);
+ BitBlt(hdc, x, y, params->w, params->h, hdcMem, 0, 0, SRCCOPY);
SelectObject(hdcMem, hOld);
DeleteDC(hdcMem);
@@ -129,15 +129,15 @@ bool FacebookProto::RunCaptchaForm(std::string captchaUrl, std::string &result)
memio.pBuf = reply->pData;
memio.fif = FIF_UNKNOWN; /* detect */
param.bmp = (HBITMAP)CallService(MS_IMG_LOADFROMMEM, (WPARAM)&memio, 0);
-
- BITMAP bmp = {0};
+
+ BITMAP bmp = { 0 };
GetObject(param.bmp, sizeof(bmp), &bmp);
param.w = bmp.bmWidth;
param.h = bmp.bmHeight;
int res = DialogBoxParam(g_hInstance, MAKEINTRESOURCE(IDD_CAPTCHAFORM), NULL, CaptchaFormDlgProc, (LPARAM)&param);
if (res == 0)
return false;
-
+
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 2fc753e6be..5a859faf7a 100644
--- a/protocols/FacebookRM/src/chat.cpp
+++ b/protocols/FacebookRM/src/chat.cpp
@@ -30,25 +30,25 @@ void FacebookProto::UpdateChat(const TCHAR *tchat_id, const char *id, const char
std::string smessage = message;
utils::text::replace_all(&smessage, "%", "%%");
- ptrT tid( mir_a2t(id));
- ptrT tnick( mir_a2t_cp(name,CP_UTF8));
- ptrT ttext( mir_a2t_cp(smessage.c_str(),CP_UTF8));
+ ptrT tid(mir_a2t(id));
+ ptrT tnick(mir_a2t_cp(name, CP_UTF8));
+ ptrT ttext(mir_a2t_cp(smessage.c_str(), CP_UTF8));
GCDEST gcd = { m_szModuleName, tchat_id, GC_EVENT_MESSAGE };
GCEVENT gce = { sizeof(gce), &gcd };
gce.ptszText = ttext;
gce.time = timestamp ? timestamp : ::time(NULL);
if (id != NULL)
- gce.bIsMe = !strcmp(id,facy.self_.user_id.c_str());
+ gce.bIsMe = !strcmp(id, facy.self_.user_id.c_str());
gce.dwFlags |= GCEF_ADDTOLOG;
if (is_old) {
gce.dwFlags |= GCEF_NOTNOTIFY;
gce.dwFlags &= ~GCEF_ADDTOLOG;
}
gce.ptszNick = tnick;
- gce.ptszUID = tid;
- CallServiceSync(MS_GC_EVENT,0,reinterpret_cast<LPARAM>(&gce));
-
+ gce.ptszUID = tid;
+ CallServiceSync(MS_GC_EVENT, 0, reinterpret_cast<LPARAM>(&gce));
+
// TODO: keep it here or move it somewhere else?
std::map<std::tstring, facebook_chatroom*>::iterator chatroom = facy.chat_rooms.find(tchat_id);
if (chatroom != facy.chat_rooms.end()) {
@@ -58,8 +58,8 @@ void FacebookProto::UpdateChat(const TCHAR *tchat_id, const char *id, const char
void FacebookProto::RenameChat(const char *chat_id, const char *name)
{
- ptrT tchat_id( mir_a2t(chat_id));
- ptrT tname( mir_a2t_cp(name, CP_UTF8));
+ ptrT tchat_id(mir_a2t(chat_id));
+ ptrT tname(mir_a2t_cp(name, CP_UTF8));
GCDEST gcd = { m_szModuleName, tchat_id, GC_EVENT_CHANGESESSIONAME };
GCEVENT gce = { sizeof(gce), &gcd };
@@ -67,7 +67,7 @@ void FacebookProto::RenameChat(const char *chat_id, const char *name)
CallService(MS_GC_EVENT, 0, reinterpret_cast<LPARAM>(&gce));
}
-int FacebookProto::OnGCEvent(WPARAM wParam,LPARAM lParam)
+int FacebookProto::OnGCEvent(WPARAM, LPARAM lParam)
{
GCHOOK *hook = reinterpret_cast<GCHOOK*>(lParam);
@@ -78,7 +78,7 @@ int FacebookProto::OnGCEvent(WPARAM wParam,LPARAM lParam)
if (!_tcscmp(hook->pDest->ptszID, _T(FACEBOOK_NOTIFICATIONS_CHATROOM)))
return 0;
- switch(hook->pDest->iType)
+ switch (hook->pDest->iType)
{
case GC_USER_MESSAGE:
{
@@ -89,7 +89,7 @@ int FacebookProto::OnGCEvent(WPARAM wParam,LPARAM lParam)
debugLogA("**Chat - Outgoing message: %s", msg.c_str());
ForkThread(&FacebookProto::SendChatMsgWorker, new send_chat(chat_id, msg));
}
-
+
break;
}
@@ -111,22 +111,22 @@ int FacebookProto::OnGCEvent(WPARAM wParam,LPARAM lParam)
/*
case GC_USER_LOGMENU:
{
- switch(hook->dwData)
- {
- case 10:
- DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_CHATROOM_INVITE), NULL, invite_to_chat_dialog,
- LPARAM(new invite_chat_param(item->id, this)));
- break;
-
- case 20:
- //chat_leave(id);
- break;
- }
- break;
+ switch(hook->dwData)
+ {
+ case 10:
+ DialogBoxParam(hInstance, MAKEINTRESOURCE(IDD_CHATROOM_INVITE), NULL, invite_to_chat_dialog,
+ LPARAM(new invite_chat_param(item->id, this)));
+ break;
+
+ case 20:
+ //chat_leave(id);
+ break;
+ }
+ break;
}
*/
- case GC_USER_NICKLISTMENU:
+ case GC_USER_NICKLISTMENU:
{
MCONTACT hContact = NULL;
if (hook->dwData == 10 || hook->dwData == 20) {
@@ -140,7 +140,7 @@ int FacebookProto::OnGCEvent(WPARAM wParam,LPARAM lParam)
break;
}
- switch (hook->dwData)
+ switch (hook->dwData)
{
case 10:
CallService(MS_USERINFO_SHOWDIALOG, hContact, 0);
@@ -171,8 +171,8 @@ void FacebookProto::AddChatContact(const TCHAR *tchat_id, const char *id, const
if (IsChatContact(tchat_id, id))
return;
- ptrT tnick( mir_a2t_cp(name, CP_UTF8));
- ptrT tid( mir_a2t(id));
+ ptrT tnick(mir_a2t_cp(name, CP_UTF8));
+ ptrT tid(mir_a2t(id));
GCDEST gcd = { m_szModuleName, tchat_id, GC_EVENT_JOIN };
GCEVENT gce = { sizeof(gce), &gcd };
@@ -185,7 +185,8 @@ void FacebookProto::AddChatContact(const TCHAR *tchat_id, const char *id, const
if (gce.bIsMe) {
gce.ptszStatus = TranslateT("Myself");
- } else {
+ }
+ else {
MCONTACT hContact = ContactIDToHContact(id);
if (hContact == NULL || getByte(hContact, FACEBOOK_KEY_CONTACT_TYPE, CONTACT_NONE) != CONTACT_FRIEND)
gce.ptszStatus = TranslateT("User");
@@ -204,8 +205,8 @@ void FacebookProto::RemoveChatContact(const TCHAR *tchat_id, const char *id, con
return;
ptrT tnick(mir_a2t_cp(name, CP_UTF8));
- ptrT tid( mir_a2t(id));
-
+ ptrT tid(mir_a2t(id));
+
GCDEST gcd = { m_szModuleName, tchat_id, GC_EVENT_PART };
GCEVENT gce = { sizeof(gce), &gcd };
gce.dwFlags = GCEF_ADDTOLOG;
@@ -214,13 +215,13 @@ void FacebookProto::RemoveChatContact(const TCHAR *tchat_id, const char *id, con
gce.time = ::time(NULL);
gce.bIsMe = false;
- CallServiceSync(MS_GC_EVENT,0,reinterpret_cast<LPARAM>(&gce));
+ CallServiceSync(MS_GC_EVENT, 0, reinterpret_cast<LPARAM>(&gce));
}
/** Caller must free result */
char *FacebookProto::GetChatUsers(const TCHAR *chat_id)
{
- GC_INFO gci = {0};
+ GC_INFO gci = { 0 };
gci.Flags = GCF_USERS;
gci.pszModule = m_szModuleName;
gci.pszID = chat_id;
@@ -234,7 +235,7 @@ char *FacebookProto::GetChatUsers(const TCHAR *chat_id)
bool FacebookProto::IsChatContact(const TCHAR *chat_id, const char *id)
{
- ptrA users( GetChatUsers(chat_id));
+ ptrA users(GetChatUsers(chat_id));
return (users != NULL && strstr(users, id) != NULL);
}
@@ -259,44 +260,45 @@ void FacebookProto::AddChat(const TCHAR *tid, const TCHAR *tname)
CallServiceSync(MS_GC_EVENT, NULL, reinterpret_cast<LPARAM>(&gce));
gce.ptszStatus = TranslateT("User");
CallServiceSync(MS_GC_EVENT, NULL, reinterpret_cast<LPARAM>(&gce));
-
+
// Finish initialization
gcd.iType = GC_EVENT_CONTROL;
gce.time = ::time(NULL);
gce.pDest = &gcd;
-
+
bool hideChats = getBool(FACEBOOK_KEY_HIDE_CHATS, DEFAULT_HIDE_CHATS);
// Add self contact
AddChatContact(tid, facy.self_.user_id.c_str(), facy.self_.real_name.c_str());
CallServiceSync(MS_GC_EVENT, (hideChats ? WINDOW_HIDDEN : SESSION_INITDONE), reinterpret_cast<LPARAM>(&gce));
- CallServiceSync(MS_GC_EVENT, SESSION_ONLINE, reinterpret_cast<LPARAM>(&gce));
+ CallServiceSync(MS_GC_EVENT, SESSION_ONLINE, reinterpret_cast<LPARAM>(&gce));
}
-INT_PTR FacebookProto::OnJoinChat(WPARAM hContact, LPARAM suppress)
-{
+INT_PTR FacebookProto::OnJoinChat(WPARAM hContact, LPARAM)
+{
if (!m_enableChat || IsSpecialChatRoom(hContact))
return 0;
- ptrT idT( getTStringA(hContact, "ChatRoomID"));
- ptrT nameT( getTStringA(hContact, "Nick"));
+ ptrT idT(getTStringA(hContact, "ChatRoomID"));
+ ptrT nameT(getTStringA(hContact, "Nick"));
if (!idT || !nameT)
return 0;
facebook_chatroom *fbc;
std::tstring tthread_id = ptrT(getTStringA(hContact, FACEBOOK_KEY_TID));
-
+
std::map<std::tstring, facebook_chatroom*>::iterator it = facy.chat_rooms.find(tthread_id);
if (it != facy.chat_rooms.end()) {
fbc = it->second;
- } else {
+ }
+ else {
// We don't have this chat loaded in memory yet, lets load some info (name, list of users)
fbc = new facebook_chatroom(tthread_id);
LoadChatInfo(fbc);
facy.chat_rooms.insert(std::make_pair(tthread_id, fbc));
}
-
+
// RM TODO: better use check if chatroom exists/is in db/is online... no?
// like: if (ChatIDToHContact(tthread_id) == NULL) {
ptrA users(GetChatUsers(tthread_id.c_str()));
@@ -317,7 +319,7 @@ INT_PTR FacebookProto::OnJoinChat(WPARAM hContact, LPARAM suppress)
return 0;
}
-INT_PTR FacebookProto::OnLeaveChat(WPARAM wParam,LPARAM)
+INT_PTR FacebookProto::OnLeaveChat(WPARAM wParam, LPARAM)
{
ptrT idT(wParam ? getTStringA(wParam, "ChatRoomID") : NULL);
@@ -327,12 +329,13 @@ INT_PTR FacebookProto::OnLeaveChat(WPARAM wParam,LPARAM)
GCEVENT gce = { sizeof(gce), &gcd };
gce.time = ::time(NULL);
- CallServiceSync(MS_GC_EVENT,SESSION_OFFLINE, reinterpret_cast<LPARAM>(&gce));
- CallServiceSync(MS_GC_EVENT,SESSION_TERMINATE,reinterpret_cast<LPARAM>(&gce));
+ CallServiceSync(MS_GC_EVENT, SESSION_OFFLINE, reinterpret_cast<LPARAM>(&gce));
+ CallServiceSync(MS_GC_EVENT, SESSION_TERMINATE, reinterpret_cast<LPARAM>(&gce));
if (!wParam) {
facy.clear_chatrooms();
- } else if (!IsSpecialChatRoom(wParam)) {
+ }
+ else if (!IsSpecialChatRoom(wParam)) {
std::tstring tthread_id = ptrT(getTStringA(wParam, FACEBOOK_KEY_TID));
std::map<std::tstring, facebook_chatroom*>::iterator it = facy.chat_rooms.find(tthread_id);
@@ -347,7 +350,7 @@ INT_PTR FacebookProto::OnLeaveChat(WPARAM wParam,LPARAM)
int FacebookProto::OnGCMenuHook(WPARAM, LPARAM lParam)
{
- GCMENUITEMS *gcmi= (GCMENUITEMS*) lParam;
+ GCMENUITEMS *gcmi = (GCMENUITEMS*)lParam;
if (gcmi == NULL || _stricmp(gcmi->pszModule, m_szModuleName)) return 0;
@@ -367,10 +370,10 @@ int FacebookProto::OnGCMenuHook(WPARAM, LPARAM lParam)
{
/*static const struct gc_item Items[] =
{
- { LPGENT("User &details"), 10, MENU_ITEM, FALSE },
- { LPGENT("User &history"), 20, MENU_ITEM, FALSE },
- { _T(""), 100, MENU_SEPARATOR, FALSE },
- { LPGENT("&Leave chat session"), 110, MENU_ITEM, FALSE }
+ { LPGENT("User &details"), 10, MENU_ITEM, FALSE },
+ { LPGENT("User &history"), 20, MENU_ITEM, FALSE },
+ { _T(""), 100, MENU_SEPARATOR, FALSE },
+ { LPGENT("&Leave chat session"), 110, MENU_ITEM, FALSE }
};
gcmi->nItems = SIZEOF(Items);
gcmi->Item = (gc_item*)Items;*/
diff --git a/protocols/FacebookRM/src/client.h b/protocols/FacebookRM/src/client.h
index e84aa3ad08..ca121b8722 100644
--- a/protocols/FacebookRM/src/client.h
+++ b/protocols/FacebookRM/src/client.h
@@ -203,8 +203,8 @@ public:
int choose_method(RequestType);
bool notify_errors(RequestType);
std::string choose_proto(RequestType);
- std::string choose_server(RequestType, std::string* data = NULL, std::string* get_data = NULL);
- std::string choose_action(RequestType, std::string* data = NULL, std::string* get_data = NULL);
+ std::string choose_server(RequestType);
+ std::string choose_action(RequestType, std::string *get_data = NULL);
NETLIBHTTPHEADER* get_request_headers(int request_type, int* headers_count);
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp
index b654b3a261..7d0cc2e12e 100644
--- a/protocols/FacebookRM/src/communication.cpp
+++ b/protocols/FacebookRM/src/communication.cpp
@@ -30,18 +30,18 @@ void facebook_client::client_notify(TCHAR* message)
http::response facebook_client::flap(RequestType request_type, std::string* request_data, std::string* request_get_data, int method)
{
http::response resp;
-
+
if (parent->isOffline()) {
resp.code = HTTP_CODE_FAKE_OFFLINE;
return resp;
}
- NETLIBHTTPREQUEST nlhr = {sizeof(NETLIBHTTPREQUEST)};
+ NETLIBHTTPREQUEST nlhr = { sizeof(NETLIBHTTPREQUEST) };
nlhr.requestType = !method ? choose_method(request_type) : method;
-
+
std::string url = choose_proto(request_type);
- url.append(choose_server(request_type, request_data, request_get_data));
- url.append(choose_action(request_type, request_data, request_get_data));
+ url.append(choose_server(request_type));
+ url.append(choose_action(request_type, request_get_data));
if (!parent->m_locale.empty())
url += "&locale=" + parent->m_locale;
@@ -50,12 +50,12 @@ http::response facebook_client::flap(RequestType request_type, std::string* requ
nlhr.flags = NLHRF_HTTP11 | choose_security_level(request_type);
nlhr.headers = get_request_headers(nlhr.requestType, &nlhr.headersCount);
- #ifdef _DEBUG
- nlhr.flags |= NLHRF_DUMPASTEXT;
- #else
- nlhr.flags |= NLHRF_NODUMP;
- #endif
-
+#ifdef _DEBUG
+ nlhr.flags |= NLHRF_DUMPASTEXT;
+#else
+ nlhr.flags |= NLHRF_NODUMP;
+#endif
+
switch (request_type)
{
case REQUEST_MESSAGES_RECEIVE:
@@ -119,7 +119,8 @@ http::response facebook_client::flap(RequestType request_type, std::string* requ
resp.data = pnlhr->pData ? pnlhr->pData : "";
CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)pnlhr);
- } else {
+ }
+ else {
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
@@ -139,7 +140,7 @@ http::response facebook_client::flap(RequestType request_type, std::string* requ
pos += 20;
error = resp.data.substr(pos, resp.data.find("\"", pos) - pos);
error = utils::text::trim(utils::text::html_entities_decode(utils::text::slashu_to_utf8(error)));
- error = ptrA( mir_utf8decodeA(error.c_str()));
+ error = ptrA(mir_utf8decodeA(error.c_str()));
}
std::string title;
@@ -148,7 +149,7 @@ http::response facebook_client::flap(RequestType request_type, std::string* requ
pos += 16;
title = resp.data.substr(pos, resp.data.find("\"", pos) - pos);
title = utils::text::trim(utils::text::html_entities_decode(utils::text::slashu_to_utf8(title)));
- title = ptrA( mir_utf8decodeA(title.c_str()));
+ title = ptrA(mir_utf8decodeA(title.c_str()));
}
bool silent = resp.data.find("\"silentError\":1") != std::string::npos;
@@ -192,7 +193,7 @@ bool facebook_client::handle_error(const std::string &method, int action)
if (!result) {
reset_error();
-
+
if (action != FORCE_QUIT)
parent->SetStatus(ID_STATUS_OFFLINE);
}
@@ -213,40 +214,40 @@ DWORD facebook_client::choose_security_level(RequestType request_type)
case REQUEST_SETUP_MACHINE:
return NLHRF_SSL;
-// case REQUEST_LOGOUT:
-// case REQUEST_HOME:
-// case REQUEST_DTSG:
-// case REQUEST_BUDDY_LIST:
-// case REQUEST_USER_INFO:
-// case REQUEST_USER_INFO_ALL:
-// case REQUEST_USER_INFO_MOBILE:
-// case REQUEST_LOAD_FRIENDSHIPS:
-// case REQUEST_SEARCH:
-// case REQUEST_DELETE_FRIEND:
-// case REQUEST_ADD_FRIEND:
-// case REQUEST_APPROVE_FRIEND:
-// case REQUEST_CANCEL_FRIENDSHIP:
-// case REQUEST_FRIENDSHIP:
-// case REQUEST_FEEDS:
-// case REQUEST_PAGES:
-// case REQUEST_NOTIFICATIONS:
-// case REQUEST_RECONNECT:
-// case REQUEST_POST_STATUS:
-// case REQUEST_IDENTITY_SWITCH:
-// case REQUEST_CAPTCHA_REFRESH:
-// case REQUEST_LINK_SCRAPER:
-// case REQUEST_MESSAGE_SEND_CHAT:
-// case REQUEST_MESSAGE_SEND_INBOX:
-// case REQUEST_THREAD_INFO:
-// case REQUEST_THREAD_SYNC:
-// case REQUEST_MESSAGES_RECEIVE:
-// case REQUEST_VISIBILITY:
-// case REQUEST_POKE:
-// case REQUEST_ASYNC:
-// case REQUEST_MARK_READ:
-// case REQUEST_NOTIFICATIONS_READ:
-// case REQUEST_UNREAD_THREADS:
-// case REQUEST_TYPING_SEND:
+ // case REQUEST_LOGOUT:
+ // case REQUEST_HOME:
+ // case REQUEST_DTSG:
+ // case REQUEST_BUDDY_LIST:
+ // case REQUEST_USER_INFO:
+ // case REQUEST_USER_INFO_ALL:
+ // case REQUEST_USER_INFO_MOBILE:
+ // case REQUEST_LOAD_FRIENDSHIPS:
+ // case REQUEST_SEARCH:
+ // case REQUEST_DELETE_FRIEND:
+ // case REQUEST_ADD_FRIEND:
+ // case REQUEST_APPROVE_FRIEND:
+ // case REQUEST_CANCEL_FRIENDSHIP:
+ // case REQUEST_FRIENDSHIP:
+ // case REQUEST_FEEDS:
+ // case REQUEST_PAGES:
+ // case REQUEST_NOTIFICATIONS:
+ // case REQUEST_RECONNECT:
+ // case REQUEST_POST_STATUS:
+ // case REQUEST_IDENTITY_SWITCH:
+ // case REQUEST_CAPTCHA_REFRESH:
+ // case REQUEST_LINK_SCRAPER:
+ // case REQUEST_MESSAGE_SEND_CHAT:
+ // case REQUEST_MESSAGE_SEND_INBOX:
+ // case REQUEST_THREAD_INFO:
+ // case REQUEST_THREAD_SYNC:
+ // case REQUEST_MESSAGES_RECEIVE:
+ // case REQUEST_VISIBILITY:
+ // case REQUEST_POKE:
+ // case REQUEST_ASYNC:
+ // case REQUEST_MARK_READ:
+ // case REQUEST_NOTIFICATIONS_READ:
+ // case REQUEST_UNREAD_THREADS:
+ // case REQUEST_TYPING_SEND:
default:
return (DWORD)0;
}
@@ -280,19 +281,19 @@ int facebook_client::choose_method(RequestType request_type)
case REQUEST_UNREAD_THREADS:
return REQUEST_POST;
-// case REQUEST_HOME:
-// case REQUEST_DTSG:
-// case REQUEST_MESSAGES_RECEIVE:
-// case REQUEST_FEEDS:
-// case REQUEST_PAGES:
-// case REQUEST_NOTIFICATIONS:
-// case REQUEST_RECONNECT:
-// case REQUEST_USER_INFO:
-// case REQUEST_USER_INFO_ALL:
-// case REQUEST_USER_INFO_MOBILE:
-// case REQUEST_LOAD_FRIENDSHIPS:
-// case REQUEST_SEARCH:
-// case REQUEST_CAPTCHA_REFRESH:
+ // case REQUEST_HOME:
+ // case REQUEST_DTSG:
+ // case REQUEST_MESSAGES_RECEIVE:
+ // case REQUEST_FEEDS:
+ // case REQUEST_PAGES:
+ // case REQUEST_NOTIFICATIONS:
+ // case REQUEST_RECONNECT:
+ // case REQUEST_USER_INFO:
+ // case REQUEST_USER_INFO_ALL:
+ // case REQUEST_USER_INFO_MOBILE:
+ // case REQUEST_LOAD_FRIENDSHIPS:
+ // case REQUEST_SEARCH:
+ // case REQUEST_CAPTCHA_REFRESH:
default:
return REQUEST_GET;
}
@@ -303,10 +304,10 @@ std::string facebook_client::choose_proto(RequestType request_type)
if (choose_security_level(request_type) == NLHRF_SSL)
return HTTP_PROTO_SECURE;
else
- return HTTP_PROTO_REGULAR;
+ return HTTP_PROTO_REGULAR;
}
-std::string facebook_client::choose_server(RequestType request_type, std::string* data, std::string* get_data)
+std::string facebook_client::choose_server(RequestType request_type)
{
switch (request_type)
{
@@ -328,40 +329,40 @@ std::string facebook_client::choose_server(RequestType request_type, std::string
case REQUEST_USER_INFO_MOBILE:
return FACEBOOK_SERVER_MOBILE;
-// case REQUEST_LOGOUT:
-// case REQUEST_BUDDY_LIST:
-// case REQUEST_USER_INFO:
-// case REQUEST_USER_INFO_ALL:
-// case REQUEST_FEEDS:
-// case REQUEST_PAGES:
-// case REQUEST_NOTIFICATIONS:
-// case REQUEST_RECONNECT:
-// case REQUEST_POST_STATUS:
-// case REQUEST_IDENTITY_SWITCH:
-// case REQUEST_CAPTCHA_REFRESH:
-// case REQUEST_LINK_SCRAPER:
-// case REQUEST_MESSAGE_SEND_CHAT:
-// case REQUEST_MESSAGE_SEND_INBOX:
-// case REQUEST_THREAD_INFO:
-// case REQUEST_THREAD_SYNC:
-// case REQUEST_VISIBILITY:
-// case REQUEST_POKE:
-// case REQUEST_ASYNC:
-// case REQUEST_MARK_READ:
-// case REQUEST_NOTIFICATIONS_READ:
-// case REQUEST_TYPING_SEND:
-// case REQUEST_SETUP_MACHINE:
-// case REQUEST_DELETE_FRIEND:
-// case REQUEST_ADD_FRIEND:
-// case REQUEST_CANCEL_FRIENDSHIP:
-// case REQUEST_FRIENDSHIP:
-// case REQUEST_UNREAD_THREADS:
+ // case REQUEST_LOGOUT:
+ // case REQUEST_BUDDY_LIST:
+ // case REQUEST_USER_INFO:
+ // case REQUEST_USER_INFO_ALL:
+ // case REQUEST_FEEDS:
+ // case REQUEST_PAGES:
+ // case REQUEST_NOTIFICATIONS:
+ // case REQUEST_RECONNECT:
+ // case REQUEST_POST_STATUS:
+ // case REQUEST_IDENTITY_SWITCH:
+ // case REQUEST_CAPTCHA_REFRESH:
+ // case REQUEST_LINK_SCRAPER:
+ // case REQUEST_MESSAGE_SEND_CHAT:
+ // case REQUEST_MESSAGE_SEND_INBOX:
+ // case REQUEST_THREAD_INFO:
+ // case REQUEST_THREAD_SYNC:
+ // case REQUEST_VISIBILITY:
+ // case REQUEST_POKE:
+ // case REQUEST_ASYNC:
+ // case REQUEST_MARK_READ:
+ // case REQUEST_NOTIFICATIONS_READ:
+ // case REQUEST_TYPING_SEND:
+ // case REQUEST_SETUP_MACHINE:
+ // case REQUEST_DELETE_FRIEND:
+ // case REQUEST_ADD_FRIEND:
+ // case REQUEST_CANCEL_FRIENDSHIP:
+ // case REQUEST_FRIENDSHIP:
+ // case REQUEST_UNREAD_THREADS:
default:
return FACEBOOK_SERVER_REGULAR;
}
}
-std::string facebook_client::choose_action(RequestType request_type, std::string* data, std::string* get_data)
+std::string facebook_client::choose_action(RequestType request_type, std::string *get_data)
{
switch (request_type)
{
@@ -401,7 +402,7 @@ std::string facebook_client::choose_action(RequestType request_type, std::string
}
case REQUEST_USER_INFO_MOBILE:
- {
+ {
std::string action = "/%sv=info";
if (get_data != NULL) {
utils::text::replace_all(&action, "%s", *get_data);
@@ -476,11 +477,11 @@ std::string facebook_client::choose_action(RequestType request_type, std::string
utils::text::replace_all(&action, "%s", self_.user_id);
return action;
}
-
+
case REQUEST_RECONNECT:
{
std::string action = "/ajax/presence/reconnect.php?__a=1&reason=%s&fb_dtsg=%s&__user=%s";
-
+
if (this->chat_reconnect_reason_.empty())
this->chat_reconnect_reason_ = "6";
@@ -533,7 +534,7 @@ std::string facebook_client::choose_action(RequestType request_type, std::string
action += "&partition=" + (this->chat_channel_partition_.empty() ? "0" : this->chat_channel_partition_);
action += "&clientid=" + this->chat_clientid_;
action += "&cb=" + utils::text::rand_string(4, "0123456789abcdefghijklmnopqrstuvwxyz");
-
+
// FIXME: fix this as I don't know how it works yet (because of quick stable release)
if (!parent->isInvisible())
action += "&idle=-1&state=active";
@@ -675,7 +676,7 @@ char* facebook_client::load_cookies()
cookieString.append(iter->second);
cookieString.append(1, ';');
}
-
+
return mir_strdup(cookieString.c_str());
}
@@ -696,7 +697,8 @@ void facebook_client::store_headers(http::response* resp, NETLIBHTTPHEADER* head
{
parent->debugLogA(" Deleted cookie '%s'", cookie_name.c_str());
cookies.erase(cookie_name);
- } else {
+ }
+ else {
parent->debugLogA(" New cookie '%s'", cookie_name.c_str());
cookies[cookie_name] = cookie_value;
}
@@ -721,7 +723,7 @@ void facebook_client::clear_notifications()
{
ScopedLock s(notifications_lock_);
- for (std::map<std::string, facebook_notification*>::iterator it = notifications.begin(); it != notifications.end(); ) {
+ for (std::map<std::string, facebook_notification*>::iterator it = notifications.begin(); it != notifications.end();) {
if (it->second->hWndPopup != NULL)
PUDeletePopup(it->second->hWndPopup); // close popup
@@ -775,14 +777,14 @@ void facebook_client::erase_reader(MCONTACT hContact)
void loginError(FacebookProto *proto, std::string error_str) {
error_str = utils::text::trim(
- utils::text::html_entities_decode(
- utils::text::remove_html(
- utils::text::edit_html(error_str))));
-
+ utils::text::html_entities_decode(
+ utils::text::remove_html(
+ utils::text::edit_html(error_str))));
+
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"),
+ mir_sntprintf(buf, SIZEOF(buf), TranslateT("Login error: %s"),
(error_str.empty()) ? TranslateT("Unknown error") : ptrT(mir_utf8decodeT(error_str.c_str())));
proto->facy.client_notify(buf);
}
@@ -793,10 +795,10 @@ bool facebook_client::login(const char *username, const char *password)
username_ = username;
password_ = password;
-
+
if (cookies.empty()) {
// Set device ID
- ptrA device( parent->getStringA(FACEBOOK_KEY_DEVICE_ID));
+ ptrA device(parent->getStringA(FACEBOOK_KEY_DEVICE_ID));
if (device != NULL)
cookies["datr"] = device;
@@ -834,7 +836,7 @@ bool facebook_client::login(const char *username, const char *password)
parent->debugLogA(" ! ! Login error: Some Facebook things are required.");
// return handle_error("login", FORCE_QUIT);
}
-
+
// Check whether setting Machine name is required
if (location.find("/checkpoint/") != std::string::npos)
{
@@ -848,7 +850,7 @@ bool facebook_client::login(const char *username, const char *password)
std::string inner_data;
if (resp.data.find("name=\"submit[Continue]\"") != std::string::npos) {
-
+
// Check if we need to approve also last unapproved device
if (resp.data.find("name=\"name_action_selected\"") == std::string::npos) {
// 1) Continue
@@ -887,8 +889,9 @@ bool facebook_client::login(const char *username, const char *password)
inner_data += "&name_action_selected=save_device"; // Save device - or "dont_save"
resp = flap(REQUEST_SETUP_MACHINE, &inner_data);
- } else if (resp.data.find("name=\"submit[OK]\"") != std::string::npos) {
-
+ }
+ else if (resp.data.find("name=\"submit[OK]\"") != std::string::npos) {
+
inner_data = "submit[OK]=OK";
inner_data += "&nh=" + utils::text::source_get_value(&resp.data, 3, "name=\"nh\"", "value=\"", "\"");
inner_data += "&fb_dtsg=" + utils::url::encode(utils::text::source_get_value(&resp.data, 3, "name=\"fb_dtsg\"", "value=\"", "\""));
@@ -899,7 +902,7 @@ bool facebook_client::login(const char *username, const char *password)
inner_data = "submit[Continue]=Continue";
inner_data += "&nh=" + utils::text::source_get_value(&resp.data, 3, "name=\"nh\"", "value=\"", "\"");
inner_data += "&fb_dtsg=" + utils::url::encode(utils::text::source_get_value(&resp.data, 3, "name=\"fb_dtsg\"", "value=\"", "\""));
-
+
// Mark that used cleaned his computer already, because he must confirm it anyway to be able to continue
inner_data += "&confirm=1";
@@ -921,7 +924,7 @@ bool facebook_client::login(const char *username, const char *password)
}
case HTTP_CODE_OK: // OK page returned, but that is regular login page we don't want in fact
- {
+ {
// 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."));
@@ -934,7 +937,7 @@ bool facebook_client::login(const char *username, const char *password)
if (error.empty())
error = utils::text::source_get_value(&resp.data, 3, "<form", "title=\"", "\"");
- loginError(parent, error);
+ loginError(parent, error);
}
case HTTP_CODE_FORBIDDEN: // Forbidden
case HTTP_CODE_NOT_FOUND: // Not Found
@@ -958,7 +961,8 @@ bool facebook_client::login(const char *username, const char *password)
parent->setString(FACEBOOK_KEY_ID, this->self_.user_id.c_str());
parent->debugLogA(" Got self user id: %s", this->self_.user_id.c_str());
return handle_success("login");
- } else {
+ }
+ else {
client_notify(TranslateT("Login error, probably bad login credentials."));
parent->debugLogA(" ! ! Login error, probably bad login credentials.");
return handle_error("login", FORCE_QUIT);
@@ -1022,13 +1026,13 @@ bool facebook_client::home()
client_notify(TranslateT("Could not load communication token. You should report this and wait for plugin update."));
return handle_error("home", FORCE_QUIT);
}
-
+
resp = flap(REQUEST_HOME);
switch (resp.code)
{
case HTTP_CODE_OK:
- {
+ {
// Get real name
this->self_.real_name = utils::text::source_get_value(&resp.data, 4, "id=\"root", "<strong", ">", "</strong>");
@@ -1073,7 +1077,7 @@ bool facebook_client::home()
// Work-around for replica_down, f**king hell what's that?
parent->debugLogA(" REPLICA_DOWN is back in force!");
return this->home();
-
+
default:
return handle_error("home", FORCE_QUIT);
}
@@ -1082,13 +1086,13 @@ bool facebook_client::home()
bool facebook_client::chat_state(bool online)
{
handle_entry("chat_state");
-
+
std::string data = (online ? "visibility=1" : "visibility=0");
data += "&window_id=0";
data += "&fb_dtsg=" + dtsg_;
data += "&__user=" + self_.user_id;
http::response resp = flap(REQUEST_VISIBILITY, &data);
-
+
if (!resp.error_title.empty())
return handle_error("chat_state");
@@ -1108,10 +1112,10 @@ bool facebook_client::reconnect()
{
this->chat_channel_ = utils::text::source_get_value(&resp.data, 2, "\"user_channel\":\"", "\"");
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());
-
+
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());
@@ -1120,7 +1124,7 @@ bool facebook_client::reconnect()
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());
-
+
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());
@@ -1132,7 +1136,7 @@ bool facebook_client::reconnect()
return handle_success("reconnect");
}
-
+
default:
return handle_error("reconnect", FORCE_DISCONNECT);
}
@@ -1230,103 +1234,103 @@ int facebook_client::send_message(MCONTACT hContact, const std::string &message_
}
switch (method) {
- case MESSAGE_INBOX:
- {
- parent->debugLogA(" > Sending message through INBOX");
- data += "&action=send";
- data += "&body=" + utils::url::encode(message_text);
- data += "&recipients[0]=" + message_recipient;
- data += "&__user=" + this->self_.user_id;
- data += "&__a=1";
- data += "&fb_dtsg=" + this->dtsg_;
- data += "&phstamp=" + phstamp(data);
-
- resp = flap(REQUEST_MESSAGE_SEND_INBOX, &data);
- break;
- }
- case MESSAGE_MERCURY:
- {
- 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;
- data += "&message_batch[0][author_email]";
- data += "&message_batch[0][coordinates]";
- data += "&message_batch[0][timestamp]=" + utils::time::mili_timestamp();
- data += "&message_batch[0][timestamp_absolute]";
- data += "&message_batch[0][timestamp_relative]";
- data += "&message_batch[0][is_unread]=false";
- data += "&message_batch[0][is_cleared]=false";
- data += "&message_batch[0][is_forward]=false";
- data += "&message_batch[0][spoof_warning]=false";
- data += "&message_batch[0][source]=source:chat:web";
- data += "&message_batch[0][source_tags][0]=source:chat";
- data += "&message_batch[0][body]=" + utils::url::encode(message_text);
- data += "&message_batch[0][has_attachment]=false";
- data += "&message_batch[0][html_body]=false";
- data += "&message_batch[0][specific_to_list][0]=fbid:" + message_recipient;
- data += "&message_batch[0][specific_to_list][1]=fbid:" + this->self_.user_id;
- data += "&message_batch[0][status]=0";
- data += "&message_batch[0][message_id]";
- data += "&message_batch[0][client_thread_id]=user:" + message_recipient;
- data += "&client=mercury";
- data += "&fb_dtsg=" + this->dtsg_;
- data += "&__user=" + this->self_.user_id;
- data += "&__a=1";
- data += "&phstamp=" + phstamp(data);
-
- resp = flap(REQUEST_MESSAGE_SEND_CHAT, &data);
- break;
- }
- case MESSAGE_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;
- data += "&message_batch[0][timestamp]=" + utils::time::mili_timestamp();
- data += "&message_batch[0][timestamp_absolute]=";
- data += "&message_batch[0][timestamp_relative]=";
- data += "&message_batch[0][is_unread]=false";
- data += "&message_batch[0][is_cleared]=false";
- data += "&message_batch[0][is_forward]=false";
- data += "&message_batch[0][source]=source:chat:web";
- data += "&message_batch[0][body]=" + utils::url::encode(message_text);
- data += "&message_batch[0][has_attachment]=false";
- data += "&message_batch[0][is_html]=false";
- data += "&message_batch[0][message_id]=";
- data += "&fb_dtsg=" + this->dtsg_;
- data += "&__user=" + this->self_.user_id;
- data += "&phstamp=" + phstamp(data);
-
- resp = flap(REQUEST_MESSAGE_SEND_CHAT, &data);
- break;
- }
- case MESSAGE_ASYNC:
- {
- parent->debugLogA(" > Sending message through ASYNC");
- data += "&action=send";
- data += "&body=" + utils::url::encode(message_text);
- data += "&recipients[0]=" + message_recipient;
- data += "&lsd=";
- data += "&fb_dtsg=" + this->dtsg_;
-
- resp = flap(REQUEST_ASYNC, &data);
- break;
- }
+ case MESSAGE_INBOX:
+ {
+ parent->debugLogA(" > Sending message through INBOX");
+ data += "&action=send";
+ data += "&body=" + utils::url::encode(message_text);
+ data += "&recipients[0]=" + message_recipient;
+ data += "&__user=" + this->self_.user_id;
+ data += "&__a=1";
+ data += "&fb_dtsg=" + this->dtsg_;
+ data += "&phstamp=" + phstamp(data);
+
+ resp = flap(REQUEST_MESSAGE_SEND_INBOX, &data);
+ break;
+ }
+ case MESSAGE_MERCURY:
+ {
+ 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;
+ data += "&message_batch[0][author_email]";
+ data += "&message_batch[0][coordinates]";
+ data += "&message_batch[0][timestamp]=" + utils::time::mili_timestamp();
+ data += "&message_batch[0][timestamp_absolute]";
+ data += "&message_batch[0][timestamp_relative]";
+ data += "&message_batch[0][is_unread]=false";
+ data += "&message_batch[0][is_cleared]=false";
+ data += "&message_batch[0][is_forward]=false";
+ data += "&message_batch[0][spoof_warning]=false";
+ data += "&message_batch[0][source]=source:chat:web";
+ data += "&message_batch[0][source_tags][0]=source:chat";
+ data += "&message_batch[0][body]=" + utils::url::encode(message_text);
+ data += "&message_batch[0][has_attachment]=false";
+ data += "&message_batch[0][html_body]=false";
+ data += "&message_batch[0][specific_to_list][0]=fbid:" + message_recipient;
+ data += "&message_batch[0][specific_to_list][1]=fbid:" + this->self_.user_id;
+ data += "&message_batch[0][status]=0";
+ data += "&message_batch[0][message_id]";
+ data += "&message_batch[0][client_thread_id]=user:" + message_recipient;
+ data += "&client=mercury";
+ data += "&fb_dtsg=" + this->dtsg_;
+ data += "&__user=" + this->self_.user_id;
+ data += "&__a=1";
+ data += "&phstamp=" + phstamp(data);
+
+ resp = flap(REQUEST_MESSAGE_SEND_CHAT, &data);
+ break;
}
-
+ case MESSAGE_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;
+ data += "&message_batch[0][timestamp]=" + utils::time::mili_timestamp();
+ data += "&message_batch[0][timestamp_absolute]=";
+ data += "&message_batch[0][timestamp_relative]=";
+ data += "&message_batch[0][is_unread]=false";
+ data += "&message_batch[0][is_cleared]=false";
+ data += "&message_batch[0][is_forward]=false";
+ data += "&message_batch[0][source]=source:chat:web";
+ data += "&message_batch[0][body]=" + utils::url::encode(message_text);
+ data += "&message_batch[0][has_attachment]=false";
+ data += "&message_batch[0][is_html]=false";
+ data += "&message_batch[0][message_id]=";
+ data += "&fb_dtsg=" + this->dtsg_;
+ data += "&__user=" + this->self_.user_id;
+ data += "&phstamp=" + phstamp(data);
+
+ resp = flap(REQUEST_MESSAGE_SEND_CHAT, &data);
+ break;
+ }
+ case MESSAGE_ASYNC:
+ {
+ parent->debugLogA(" > Sending message through ASYNC");
+ data += "&action=send";
+ data += "&body=" + utils::url::encode(message_text);
+ data += "&recipients[0]=" + message_recipient;
+ data += "&lsd=";
+ data += "&fb_dtsg=" + this->dtsg_;
+
+ resp = flap(REQUEST_ASYNC, &data);
+ break;
+ }
+ }
+
*error_text = resp.error_text;
switch (resp.error_number)
{
- case 0: // Everything is OK
+ case 0: // Everything is OK
{
// Remember this message id
std::string mid = utils::text::source_get_value(&resp.data, 2, "\"message_id\":\"", "\"");
if (mid.empty())
mid = utils::text::source_get_value(&resp.data, 2, "\"mid\":\"", "\"");
-
+
// For classic contacts remember last message id
if (!parent->isChatRoom(hContact))
parent->setString(hContact, FACEBOOK_KEY_MESSAGE_ID, mid.c_str());
@@ -1338,7 +1342,7 @@ int facebook_client::send_message(MCONTACT hContact, const std::string &message_
messages_ignore.insert(std::make_pair(mid, 0));
} break;
- //case 1356002: // You are offline (probably you can't use mercury or some other request when chat is offline)
+ //case 1356002: // You are offline (probably you can't use mercury or some other request when chat is offline)
case 1356003: // Contact is offline
{
@@ -1346,7 +1350,7 @@ int facebook_client::send_message(MCONTACT hContact, const std::string &message_
return SEND_MESSAGE_ERROR;
}
- case 1356026: // Contact has alternative client
+ case 1356026: // Contact has alternative client
{
client_notify(TranslateT("Need confirmation for sending messages to other clients.\nOpen Facebook website and try to send message to this contact again!"));
return SEND_MESSAGE_ERROR;
@@ -1356,7 +1360,7 @@ int facebook_client::send_message(MCONTACT hContact, const std::string &message_
{
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());
@@ -1382,11 +1386,11 @@ int facebook_client::send_message(MCONTACT hContact, const std::string &message_
return SEND_MESSAGE_CANCEL; // Cancel because we failed to load captcha image so we can't continue only with error
}
-
- default: // Other error
+
+ default: // Other error
parent->debugLogA(" !!! Send message error #%d: %s", resp.error_number, resp.error_text.c_str());
return SEND_MESSAGE_ERROR;
- }
+ }
switch (resp.code)
{
@@ -1479,9 +1483,9 @@ bool facebook_client::post_status(status_data *status)
//////////////////////////////////////////////////////////////////////////////
-bool facebook_client::save_url(const std::string &url,const std::tstring &filename, HANDLE &nlc)
+bool facebook_client::save_url(const std::string &url, const std::tstring &filename, HANDLE &nlc)
{
- NETLIBHTTPREQUEST req = {sizeof(req)};
+ NETLIBHTTPREQUEST req = { sizeof(req) };
NETLIBHTTPREQUEST *resp;
req.requestType = REQUEST_GET;
req.szUrl = const_cast<char*>(url.c_str());
@@ -1498,21 +1502,22 @@ bool facebook_client::save_url(const std::string &url,const std::tstring &filena
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('\\'));
+ std::tstring dir = filename.substr(0, filename.rfind('\\'));
if (_taccess(dir.c_str(), 0))
CreateDirectoryTreeT(dir.c_str());
// Write to file
FILE *f = _tfopen(filename.c_str(), _T("wb"));
if (f != NULL) {
- fwrite(resp->pData,1,resp->dataLength,f);
+ fwrite(resp->pData, 1, resp->dataLength, f);
fclose(f);
ret = _taccess(filename.c_str(), 0) == 0;
}
CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)resp);
- } else {
+ }
+ else {
nlc = NULL;
}
diff --git a/protocols/FacebookRM/src/connection.cpp b/protocols/FacebookRM/src/connection.cpp
index 2d86147031..dfeabb0973 100644
--- a/protocols/FacebookRM/src/connection.cpp
+++ b/protocols/FacebookRM/src/connection.cpp
@@ -26,7 +26,7 @@ void FacebookProto::ChangeStatus(void*)
{
ScopedLock s(signon_lock_);
ScopedLock b(facy.buddies_lock_);
-
+
int new_status = m_iDesiredStatus;
int old_status = m_iStatus;
@@ -89,7 +89,7 @@ void FacebookProto::ChangeStatus(void*)
SYSTEMTIME t;
GetLocalTime(&t);
debugLogA("[%d.%d.%d] Using Facebook Protocol RM %s", t.wDay, t.wMonth, t.wYear, __VERSION_STRING_DOTS);
-
+
debugLogA("***** Beginning SignOn process");
m_enableChat = getBool(FACEBOOK_KEY_ENABLE_CHATS, true);
@@ -100,7 +100,7 @@ void FacebookProto::ChangeStatus(void*)
ResetEvent(update_loop_lock_);
if (NegotiateConnection() && facy.home() && facy.reconnect())
- {
+ {
// Load all friends
ProcessFriendList(NULL);
@@ -120,7 +120,7 @@ void FacebookProto::ChangeStatus(void*)
ForkThread(&FacebookProto::ProcessPages, NULL);
setDword(FACEBOOK_KEY_LOGON_TS, (DWORD)time(NULL));
- ForkThread(&FacebookProto::UpdateLoop, NULL);
+ ForkThread(&FacebookProto::UpdateLoop, NULL);
ForkThread(&FacebookProto::MessageLoop, NULL);
if (getByte(FACEBOOK_KEY_SET_MIRANDA_STATUS, DEFAULT_SET_MIRANDA_STATUS))
@@ -165,15 +165,15 @@ bool FacebookProto::NegotiateConnection()
{
debugLogA("***** Negotiating connection with Facebook");
- ptrA username( getStringA(FACEBOOK_KEY_LOGIN));
+ ptrA username(getStringA(FACEBOOK_KEY_LOGIN));
if (!username || !strlen(username)) {
- NotifyEvent(m_tszUserName,TranslateT("Please enter a username."),NULL,FACEBOOK_EVENT_CLIENT);
+ NotifyEvent(m_tszUserName, TranslateT("Please enter a username."), NULL, FACEBOOK_EVENT_CLIENT);
return false;
}
- ptrA password( getStringA(FACEBOOK_KEY_PASS));
+ ptrA password(getStringA(FACEBOOK_KEY_PASS));
if (!password || !*password) {
- NotifyEvent(m_tszUserName,TranslateT("Please enter a password."),NULL,FACEBOOK_EVENT_CLIENT);
+ NotifyEvent(m_tszUserName, TranslateT("Please enter a password."), NULL, FACEBOOK_EVENT_CLIENT);
return false;
}
@@ -189,10 +189,10 @@ bool FacebookProto::NegotiateConnection()
facy.chat_clientid_ = utils::text::rand_string(8, "0123456789abcdef");
// Create default group for new contacts
- ptrT groupName( getTStringA(FACEBOOK_KEY_DEF_GROUP));
+ ptrT groupName(getTStringA(FACEBOOK_KEY_DEF_GROUP));
if (groupName != NULL)
Clist_CreateGroup(0, groupName);
-
+
return facy.login(username, password);
}
@@ -243,7 +243,7 @@ BYTE FacebookProto::GetPollRate()
BYTE poll_rate = getByte(FACEBOOK_KEY_POLL_RATE, FACEBOOK_DEFAULT_POLL_RATE);
return (
- (poll_rate >= FACEBOOK_MINIMAL_POLL_RATE &&
- poll_rate <= FACEBOOK_MAXIMAL_POLL_RATE)
- ? poll_rate : FACEBOOK_DEFAULT_POLL_RATE);
+ (poll_rate >= FACEBOOK_MINIMAL_POLL_RATE &&
+ poll_rate <= FACEBOOK_MAXIMAL_POLL_RATE)
+ ? poll_rate : FACEBOOK_DEFAULT_POLL_RATE);
}
diff --git a/protocols/FacebookRM/src/contacts.cpp b/protocols/FacebookRM/src/contacts.cpp
index e97439c57e..6e7c281d17 100644
--- a/protocols/FacebookRM/src/contacts.cpp
+++ b/protocols/FacebookRM/src/contacts.cpp
@@ -24,7 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
void updateStringUtf(FacebookProto *proto, MCONTACT hContact, const char *key, const std::string &value) {
bool update_required = true;
-
+
DBVARIANT dbv;
if (!proto->getStringUtf(hContact, key, &dbv)) {
update_required = strcmp(dbv.pszVal, value.c_str()) != 0;
@@ -153,7 +153,7 @@ std::string FacebookProto::ThreadIDToContactID(const std::string &thread_id)
break; // this shouldn't happen unless user manually deletes ID from FB contact in DB
}
}
-
+
// We don't have any contact with this thread_id cached, we must ask server
if (isOffline())
return "";
@@ -166,11 +166,11 @@ std::string FacebookProto::ThreadIDToContactID(const std::string &thread_id)
std::string user_id;
http::response resp = facy.flap(REQUEST_THREAD_INFO, &data);
-
+
if (resp.code == HTTP_CODE_OK) {
CODE_BLOCK_TRY
- facebook_json_parser* p = new facebook_json_parser(this);
+ facebook_json_parser* p = new facebook_json_parser(this);
p->parse_thread_info(&resp.data, &user_id);
delete p;
@@ -181,7 +181,7 @@ std::string FacebookProto::ThreadIDToContactID(const std::string &thread_id)
CODE_BLOCK_CATCH
- debugLogA("***** Error processing thread info: %s", e.what());
+ debugLogA("***** Error processing thread info: %s", e.what());
CODE_BLOCK_END
}
@@ -196,13 +196,13 @@ void FacebookProto::LoadContactInfo(facebook_user* fbu)
// TODO: support for more friends at once
std::string get_query = "&ids[0]=" + utils::url::encode(fbu->user_id);
-
+
http::response resp = facy.flap(REQUEST_USER_INFO, NULL, &get_query);
if (resp.code == HTTP_CODE_OK) {
CODE_BLOCK_TRY
- facebook_json_parser* p = new facebook_json_parser(this);
+ facebook_json_parser* p = new facebook_json_parser(this);
p->parse_user_info(&resp.data, fbu);
delete p;
@@ -217,7 +217,7 @@ void FacebookProto::LoadContactInfo(facebook_user* fbu)
}
void FacebookProto::LoadParticipantsNames(facebook_chatroom *fbc)
-{
+{
for (std::map<std::string, std::string>::iterator it = fbc->participants.begin(); it != fbc->participants.end(); ++it) {
if (it->second.empty()) {
if (!strcmp(it->first.c_str(), facy.self_.user_id.c_str()))
@@ -265,7 +265,7 @@ void FacebookProto::LoadChatInfo(facebook_chatroom *fbc)
CODE_BLOCK_TRY
- facebook_json_parser* p = new facebook_json_parser(this);
+ facebook_json_parser* p = new facebook_json_parser(this);
p->parse_chat_info(&resp.data, fbc);
delete p;
@@ -441,7 +441,8 @@ void FacebookProto::DeleteContactFromServer(void *data)
}
NotifyEvent(m_tszUserName, TranslateT("Contact was removed from your server list."), NULL, FACEBOOK_EVENT_OTHER);
- } else {
+ }
+ else {
facy.client_notify(TranslateT("Error occurred when removing contact from server."));
}
@@ -582,7 +583,7 @@ void FacebookProto::IgnoreFriendshipRequest(void *data)
ptrA id(getStringA(hContact, FACEBOOK_KEY_ID));
if (!id)
return;
-
+
std::string query = "action=reject";
query += "&id=" + std::string(id);
query += "&__user=" + facy.self_.user_id;
@@ -632,7 +633,7 @@ void FacebookProto::SendPokeWorker(void *p)
if (resp.data.find("\"payload\":null", 0) != std::string::npos) {
resp.data = utils::text::slashu_to_utf8(
- utils::text::source_get_value(&resp.data, 2, "__html\":\"", "\"}"));
+ utils::text::source_get_value(&resp.data, 2, "__html\":\"", "\"}"));
std::string message = utils::text::source_get_value(&resp.data, 4, "<img", "<div", ">", "<\\/div>");
@@ -642,7 +643,7 @@ void FacebookProto::SendPokeWorker(void *p)
message = utils::text::html_entities_decode(
utils::text::remove_html(message));
- ptrT tmessage( mir_utf8decodeT(message.c_str()));
+ ptrT tmessage(mir_utf8decodeT(message.c_str()));
NotifyEvent(m_tszUserName, tmessage, NULL, FACEBOOK_EVENT_OTHER);
}
@@ -650,12 +651,12 @@ void FacebookProto::SendPokeWorker(void *p)
}
-HANDLE FacebookProto::GetAwayMsg(MCONTACT hContact)
+HANDLE FacebookProto::GetAwayMsg(MCONTACT)
{
return 0; // Status messages are disabled
}
-int FacebookProto::OnContactDeleted(WPARAM wParam,LPARAM)
+int FacebookProto::OnContactDeleted(WPARAM wParam, LPARAM)
{
MCONTACT hContact = (MCONTACT)wParam;
diff --git a/protocols/FacebookRM/src/dialogs.cpp b/protocols/FacebookRM/src/dialogs.cpp
index cf9d5c97a2..d124c2191d 100644
--- a/protocols/FacebookRM/src/dialogs.cpp
+++ b/protocols/FacebookRM/src/dialogs.cpp
@@ -74,11 +74,11 @@ INT_PTR CALLBACK FBAccountProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
if (HIWORD(wparam) == EN_CHANGE && reinterpret_cast<HWND>(lparam) == GetFocus())
{
- switch(LOWORD(wparam))
+ switch (LOWORD(wparam))
{
case IDC_UN:
case IDC_PW:
- SendMessage(GetParent(hwnd),PSM_CHANGED,0,0);
+ SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
}
}
break;
@@ -109,7 +109,8 @@ void RefreshPrivacy(HWND hwnd, post_status_data *data)
if (data->walls[wall_id]->user_id == data->proto->facy.self_.user_id) {
for (size_t i = 0; i < SIZEOF(privacy_types); i++)
SendDlgItemMessageA(hwnd, IDC_PRIVACY, CB_INSERTSTRING, i, reinterpret_cast<LPARAM>(Translate(privacy_types[i].name)));
- } else {
+ }
+ else {
SendDlgItemMessage(hwnd, IDC_PRIVACY, CB_INSERTSTRING, 0, reinterpret_cast<LPARAM>(TranslateT("Default")));
}
SendDlgItemMessage(hwnd, IDC_PRIVACY, CB_SETCURSEL, 0, 0);
@@ -121,7 +122,7 @@ void ClistPrepare(FacebookProto *proto, MCONTACT hItem, HWND hwndList)
if (hItem == NULL)
hItem = (MCONTACT)::SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_ROOT, 0);
- while (hItem)
+ while (hItem)
{
MCONTACT hItemN = (MCONTACT)::SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXT, (LPARAM)hItem);
@@ -149,14 +150,15 @@ void GetSelectedContacts(FacebookProto *proto, MCONTACT hItem, HWND hwndList, st
MCONTACT hItemT = (MCONTACT)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem);
if (hItemT)
GetSelectedContacts(proto, hItemT, hwndList, contacts);
- } else {
+ }
+ else {
if (SendMessage(hwndList, CLM_GETCHECKMARK, (WPARAM)hItem, 0)) {
facebook_user *fu = new facebook_user();
-
+
ptrA userId(proto->getStringA(hItem, FACEBOOK_KEY_ID));
if (userId)
fu->user_id = userId;
-
+
ptrT realName(proto->getTStringA(hItem, FACEBOOK_KEY_NICK));
if (realName)
fu->real_name = _T2A(realName);
@@ -184,7 +186,7 @@ INT_PTR CALLBACK FBMindProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lpara
{
post_status_data *data;
- switch(message)
+ switch (message)
{
case WM_INITDIALOG:
@@ -199,11 +201,11 @@ INT_PTR CALLBACK FBMindProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lpara
SendDlgItemMessage(hwnd, IDC_MINDMSG, EM_LIMITTEXT, FACEBOOK_MIND_LIMIT, 0);
SendDlgItemMessage(hwnd, IDC_URL, EM_LIMITTEXT, 1024, 0);
- ptrT place( data->proto->getTStringA(FACEBOOK_KEY_PLACE));
+ ptrT place(data->proto->getTStringA(FACEBOOK_KEY_PLACE));
SetDlgItemText(hwnd, IDC_PLACE, place != NULL ? place : _T("Miranda NG"));
bShowContacts = data->proto->getByte("PostStatusExpand", 0) > 0;
- ResizeHorizontal(hwnd, bShowContacts);
+ ResizeHorizontal(hwnd, bShowContacts);
HWND hwndClist = GetDlgItem(hwnd, IDC_CCLIST);
SetWindowLongPtr(hwndClist, GWL_STYLE, GetWindowLongPtr(hwndClist, GWL_STYLE) & ~CLS_HIDEOFFLINE);
@@ -226,25 +228,25 @@ INT_PTR CALLBACK FBMindProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lpara
return TRUE;
case WM_NOTIFY:
- {
- NMCLISTCONTROL *nmc = (NMCLISTCONTROL *)lparam;
- if (nmc->hdr.idFrom == IDC_CCLIST) {
- switch (nmc->hdr.code) {
- case CLN_LISTREBUILT:
- data = reinterpret_cast<post_status_data*>(GetWindowLongPtr(hwnd,GWLP_USERDATA));
- ClistPrepare(data->proto, NULL, nmc->hdr.hwndFrom);
- break;
- }
+ {
+ NMCLISTCONTROL *nmc = (NMCLISTCONTROL *)lparam;
+ if (nmc->hdr.idFrom == IDC_CCLIST) {
+ switch (nmc->hdr.code) {
+ case CLN_LISTREBUILT:
+ data = reinterpret_cast<post_status_data*>(GetWindowLongPtr(hwnd, GWLP_USERDATA));
+ ClistPrepare(data->proto, NULL, nmc->hdr.hwndFrom);
+ break;
}
}
- break;
+ }
+ break;
case WM_COMMAND:
switch (LOWORD(wparam))
{
case IDC_WALL:
if (HIWORD(wparam) == CBN_SELCHANGE) {
- data = reinterpret_cast<post_status_data*>(GetWindowLongPtr(hwnd,GWLP_USERDATA));
+ data = reinterpret_cast<post_status_data*>(GetWindowLongPtr(hwnd, GWLP_USERDATA));
RefreshPrivacy(hwnd, data);
}
break;
@@ -268,9 +270,9 @@ INT_PTR CALLBACK FBMindProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lpara
case IDOK:
{
- data = reinterpret_cast<post_status_data*>(GetWindowLongPtr(hwnd,GWLP_USERDATA));
+ data = reinterpret_cast<post_status_data*>(GetWindowLongPtr(hwnd, GWLP_USERDATA));
- TCHAR mindMessageT[FACEBOOK_MIND_LIMIT+1];
+ TCHAR mindMessageT[FACEBOOK_MIND_LIMIT + 1];
TCHAR urlT[1024];
TCHAR placeT[100];
@@ -281,17 +283,17 @@ INT_PTR CALLBACK FBMindProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lpara
int wall_id = SendDlgItemMessage(hwnd, IDC_WALL, CB_GETCURSEL, 0, 0);
int privacy_id = SendDlgItemMessage(hwnd, IDC_PRIVACY, CB_GETCURSEL, 0, 0);
-
+
data->proto->setTString(FACEBOOK_KEY_PLACE, placeT);
data->proto->setByte("PostStatusExpand", bShowContacts);
// remember last wall, only when there are more options
if (SendDlgItemMessage(hwnd, IDC_WALL, CB_GETCOUNT, 0, 0) > 1)
data->proto->setByte(FACEBOOK_KEY_LAST_WALL, wall_id);
-
+
// remember last privacy, only when there are more options
if (SendDlgItemMessage(hwnd, IDC_PRIVACY, CB_GETCOUNT, 0, 0) > 1)
- data->proto->setByte(FACEBOOK_KEY_PRIVACY_TYPE, privacy_id);
+ data->proto->setByte(FACEBOOK_KEY_PRIVACY_TYPE, privacy_id);
status_data *status = new status_data();
status->user_id = data->walls[wall_id]->user_id;
@@ -303,7 +305,7 @@ INT_PTR CALLBACK FBMindProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lpara
HWND hwndList = GetDlgItem(hwnd, IDC_CCLIST);
GetSelectedContacts(data->proto, NULL, hwndList, &status->users);
- ptrA narrow( mir_utf8encodeT(mindMessageT));
+ ptrA narrow(mir_utf8encodeT(mindMessageT));
status->text = narrow;
if (status->user_id == data->proto->facy.self_.user_id && data->proto->last_status_msg_ != (char *)narrow)
@@ -321,9 +323,9 @@ INT_PTR CALLBACK FBMindProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lpara
} break;
case WM_DESTROY:
- data = reinterpret_cast<post_status_data*>(GetWindowLongPtr(hwnd,GWLP_USERDATA));
+ data = reinterpret_cast<post_status_data*>(GetWindowLongPtr(hwnd, GWLP_USERDATA));
- for(std::vector<wall_data*>::size_type i = 0; i < data->walls.size(); i++) {
+ for (std::vector<wall_data*>::size_type i = 0; i < data->walls.size(); i++) {
mir_free(data->walls[i]->title);
delete data->walls[i];
}
@@ -336,7 +338,7 @@ INT_PTR CALLBACK FBMindProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lpara
INT_PTR CALLBACK FBOptionsProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
- FacebookProto *proto = reinterpret_cast<FacebookProto*>(GetWindowLongPtr(hwnd,GWLP_USERDATA));
+ FacebookProto *proto = reinterpret_cast<FacebookProto*>(GetWindowLongPtr(hwnd, GWLP_USERDATA));
switch (message)
{
@@ -346,14 +348,14 @@ INT_PTR CALLBACK FBOptionsProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
TranslateDialogDefault(hwnd);
proto = reinterpret_cast<FacebookProto*>(lparam);
- SetWindowLongPtr(hwnd,GWLP_USERDATA,lparam);
+ SetWindowLongPtr(hwnd, GWLP_USERDATA, lparam);
ptrA login(db_get_sa(NULL, proto->ModuleName(), FACEBOOK_KEY_LOGIN));
if (login != NULL)
SetDlgItemTextA(hwnd, IDC_UN, login);
ptrA password(db_get_sa(NULL, proto->ModuleName(), FACEBOOK_KEY_PASS));
- if (password!= NULL)
+ if (password != NULL)
SetDlgItemTextA(hwnd, IDC_PW, password);
if (!proto->isOffline()) {
@@ -363,7 +365,7 @@ INT_PTR CALLBACK FBOptionsProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
LoadDBCheckState(proto, hwnd, IDC_SECURE, FACEBOOK_KEY_FORCE_HTTPS, DEFAULT_FORCE_HTTPS);
LoadDBCheckState(proto, hwnd, IDC_SECURE_CHANNEL, FACEBOOK_KEY_FORCE_HTTPS_CHANNEL, DEFAULT_FORCE_HTTPS_CHANNEL);
-
+
EnableWindow(GetDlgItem(hwnd, IDC_SECURE_CHANNEL), IsDlgButtonChecked(hwnd, IDC_SECURE));
SendDlgItemMessage(hwnd, IDC_GROUP, EM_LIMITTEXT, FACEBOOK_GROUP_NAME_LIMIT, 0);
@@ -386,8 +388,8 @@ INT_PTR CALLBACK FBOptionsProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
case IDC_UN:
case IDC_PW:
case IDC_GROUP:
- if (HIWORD(wparam)==EN_CHANGE && (HWND)lparam==GetFocus())
- SendMessage(GetParent(hwnd),PSM_CHANGED,0,0);
+ if (HIWORD(wparam) == EN_CHANGE && (HWND)lparam == GetFocus())
+ SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
break;
case IDC_SECURE:
EnableWindow(GetDlgItem(hwnd, IDC_SECURE_CHANNEL), IsDlgButtonChecked(hwnd, IDC_SECURE));
@@ -397,7 +399,7 @@ INT_PTR CALLBACK FBOptionsProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
if (IsDlgButtonChecked(hwnd, IDC_SECURE_CHANNEL))
MessageBox(hwnd, TranslateT("Note: Make sure you have disabled 'Validate SSL certificates' option in Network options to work properly."), proto->m_tszUserName, MB_OK);
default:
- SendMessage(GetParent(hwnd),PSM_CHANGED,0,0);
+ SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
}
} break;
@@ -406,17 +408,17 @@ INT_PTR CALLBACK FBOptionsProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
{
char str[128]; TCHAR tstr[128];
- GetDlgItemTextA(hwnd,IDC_UN,str,SIZEOF(str));
- db_set_s(0,proto->ModuleName(),FACEBOOK_KEY_LOGIN,str);
+ GetDlgItemTextA(hwnd, IDC_UN, str, SIZEOF(str));
+ db_set_s(0, proto->ModuleName(), FACEBOOK_KEY_LOGIN, str);
- GetDlgItemTextA(hwnd,IDC_PW,str,SIZEOF(str));
+ GetDlgItemTextA(hwnd, IDC_PW, str, SIZEOF(str));
proto->setString(FACEBOOK_KEY_PASS, str);
- GetDlgItemText(hwnd,IDC_GROUP,tstr,SIZEOF(tstr));
+ GetDlgItemText(hwnd, IDC_GROUP, tstr, SIZEOF(tstr));
if (tstr[0] != '\0')
{
proto->setTString(FACEBOOK_KEY_DEF_GROUP, tstr);
- Clist_CreateGroup( 0, tstr);
+ Clist_CreateGroup(0, tstr);
}
else proto->delSetting(FACEBOOK_KEY_DEF_GROUP);
@@ -435,9 +437,9 @@ INT_PTR CALLBACK FBOptionsProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
return FALSE;
}
-INT_PTR CALLBACK FBOptionsStatusesProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
+INT_PTR CALLBACK FBOptionsStatusesProc(HWND hwnd, UINT message, WPARAM, LPARAM lparam)
{
- FacebookProto *proto = reinterpret_cast<FacebookProto*>(GetWindowLongPtr(hwnd,GWLP_USERDATA));
+ FacebookProto *proto = reinterpret_cast<FacebookProto*>(GetWindowLongPtr(hwnd, GWLP_USERDATA));
switch (message)
{
@@ -447,7 +449,7 @@ INT_PTR CALLBACK FBOptionsStatusesProc(HWND hwnd, UINT message, WPARAM wparam, L
TranslateDialogDefault(hwnd);
proto = reinterpret_cast<FacebookProto*>(lparam);
- SetWindowLongPtr(hwnd,GWLP_USERDATA,lparam);
+ SetWindowLongPtr(hwnd, GWLP_USERDATA, lparam);
LoadDBCheckState(proto, hwnd, IDC_DISCONNECT_CHAT, FACEBOOK_KEY_DISCONNECT_CHAT, DEFAULT_DISCONNECT_CHAT);
LoadDBCheckState(proto, hwnd, IDC_SET_STATUS, FACEBOOK_KEY_SET_MIRANDA_STATUS, DEFAULT_SET_MIRANDA_STATUS);
@@ -460,8 +462,8 @@ INT_PTR CALLBACK FBOptionsStatusesProc(HWND hwnd, UINT message, WPARAM wparam, L
case WM_COMMAND: {
//switch (LOWORD(wparam)) {
//default:
- SendMessage(GetParent(hwnd),PSM_CHANGED,0,0);
- break;
+ SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
+ break;
//}
//break;
}
@@ -494,9 +496,9 @@ INT_PTR CALLBACK FBOptionsStatusesProc(HWND hwnd, UINT message, WPARAM wparam, L
INT_PTR CALLBACK FBOptionsEventsProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam)
{
- FacebookProto *proto = reinterpret_cast<FacebookProto*>(GetWindowLongPtr(hwnd,GWLP_USERDATA));
+ FacebookProto *proto = reinterpret_cast<FacebookProto*>(GetWindowLongPtr(hwnd, GWLP_USERDATA));
- switch(message)
+ switch (message)
{
case WM_INITDIALOG:
@@ -504,13 +506,13 @@ INT_PTR CALLBACK FBOptionsEventsProc(HWND hwnd, UINT message, WPARAM wparam, LPA
TranslateDialogDefault(hwnd);
proto = reinterpret_cast<FacebookProto*>(lparam);
- SetWindowLongPtr(hwnd,GWLP_USERDATA,lparam);
+ SetWindowLongPtr(hwnd, GWLP_USERDATA, lparam);
- for (size_t i = 0; i<SIZEOF(feed_types); i++)
+ for (size_t i = 0; i < SIZEOF(feed_types); i++)
SendDlgItemMessageA(hwnd, IDC_FEED_TYPE, CB_INSERTSTRING, i, reinterpret_cast<LPARAM>(Translate(feed_types[i].name)));
SendDlgItemMessage(hwnd, IDC_FEED_TYPE, CB_SETCURSEL, proto->getByte(FACEBOOK_KEY_FEED_TYPE, 0), 0);
- for (size_t i = 0; i<SIZEOF(server_types); i++)
+ for (size_t i = 0; i < SIZEOF(server_types); i++)
SendDlgItemMessageA(hwnd, IDC_URL_SERVER, CB_INSERTSTRING, i, reinterpret_cast<LPARAM>(Translate(server_types[i].name)));
SendDlgItemMessage(hwnd, IDC_URL_SERVER, CB_SETCURSEL, proto->getByte(FACEBOOK_KEY_SERVER_TYPE, 0), 0);
@@ -521,7 +523,7 @@ INT_PTR CALLBACK FBOptionsEventsProc(HWND hwnd, UINT message, WPARAM wparam, LPA
LoadDBCheckState(proto, hwnd, IDC_FEEDS_ENABLE, FACEBOOK_KEY_EVENT_FEEDS_ENABLE, DEFAULT_EVENT_FEEDS_ENABLE);
LoadDBCheckState(proto, hwnd, IDC_CLIENT_ENABLE, FACEBOOK_KEY_EVENT_CLIENT_ENABLE, DEFAULT_EVENT_CLIENT_ENABLE);
LoadDBCheckState(proto, hwnd, IDC_OTHER_ENABLE, FACEBOOK_KEY_EVENT_OTHER_ENABLE, DEFAULT_EVENT_OTHER_ENABLE);
- LoadDBCheckState(proto, hwnd, IDC_FILTER_ADS, FACEBOOK_KEY_FILTER_ADS, DEFAULT_FILTER_ADS);
+ LoadDBCheckState(proto, hwnd, IDC_FILTER_ADS, FACEBOOK_KEY_FILTER_ADS, DEFAULT_FILTER_ADS);
} return TRUE;
@@ -540,7 +542,7 @@ INT_PTR CALLBACK FBOptionsEventsProc(HWND hwnd, UINT message, WPARAM wparam, LPA
SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
break;
default:
- SendMessage(GetParent(hwnd),PSM_CHANGED,0,0);
+ SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
}
return TRUE;
@@ -587,7 +589,7 @@ INT_PTR CALLBACK FBOptionsMessagingProc(HWND hwnd, UINT message, WPARAM wparam,
LoadDBCheckState(proto, hwnd, IDC_KEEP_UNREAD, FACEBOOK_KEY_KEEP_UNREAD, DEFAULT_KEEP_UNREAD);
LoadDBCheckState(proto, hwnd, IDC_MESSAGES_ON_OPEN, FACEBOOK_KEY_MESSAGES_ON_OPEN, DEFAULT_MESSAGES_ON_OPEN);
LoadDBCheckState(proto, hwnd, IDC_LOGIN_SYNC, FACEBOOK_KEY_LOGIN_SYNC, DEFAULT_LOGIN_SYNC);
-
+
LoadDBCheckState(proto, hwnd, IDC_ENABLE_CHATS, FACEBOOK_KEY_ENABLE_CHATS, DEFAULT_ENABLE_CHATS);
LoadDBCheckState(proto, hwnd, IDC_HIDE_CHATS, FACEBOOK_KEY_HIDE_CHATS, DEFAULT_HIDE_CHATS);
@@ -622,7 +624,7 @@ INT_PTR CALLBACK FBOptionsMessagingProc(HWND hwnd, UINT message, WPARAM wparam,
StoreDBCheckState(proto, hwnd, IDC_KEEP_UNREAD, FACEBOOK_KEY_KEEP_UNREAD);
StoreDBCheckState(proto, hwnd, IDC_LOGIN_SYNC, FACEBOOK_KEY_LOGIN_SYNC);
StoreDBCheckState(proto, hwnd, IDC_MESSAGES_ON_OPEN, FACEBOOK_KEY_MESSAGES_ON_OPEN);
-
+
StoreDBCheckState(proto, hwnd, IDC_ENABLE_CHATS, FACEBOOK_KEY_ENABLE_CHATS);
StoreDBCheckState(proto, hwnd, IDC_HIDE_CHATS, FACEBOOK_KEY_HIDE_CHATS);
diff --git a/protocols/FacebookRM/src/events.cpp b/protocols/FacebookRM/src/events.cpp
index 7ebe65983d..3353a59c56 100644
--- a/protocols/FacebookRM/src/events.cpp
+++ b/protocols/FacebookRM/src/events.cpp
@@ -63,16 +63,16 @@ HWND FacebookProto::NotifyEvent(TCHAR* title, TCHAR* info, MCONTACT contact, DWO
break;
}
- if (!getByte(FACEBOOK_KEY_SYSTRAY_NOTIFY,DEFAULT_SYSTRAY_NOTIFY))
+ if (!getByte(FACEBOOK_KEY_SYSTRAY_NOTIFY, DEFAULT_SYSTRAY_NOTIFY))
{
if (ServiceExists(MS_POPUP_ADDPOPUPCLASS)) {
-
+
// TODO: if popup with particular ID is already showed, just update his content
// ... but f***ed up Popup Classes won't allow it now - they need to return hPopupWindow somehow
/* if (popup exists) {
if (PUChangeTextT(hWndPopup, info) > 0) // success
- return;
- }*/
+ return;
+ }*/
POPUPDATACLASS pd = { sizeof(pd) };
pd.ptszTitle = title;
@@ -89,24 +89,25 @@ HWND FacebookProto::NotifyEvent(TCHAR* title, TCHAR* info, MCONTACT contact, DWO
pd.PluginData = data;
}
- return (HWND) CallService(MS_POPUP_ADDPOPUPCLASS, 0, (LPARAM)&pd);
+ return (HWND)CallService(MS_POPUP_ADDPOPUPCLASS, 0, (LPARAM)&pd);
}
- } else {
+ }
+ else {
if (ServiceExists(MS_CLIST_SYSTRAY_NOTIFY))
{
MIRANDASYSTRAYNOTIFY err;
int niif_flags = flags;
REMOVE_FLAG(niif_flags, FACEBOOK_EVENT_CLIENT |
- FACEBOOK_EVENT_NEWSFEED |
- FACEBOOK_EVENT_NOTIFICATION |
- FACEBOOK_EVENT_OTHER);
+ FACEBOOK_EVENT_NEWSFEED |
+ FACEBOOK_EVENT_NOTIFICATION |
+ FACEBOOK_EVENT_OTHER);
err.szProto = m_szModuleName;
err.cbSize = sizeof(err);
err.dwInfoFlags = NIIF_INTERN_TCHAR | niif_flags;
err.tszInfoTitle = title;
err.tszInfo = info;
err.uTimeout = 10000;
- if (CallService(MS_CLIST_SYSTRAY_NOTIFY, 0, (LPARAM) & err) == 0)
+ if (CallService(MS_CLIST_SYSTRAY_NOTIFY, 0, (LPARAM)& err) == 0)
return NULL;
}
}
diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp
index 4c24b138b8..b7f85d04d5 100644
--- a/protocols/FacebookRM/src/json.cpp
+++ b/protocols/FacebookRM/src/json.cpp
@@ -25,7 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
int facebook_json_parser::parse_buddy_list(void* data, List::List< facebook_user >* buddy_list)
{
facebook_user* current = NULL;
- std::string jsonData = static_cast< std::string* >(data)->substr(9);
+ std::string jsonData = static_cast<std::string*>(data)->substr(9);
JSONROOT root(jsonData.c_str());
if (root == NULL)
@@ -45,14 +45,14 @@ int facebook_json_parser::parse_buddy_list(void* data, List::List< facebook_user
for (List::Item< facebook_user >* i = buddy_list->begin(); i != NULL; i = i->next) {
i->data->status_id = ID_STATUS_OFFLINE;
}
-
+
// Load last active times
JSONNODE *lastActive = json_get(list, "last_active_times");
if (lastActive != NULL) {
for (unsigned int i = 0; i < json_size(lastActive); i++) {
JSONNODE *it = json_at(lastActive, i);
const char *id = json_name(it);
-
+
current = buddy_list->find(id);
if (current == NULL) {
buddy_list->insert(std::make_pair(id, new facebook_user()));
@@ -63,14 +63,14 @@ int facebook_json_parser::parse_buddy_list(void* data, List::List< facebook_user
current->last_active = json_as_int(it);
}
}
-
+
// Find mobile friends
JSONNODE *mobileFriends = json_get(list, "mobile_friends");
if (mobileFriends != NULL) {
for (unsigned int i = 0; i < json_size(mobileFriends); i++) {
JSONNODE *it = json_at(mobileFriends, i);
std::string id = json_as_pstring(it);
-
+
current = buddy_list->find(id);
if (current == NULL) {
buddy_list->insert(std::make_pair(id, new facebook_user()));
@@ -85,11 +85,11 @@ int facebook_json_parser::parse_buddy_list(void* data, List::List< facebook_user
// Find now available contacts
JSONNODE *nowAvailable = json_get(list, "nowAvailableList");
- if (nowAvailable != NULL) {
+ if (nowAvailable != NULL) {
for (unsigned int i = 0; i < json_size(nowAvailable); i++) {
JSONNODE *it = json_at(nowAvailable, i);
const char *id = json_name(it);
-
+
current = buddy_list->find(id);
if (current == NULL) {
buddy_list->insert(std::make_pair(id, new facebook_user()));
@@ -98,7 +98,7 @@ int facebook_json_parser::parse_buddy_list(void* data, List::List< facebook_user
}
current->status_id = ID_STATUS_ONLINE;
-
+
JSONNODE *p = json_get(it, "p");
if (p != NULL) {
JSONNODE *status = json_get(p, "status"); // this seems to be "active" everytime
@@ -115,7 +115,7 @@ int facebook_json_parser::parse_buddy_list(void* data, List::List< facebook_user
// "webStatus" and "otherStatus" are marked as "WEB" on FB website
if ((b = (json_as_pstring(webStatus) == "active")) || json_as_pstring(otherStatus) == "active") {
- current->status_id = ID_STATUS_ONLINE;
+ current->status_id = ID_STATUS_ONLINE;
current->client = b ? CLIENT_WEB : CLIENT_OTHER;
}
@@ -136,11 +136,11 @@ int facebook_json_parser::parse_buddy_list(void* data, List::List< facebook_user
// Get aditional informations about contacts (if available)
JSONNODE *userInfos = json_get(list, "userInfos");
- if (userInfos != NULL) {
+ if (userInfos != NULL) {
for (unsigned int i = 0; i < json_size(userInfos); i++) {
JSONNODE *it = json_at(userInfos, i);
const char *id = json_name(it);
-
+
current = buddy_list->find(id);
if (current == NULL)
continue;
@@ -150,7 +150,7 @@ int facebook_json_parser::parse_buddy_list(void* data, List::List< facebook_user
if (name != NULL)
current->real_name = utils::text::slashu_to_utf8(json_as_pstring(name));
- if (thumbSrc != NULL)
+ if (thumbSrc != NULL)
current->image_url = utils::text::slashu_to_utf8(json_as_pstring(thumbSrc));
}
}
@@ -176,7 +176,7 @@ void parseUser(JSONNODE *it, facebook_user *fbu)
//JSONNODE *is_friend = json_get(it, "is_friend"); // e.g. "True"
//JSONNODE *type = json_get(it, "type"); // e.g. "friend" (classic contact) or "user" (disabled/deleted account)
-
+
if (name)
fbu->real_name = utils::text::slashu_to_utf8(json_as_pstring(name));
if (thumbSrc)
@@ -192,14 +192,14 @@ void parseUser(JSONNODE *it, facebook_user *fbu)
case 2: // male
fbu->gender = 77;
break;
- // case 7: not available female?
+ // case 7: not available female?
}
}
int facebook_json_parser::parse_friends(void* data, std::map< std::string, facebook_user* >* friends)
{
- std::string jsonData = static_cast< std::string* >(data)->substr(9);
-
+ std::string jsonData = static_cast<std::string*>(data)->substr(9);
+
JSONROOT root(jsonData.c_str());
if (root == NULL)
return EXIT_FAILURE;
@@ -222,10 +222,10 @@ int facebook_json_parser::parse_friends(void* data, std::map< std::string, faceb
}
-int facebook_json_parser::parse_notifications(void *data, std::map< std::string, facebook_notification* > *notifications)
+int facebook_json_parser::parse_notifications(void *data, std::map< std::string, facebook_notification* > *notifications)
{
- std::string jsonData = static_cast< std::string* >(data)->substr(9);
-
+ std::string jsonData = static_cast<std::string*>(data)->substr(9);
+
JSONROOT root(jsonData.c_str());
if (root == NULL)
return EXIT_FAILURE;
@@ -291,7 +291,7 @@ bool ignore_duplicits(FacebookProto *proto, const std::string &mid, const std::s
it->second++; // increase counter (for deleting it later)
return true;
}
-
+
// remember this id to ignore duplicits
proto->facy.messages_ignore.insert(std::make_pair(mid, 1));
return false;
@@ -318,7 +318,7 @@ void parseAttachments(FacebookProto *proto, std::string *message_text, JSONNODE
JSONNODE *url = json_get(itAttachment, "url");
if (url != NULL) {
std::string link = json_as_pstring(url);
-
+
if (link.find("/ajax/mercury/attachments/photo/view/") != std::string::npos)
// fix photo url
link = utils::url::decode(utils::text::source_get_value(&link, 2, "?uri=", "&"));
@@ -327,7 +327,7 @@ void parseAttachments(FacebookProto *proto, std::string *message_text, JSONNODE
bool useHttps = proto->getByte(FACEBOOK_KEY_FORCE_HTTPS, 1) > 0;
link = (useHttps ? HTTP_PROTO_SECURE : HTTP_PROTO_REGULAR) + std::string(FACEBOOK_SERVER_REGULAR) + link;
}
-
+
if (!link.empty()) {
std::string filename;
if (name != NULL)
@@ -366,11 +366,11 @@ void parseAttachments(FacebookProto *proto, std::string *message_text, JSONNODE
if (!message_text->empty())
*message_text += "\n\n";
- if (!attachments_text.empty()) {
+ if (!attachments_text.empty()) {
// we can't use this as offline messages doesn't have it
/* JSONNODE *admin_snippet = json_get(it, "admin_snippet");
if (admin_snippet != NULL) {
- *message_text += json_as_pstring(admin_snippet);
+ *message_text += json_as_pstring(admin_snippet);
} */
std::tstring newText;
@@ -388,7 +388,8 @@ void parseAttachments(FacebookProto *proto, std::string *message_text, JSONNODE
*message_text += ptrA(mir_utf8encodeT(title));
*message_text += attachments_text;
- } else {
+ }
+ else {
// TODO: better support for these attachments (parse it from "m_messaging" instead of "messaging"
*message_text += ptrA(mir_utf8encodeT(TranslateT("User sent an unsupported attachment. Open your browser to see it.")));
}
@@ -401,13 +402,14 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa
for (std::map<std::string, int>::iterator it = proto->facy.messages_ignore.begin(); it != proto->facy.messages_ignore.end();) {
if (it->second > FACEBOOK_IGNORE_COUNTER_LIMIT) {
it = proto->facy.messages_ignore.erase(it);
- } else {
+ }
+ else {
it->second++; // increase counter on each request
++it;
}
}
- std::string jsonData = static_cast< std::string* >(data)->substr(9);
+ std::string jsonData = static_cast<std::string*>(data)->substr(9);
JSONROOT root(jsonData.c_str());
if (root == NULL)
@@ -420,7 +422,7 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa
for (unsigned int i = 0; i < json_size(ms); i++) {
JSONNODE *it = json_at(ms, i);
-
+
JSONNODE *type = json_get(it, "type");
if (type == NULL)
continue;
@@ -495,13 +497,15 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa
CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)hChatContact, (LPARAM)&st);
}
}
- } else { // classic contact
+ }
+ else { // classic contact
MCONTACT hContact = proto->ContactIDToHContact(json_as_pstring(reader));
if (hContact) {
proto->facy.insert_reader(hContact, timestamp);
}
}
- } else if (t == "deliver") {
+ }
+ else if (t == "deliver") {
// inbox message (multiuser or direct)
JSONNODE *msg = json_get(it, "message");
@@ -513,7 +517,7 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa
JSONNODE *sender_fbid = json_get(msg, "sender_fbid");
JSONNODE *sender_name = json_get(msg, "sender_name");
JSONNODE *body = json_get(msg, "body");
-
+
// looks like there is either "tid" or "other_user_fbid" - or "tid" is removed forever?
JSONNODE *tid = json_get(msg, "tid");
JSONNODE *other_user_id_ = json_get(msg, "other_user_fbid");
@@ -567,7 +571,8 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa
messages->push_back(message);
}
- } else if (t == "notification_json") {
+ }
+ else if (t == "notification_json") {
// event notification
JSONNODE *nodes = json_get(it, "nodes");
@@ -587,7 +592,7 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa
JSONNODE *text = json_get(text_, "text");
JSONNODE *url = json_get(itNodes, "url");
JSONNODE *alert_id = json_get(itNodes, "alert_id");
-
+
JSONNODE *time_ = json_get(itNodes, "timestamp");
if (time_ == NULL)
continue;
@@ -602,13 +607,13 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa
facebook_notification* notification = new facebook_notification();
notification->text = utils::text::slashu_to_utf8(json_as_pstring(text));
- notification->link = json_as_pstring(url);
+ notification->link = json_as_pstring(url);
notification->id = json_as_pstring(alert_id);
notification->time = local_timestamp ? ::time(NULL) : utils::time::fix_timestamp(timestamp);
std::string::size_type pos = notification->id.find(":");
if (pos != std::string::npos)
- notification->id = notification->id.substr(pos+1);
+ notification->id = notification->id.substr(pos + 1);
// Write notification to chatroom
proto->UpdateNotificationsChatRoom(notification);
@@ -620,7 +625,8 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa
delete notification;
}
}
- } else if (t == "typ") {
+ }
+ else if (t == "typ") {
// chat typing notification
JSONNODE *from = json_get(it, "from");
@@ -637,7 +643,8 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa
proto->StartTyping(hContact);
else
proto->StopTyping(hContact);
- } else if (t == "ttyp") {
+ }
+ else if (t == "ttyp") {
// multi chat typing notification
if (!proto->m_enableChat)
continue;
@@ -672,7 +679,7 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa
if (json_as_int(st_) == 1) {
StatusTextData st = { 0 };
st.cbSize = sizeof(st);
-
+
mir_sntprintf(st.tszText, SIZEOF(st.tszText), TranslateT("%s is typing a message..."), name);
CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)hChatContact, (LPARAM)&st);
@@ -684,7 +691,8 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa
// TODO: support proper MS_PROTO_CONTACTISTYPING service for chatrooms (when it will be implemented)
}
}
- } else if (t == "privacy_changed") {
+ }
+ else if (t == "privacy_changed") {
// settings changed
JSONNODE *event_type = json_get(it, "event");
@@ -697,32 +705,32 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa
if (t == "visibility_update") {
// change of chat status
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->SetStatus(isVisible ? ID_STATUS_ONLINE : ID_STATUS_INVISIBLE);
}
- } else if (t == "buddylist_overlay") {
+ }
+ else if (t == "buddylist_overlay") {
// we opened/closed chat window - pretty useless info for us
continue;
- } else if (t == "ticker_update:home") {
- JSONNODE *actor_ = json_get(it, "actor");
- JSONNODE *time_ = json_get(it, "actor");
+ }
+ else if (t == "ticker_update:home") {
JSONNODE *story_ = json_get(it, "story_xhp");
- time_t time = json_as_float(time_);
std::string text = json_as_pstring(story_);
text = utils::text::slashu_to_utf8(text);
text = utils::text::trim(
- utils::text::html_entities_decode(
- utils::text::source_get_value(&text, 3, "<h5", ">", "</h5>")));
-
+ utils::text::html_entities_decode(
+ utils::text::source_get_value(&text, 3, "<h5", ">", "</h5>")));
+
// TODO: notify ticker updates
/* if (!text.empty()) {
proto->NotifyEvent()
- }*/
- } else if (t == "mercury") {
+ }*/
+ }
+ else if (t == "mercury") {
// rename multi user chat, video call, ...
JSONNODE *actions_ = json_get(it, "actions");
@@ -731,7 +739,7 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa
for (unsigned int i = 0; i < json_size(actions_); i++) {
JSONNODE *action_ = json_at(actions_, i);
-
+
JSONNODE *thread_id_ = json_get(action_, "thread_id");
JSONNODE *log_body_ = json_get(action_, "log_message_body");
JSONNODE *log_data_ = json_get(action_, "log_message_data");
@@ -749,9 +757,9 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa
JSONNODE *timestamp = json_get(action_, "timestamp");
JSONNODE *mid_ = json_get(action_, "message_id");
-
+
std::string message_id = json_as_pstring(mid_);
-
+
facebook_message* message = new facebook_message();
message->isChat = false;
message->isUnread = true;
@@ -765,7 +773,8 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa
message->type = CALL;
messages->push_back(message);
- } else {
+ }
+ else {
// TODO: check for other types, now we expect this is rename chat
if (!proto->m_enableChat)
@@ -780,7 +789,8 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa
proto->UpdateChat(thread_id.c_str(), NULL, NULL, message_text.c_str());
}
}
- } else if (t == "notifications_read" || t == "notifications_seen") {
+ }
+ else if (t == "notifications_read" || t == "notifications_seen") {
ScopedLock s(proto->facy.notifications_lock_);
JSONNODE *alerts = json_get(it, "alert_ids");
@@ -788,7 +798,7 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa
for (unsigned int j = 0; j < json_size(alerts); j++) {
JSONNODE *itAlerts = json_at(alerts, j);
std::string id = json_as_pstring(itAlerts);
-
+
std::map<std::string, facebook_notification*>::iterator it = notifications->find(id);
if (it != notifications->end()) {
if (it->second->hWndPopup != NULL)
@@ -798,7 +808,8 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa
notifications->erase(it);
}
}
- } else
+ }
+ else
continue;
}
@@ -807,8 +818,8 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa
int facebook_json_parser::parse_unread_threads(void* data, std::vector< std::string >* threads, bool inboxOnly)
{
- std::string jsonData = static_cast< std::string* >(data)->substr(9);
-
+ std::string jsonData = static_cast<std::string*>(data)->substr(9);
+
JSONROOT root(jsonData.c_str());
if (root == NULL)
return EXIT_FAILURE;
@@ -841,9 +852,9 @@ int facebook_json_parser::parse_unread_threads(void* data, std::vector< std::str
return EXIT_SUCCESS;
}
-int facebook_json_parser::parse_thread_messages(void* data, std::vector< facebook_message* >* messages, std::map< std::string, facebook_chatroom* >* chatrooms, bool unreadOnly, bool inboxOnly, int limit)
+int facebook_json_parser::parse_thread_messages(void* data, std::vector< facebook_message* >* messages, std::map< std::string, facebook_chatroom* >* chatrooms, bool unreadOnly, bool inboxOnly)
{
- std::string jsonData = static_cast< std::string* >(data)->substr(9);
+ std::string jsonData = static_cast<std::string*>(data)->substr(9);
JSONROOT root(jsonData.c_str());
if (root == NULL)
@@ -865,7 +876,7 @@ int facebook_json_parser::parse_thread_messages(void* data, std::vector< faceboo
for (unsigned int i = 0; i < json_size(roger); i++) {
JSONNODE *it = json_at(roger, i);
std::tstring id = _A2T(json_name(it));
-
+
// Ignore "wrong" (duplicit) identifiers - these that doesn't begin with "id."
if (id.substr(0, 3) == _T("id.")) {
facebook_chatroom *room = new facebook_chatroom(id);
@@ -882,9 +893,9 @@ int facebook_json_parser::parse_thread_messages(void* data, std::vector< faceboo
JSONNODE *thread_id = json_get(it, "thread_id");
JSONNODE *name = json_get(it, "name");
//JSONNODE *message_count = json_get(it, "message_count");
- JSONNODE *unread_count = json_get(it, "unread_count"); // TODO: use it to check against number of loaded messages... but how?
+ //JSONNODE *unread_count = json_get(it, "unread_count"); // TODO: use it to check against number of loaded messages... but how?
JSONNODE *folder = json_get(it, "folder");
-
+
if (canonical == NULL || thread_id == NULL)
continue;
@@ -895,7 +906,8 @@ int facebook_json_parser::parse_thread_messages(void* data, std::vector< faceboo
if (iter != chatrooms->end()) {
if (json_as_bool(is_canonical_user)) {
chatrooms->erase(iter); // this is not chatroom
- } else {
+ }
+ else {
iter->second->chat_name = json_as_string(name); // TODO: create name from users if there is no name...
JSONNODE *participants = json_get(it, "participants");
@@ -946,19 +958,19 @@ int facebook_json_parser::parse_thread_messages(void* data, std::vector< faceboo
std::string author_id = json_as_pstring(author);
std::string::size_type pos = author_id.find(":");
if (pos != std::string::npos)
- author_id = author_id.substr(pos+1);
+ author_id = author_id.substr(pos + 1);
// Process attachements and stickers
parseAttachments(proto, &message_text, it, thread_id, ""); // FIXME: is here supported other_user_fbid ?
if (json_as_bool(filtered) && message_text.empty())
message_text = Translate("This message is no longer available, because it was marked as abusive or spam.");
-
+
message_text = utils::text::trim(utils::text::slashu_to_utf8(message_text), true);
if (message_text.empty())
continue;
- facebook_message* message = new facebook_message();
+ facebook_message* message = new facebook_message();
message->message_text = message_text;
if (author_email != NULL)
message->sender_name = json_as_pstring(author_email);
@@ -977,16 +989,18 @@ int facebook_json_parser::parse_thread_messages(void* data, std::vector< faceboo
// this is chatroom message
message->isChat = true;
message->user_id = author_id;
- } else {
+ }
+ else {
// this is standard message
message->isChat = false;
std::map<std::string, std::string>::iterator iter = thread_ids.find(thread_id);
if (iter != thread_ids.end()) {
message->user_id = iter->second; // TODO: Check if we have contact with this ID in friendlist and otherwise do something different?
- } else {
+ }
+ else {
continue;
}
- }
+ }
messages->push_back(message);
}
@@ -996,7 +1010,7 @@ int facebook_json_parser::parse_thread_messages(void* data, std::vector< faceboo
int facebook_json_parser::parse_thread_info(void* data, std::string* user_id)
{
- std::string jsonData = static_cast< std::string* >(data)->substr(9);
+ std::string jsonData = static_cast<std::string*>(data)->substr(9);
JSONROOT root(jsonData.c_str());
if (root == NULL)
@@ -1017,7 +1031,7 @@ int facebook_json_parser::parse_thread_info(void* data, std::string* user_id)
JSONNODE *it = json_at(threads, i);
JSONNODE *canonical = json_get(it, "canonical_fbid");
JSONNODE *thread_id = json_get(it, "thread_id");
- JSONNODE *message_count = json_get(it, "message_count"); // TODO: this could be useful for loading history from server
+ //JSONNODE *message_count = json_get(it, "message_count"); // TODO: this could be useful for loading history from server
if (canonical == NULL || thread_id == NULL)
continue;
@@ -1035,7 +1049,7 @@ int facebook_json_parser::parse_thread_info(void* data, std::string* user_id)
int facebook_json_parser::parse_user_info(void* data, facebook_user* fbu)
{
- std::string jsonData = static_cast< std::string* >(data)->substr(9);
+ std::string jsonData = static_cast<std::string*>(data)->substr(9);
JSONROOT root(jsonData.c_str());
if (root == NULL)
@@ -1054,7 +1068,7 @@ int facebook_json_parser::parse_user_info(void* data, facebook_user* fbu)
//std::map<std::string, std::string> user_ids;
for (unsigned int i = 0; i < json_size(profiles); i++) {
JSONNODE *it = json_at(profiles, i);
-
+
// TODO: allow more users to parse at once
std::string id = json_name(it);
@@ -1069,7 +1083,7 @@ int facebook_json_parser::parse_user_info(void* data, facebook_user* fbu)
int facebook_json_parser::parse_chat_info(void* data, facebook_chatroom* fbc)
{
- std::string jsonData = static_cast< std::string* >(data)->substr(9);
+ std::string jsonData = static_cast<std::string*>(data)->substr(9);
JSONROOT root(jsonData.c_str());
if (root == NULL)
@@ -1088,18 +1102,18 @@ int facebook_json_parser::parse_chat_info(void* data, facebook_chatroom* fbc)
/*JSONNODE *roger = json_get(payload, "roger");
if (roger != NULL) {
- for (unsigned int i = 0; i < json_size(roger); i++) {
- JSONNODE *it = json_at(roger, i);
- std::tstring id = _A2T(json_name(it));
+ for (unsigned int i = 0; i < json_size(roger); i++) {
+ JSONNODE *it = json_at(roger, i);
+ std::tstring id = _A2T(json_name(it));
- // Ignore "wrong" (duplicit) identifiers - these that doesn't begin with "id."
- if (id.substr(0, 3) == _T("id.")) {
- facebook_chatroom *room = new facebook_chatroom();
- room->thread_id = id;
+ // Ignore "wrong" (duplicit) identifiers - these that doesn't begin with "id."
+ if (id.substr(0, 3) == _T("id.")) {
+ facebook_chatroom *room = new facebook_chatroom();
+ room->thread_id = id;
- chatrooms->insert(std::make_pair((char*)_T2A(room->thread_id.c_str()), room));
- }
- }
+ chatrooms->insert(std::make_pair((char*)_T2A(room->thread_id.c_str()), room));
+ }
+ }
}*/
//std::map<std::string, std::string> thread_ids;
@@ -1110,8 +1124,7 @@ int facebook_json_parser::parse_chat_info(void* data, facebook_chatroom* fbc)
JSONNODE *thread_id_ = json_get(it, "thread_id");
JSONNODE *name_ = json_get(it, "name");
//JSONNODE *message_count_ = json_get(it, "message_count");
- JSONNODE *unread_count_ = json_get(it, "unread_count"); // TODO: use it to check against number of loaded messages... but how?
- JSONNODE *folder_ = json_get(it, "folder");
+ //JSONNODE *unread_count_ = json_get(it, "unread_count"); // TODO: use it to check against number of loaded messages... but how?
if (thread_id_ == NULL || is_canonical_user_ == NULL || json_as_bool(is_canonical_user_))
continue;
diff --git a/protocols/FacebookRM/src/json.h b/protocols/FacebookRM/src/json.h
index d1e8f2e44d..cae57eb412 100644
--- a/protocols/FacebookRM/src/json.h
+++ b/protocols/FacebookRM/src/json.h
@@ -35,7 +35,7 @@ public:
int parse_notifications(void*, std::map< std::string, facebook_notification* >*);
int parse_messages(void*, std::vector< facebook_message* >*, std::map< std::string, facebook_notification* >*, bool inboxOnly);
int parse_unread_threads(void*, std::vector< std::string >*, bool inboxOnly);
- int parse_thread_messages(void*, std::vector< facebook_message* >*, std::map< std::string, facebook_chatroom* >*, bool unreadOnly, bool inboxOnly, int limit);
+ int parse_thread_messages(void*, std::vector< facebook_message* >*, std::map< std::string, facebook_chatroom* >*, bool unreadOnly, bool inboxOnly);
int parse_thread_info(void* data, std::string* user_id);
int parse_user_info(void* data, facebook_user* fbu);
int parse_chat_info(void* data, facebook_chatroom* fbc);
diff --git a/protocols/FacebookRM/src/main.cpp b/protocols/FacebookRM/src/main.cpp
index 8aa058ec4d..c112ff858f 100644
--- a/protocols/FacebookRM/src/main.cpp
+++ b/protocols/FacebookRM/src/main.cpp
@@ -42,7 +42,7 @@ PLUGININFOEX pluginInfo = {
__AUTHORWEB,
UNICODE_AWARE,
// {8432B009-FF32-4727-AAE6-A9035038FD58}
- {0x8432b009, 0xff32, 0x4727, {0xaa, 0xe6, 0xa9, 0x3, 0x50, 0x38, 0xfd, 0x58}}
+ { 0x8432b009, 0xff32, 0x4727, { 0xaa, 0xe6, 0xa9, 0x3, 0x50, 0x38, 0xfd, 0x58 } }
};
/////////////////////////////////////////////////////////////////////////////
@@ -54,7 +54,7 @@ static int compare_protos(const FacebookProto *p1, const FacebookProto *p2)
OBJLIST<FacebookProto> g_Instances(1, compare_protos);
-DWORD WINAPI DllMain(HINSTANCE hInstance,DWORD,LPVOID)
+DWORD WINAPI DllMain(HINSTANCE hInstance, DWORD, LPVOID)
{
g_hInstance = hInstance;
return TRUE;
@@ -69,14 +69,14 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD miranda
/////////////////////////////////////////////////////////////////////////////////////////
// Interface information
-extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_PROTOCOL, MIID_LAST};
+extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOCOL, MIID_LAST };
/////////////////////////////////////////////////////////////////////////////////////////
// Load
-static PROTO_INTERFACE* protoInit(const char *proto_name,const TCHAR *username)
+static PROTO_INTERFACE* protoInit(const char *proto_name, const TCHAR *username)
{
- FacebookProto *proto = new FacebookProto(proto_name,username);
+ FacebookProto *proto = new FacebookProto(proto_name, username);
g_Instances.insert(proto);
return proto;
}
@@ -97,8 +97,8 @@ extern "C" int __declspec(dllexport) Load(void)
pd.type = PROTOTYPE_PROTOCOL;
pd.fnInit = protoInit;
pd.fnUninit = protoUninit;
- CallService(MS_PROTO_REGISTERMODULE,0,reinterpret_cast<LPARAM>(&pd));
-
+ CallService(MS_PROTO_REGISTERMODULE, 0, reinterpret_cast<LPARAM>(&pd));
+
InitIcons();
InitContactMenus();
@@ -107,11 +107,11 @@ extern "C" int __declspec(dllexport) Load(void)
CallService(MS_SYSTEM_GETFILEVERSION, 0, (LPARAM)v);
std::stringstream agent;
agent << "MirandaNG/" << v[0] << "." << v[1] << "." << v[2] << "." << v[3] << ".";
- #ifdef _WIN64
- agent << " Facebook Protocol RM x64/";
- #else
- agent << " Facebook Protocol RM/";
- #endif
+#ifdef _WIN64
+ agent << " Facebook Protocol RM x64/";
+#else
+ agent << " Facebook Protocol RM/";
+#endif
agent << __VERSION_STRING_DOTS;
g_strUserAgent = agent.str();
diff --git a/protocols/FacebookRM/src/messages.cpp b/protocols/FacebookRM/src/messages.cpp
index fb415825be..de6811cf2c 100644
--- a/protocols/FacebookRM/src/messages.cpp
+++ b/protocols/FacebookRM/src/messages.cpp
@@ -34,7 +34,7 @@ int FacebookProto::RecvMsg(MCONTACT hContact, PROTORECVEVENT *pre)
void FacebookProto::SendMsgWorker(void *p)
{
- if(p == NULL)
+ if (p == NULL)
return;
send_direct *data = static_cast<send_direct*>(p);
@@ -43,9 +43,11 @@ void FacebookProto::SendMsgWorker(void *p)
if (!isOnline()) {
ProtoBroadcastAck(data->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, data->msgid, (LPARAM)Translate("You cannot send messages when you are offline."));
- } else if (id == NULL) {
+ }
+ else if (id == NULL) {
ProtoBroadcastAck(data->hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, data->msgid, 0);
- } else {
+ }
+ else {
int retries = 5;
std::string error_text;
int result = SEND_MESSAGE_ERROR;
@@ -69,7 +71,7 @@ void FacebookProto::SendMsgWorker(void *p)
void FacebookProto::SendChatMsgWorker(void *p)
{
- if(p == NULL)
+ if (p == NULL)
return;
send_chat *data = static_cast<send_chat*>(p);
@@ -84,7 +86,8 @@ void FacebookProto::SendChatMsgWorker(void *p)
std::string tid;
if (tid_ != NULL) {
tid = tid_;
- } else {
+ }
+ else {
std::string post_data = "threads[group_ids][0]=" + utils::url::encode(data->chat_id);
post_data += "&fb_dtsg=" + facy.dtsg_;
post_data += "&__user=" + facy.self_.user_id;
@@ -95,8 +98,8 @@ 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());
- }
-
+ }
+
if (!tid.empty()) {
if (facy.send_message(hContact, tid, data->msg, &err_message, MESSAGE_TID) == SEND_MESSAGE_OK)
UpdateChat(_A2T(data->chat_id.c_str()), facy.self_.user_id.c_str(), facy.self_.real_name.c_str(), data->msg.c_str());
@@ -113,14 +116,14 @@ int FacebookProto::SendMsg(MCONTACT hContact, int flags, const char *msg)
// TODO: msg comes as Unicode (retyped wchar_t*), why should we convert it as ANSI to UTF-8? o_O
if (flags & PREF_UNICODE)
msg = mir_utf8encode(msg);
-
+
facy.msgid_ = (facy.msgid_ % 1024) + 1;
ForkThread(&FacebookProto::SendMsgWorker, new send_direct(hContact, msg, (HANDLE)facy.msgid_));
return facy.msgid_;
}
-int FacebookProto::UserIsTyping(MCONTACT hContact,int type)
-{
+int FacebookProto::UserIsTyping(MCONTACT hContact, int type)
+{
if (hContact && isOnline())
ForkThread(&FacebookProto::SendTypingWorker, new send_typing(hContact, type));
@@ -148,13 +151,13 @@ void FacebookProto::SendTypingWorker(void *p)
delete typing;
return;
}
-
+
const char *value = (isChatRoom(typing->hContact) ? FACEBOOK_KEY_TID : FACEBOOK_KEY_ID);
- ptrA id( getStringA(typing->hContact, value));
+ ptrA id(getStringA(typing->hContact, value));
if (id != NULL) {
std::string data = "&source=mercury-chat";
data += (typing->status == PROTOTYPE_SELFTYPING_ON ? "&typ=1" : "&typ=0");
-
+
data += "&to=";
if (isChatRoom(typing->hContact))
data += "&thread=";
@@ -163,7 +166,7 @@ void FacebookProto::SendTypingWorker(void *p)
data += "&fb_dtsg=" + facy.dtsg_;
data += "&lsd=&__user=" + facy.self_.user_id;
data += "&phstamp=" + facy.phstamp(data);
-
+
http::response resp = facy.flap(REQUEST_TYPING_SEND, &data);
}
@@ -174,7 +177,7 @@ void FacebookProto::ReadMessageWorker(void *p)
{
if (p == NULL)
return;
-
+
if (getBool(FACEBOOK_KEY_KEEP_UNREAD, 0))
return;
@@ -188,7 +191,7 @@ void FacebookProto::ReadMessageWorker(void *p)
std::string data = "fb_dtsg=" + facy.dtsg_;
data += "&__user=" + facy.self_.user_id;
data += "&__a=1&__dyn=&__req=&ttstamp=" + facy.ttstamp();
-
+
for (std::set<MCONTACT>::iterator it = hContacts->begin(); it != hContacts->end(); ++it) {
MCONTACT hContact = *it;
@@ -200,7 +203,7 @@ void FacebookProto::ReadMessageWorker(void *p)
ptrA id(getStringA(hContact, value));
if (id == NULL)
continue;
-
+
data += "&ids[" + utils::url::encode(std::string(id)) + "]=true";
}
hContacts->clear();
@@ -211,11 +214,11 @@ void FacebookProto::ReadMessageWorker(void *p)
void FacebookProto::StickerAsSmiley(std::string sticker, const std::string &url, MCONTACT hContact)
{
- std::string b64 = ptrA( mir_base64_encode((PBYTE)sticker.c_str(), (unsigned)sticker.length()));
+ std::string b64 = ptrA(mir_base64_encode((PBYTE)sticker.c_str(), (unsigned)sticker.length()));
b64 = utils::url::encode(b64);
std::tstring filename = GetAvatarFolder() + _T("\\stickers\\") + (TCHAR*)_A2T(b64.c_str()) + _T(".png");
-
+
// Check if we have this sticker already and download it it not
if (GetFileAttributes(filename.c_str()) == INVALID_FILE_ATTRIBUTES) {
HANDLE nlc = NULL;
diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp
index 1923b674c0..36b95aad68 100644
--- a/protocols/FacebookRM/src/process.cpp
+++ b/protocols/FacebookRM/src/process.cpp
@@ -35,7 +35,7 @@ void FacebookProto::ProcessBuddyList(void*)
// Prepare update data
std::string post_data = "user=" + facy.self_.user_id + "&fetch_mobile=true&fb_dtsg=" + facy.dtsg_ + "&__user=" + facy.self_.user_id + "&cached_user_info_ids=";
-
+
int counter = 0;
for (List::Item< facebook_user >* i = facy.buddies.begin(); i != NULL; i = i->next, counter++)
{
@@ -56,24 +56,24 @@ void FacebookProto::ProcessBuddyList(void*)
CODE_BLOCK_TRY
- facebook_json_parser* p = new facebook_json_parser(this);
+ facebook_json_parser* p = new facebook_json_parser(this);
p->parse_buddy_list(&resp.data, &facy.buddies);
delete p;
for (List::Item< facebook_user >* i = facy.buddies.begin(); i != NULL;)
- {
+ {
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;
+ 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)";
@@ -83,8 +83,8 @@ void FacebookProto::ProcessBuddyList(void*)
{
if (!fbu->handle) // just been added
fbu->handle = AddToContactList(fbu, CONTACT_FRIEND);
-
- ptrT client( getTStringA(fbu->handle, "MirVer"));
+
+ ptrT client(getTStringA(fbu->handle, "MirVer"));
if (!client || _tcscmp(client, fbu->getMirVer()))
setTString(fbu->handle, "MirVer", fbu->getMirVer());
@@ -104,13 +104,14 @@ void FacebookProto::ProcessBuddyList(void*)
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
fbu->handle = AddToContactList(fbu, CONTACT_FRIEND);
- if (getWord(fbu->handle, "Status", 0) != fbu->status_id)
+ if (getWord(fbu->handle, "Status", 0) != (int)fbu->status_id)
setWord(fbu->handle, "Status", fbu->status_id);
if (getDword(fbu->handle, "LastActiveTS", 0) != fbu->last_active) {
@@ -131,7 +132,7 @@ void FacebookProto::ProcessBuddyList(void*)
std::string url = FACEBOOK_URL_PROFILE + fbu->user_id;
- ptrT szTitle( mir_utf8decodeT(fbu->real_name.c_str()));
+ ptrT szTitle(mir_utf8decodeT(fbu->real_name.c_str()));
NotifyEvent(szTitle, TranslateT("Contact is back on server-list."), fbu->handle, FACEBOOK_EVENT_OTHER, &url);
}
@@ -144,7 +145,7 @@ void FacebookProto::ProcessBuddyList(void*)
CODE_BLOCK_CATCH
- debugLogA("***** Error processing buddy list: %s", e.what());
+ debugLogA("***** Error processing buddy list: %s", e.what());
CODE_BLOCK_END
}
@@ -164,13 +165,13 @@ void FacebookProto::ProcessFriendList(void*)
if (resp.code != HTTP_CODE_OK) {
facy.handle_error("load_friends");
return;
- }
+ }
debugLogA("***** Starting processing friend list");
CODE_BLOCK_TRY
- std::map<std::string, facebook_user*> friends;
+ std::map<std::string, facebook_user*> friends;
facebook_json_parser* p = new facebook_json_parser(this);
p->parse_friends(&resp.data, &friends);
@@ -179,7 +180,7 @@ void FacebookProto::ProcessFriendList(void*)
// Check and update old contacts
for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
- if ( isChatRoom(hContact))
+ if (isChatRoom(hContact))
continue;
// TODO RM: change name of "Deleted" key to "DeletedTS", remove this code in some next version
@@ -193,17 +194,17 @@ void FacebookProto::ProcessFriendList(void*)
ptrA id(getStringA(hContact, FACEBOOK_KEY_ID));
if (id != NULL) {
std::map< std::string, facebook_user* >::iterator iter;
-
+
if ((iter = friends.find(std::string(id))) != friends.end()) {
// Found contact, update it and remove from map
fbu = iter->second;
// TODO RM: remove, because contacts cant change it, so its only for "first run"
- // - but what with contacts, that was added after logon?
+ // - but what with contacts, that was added after logon?
// Update gender
- if (getByte(hContact, "Gender", 0) != fbu->gender)
+ if (getByte(hContact, "Gender", 0) != (int)fbu->gender)
setByte(hContact, "Gender", fbu->gender);
-
+
// TODO: remove this in some future version?
// Remove old useless "RealName" field
ptrA realname(getStringA(hContact, "RealName"));
@@ -237,7 +238,7 @@ void FacebookProto::ProcessFriendList(void*)
std::string url = FACEBOOK_URL_PROFILE + fbu->user_id;
- ptrT szTitle( mir_utf8decodeT(fbu->real_name.c_str()));
+ ptrT szTitle(mir_utf8decodeT(fbu->real_name.c_str()));
NotifyEvent(szTitle, TranslateT("Contact is back on server-list."), hContact, FACEBOOK_EVENT_OTHER, &url);
}
@@ -246,14 +247,15 @@ void FacebookProto::ProcessFriendList(void*)
// Mark this contact as deleted ("processed") and delete them later (as there may be some duplicit contacts to use)
fbu->deleted = true;
- } else {
+ }
+ else {
// Contact was removed from "server-list", notify it
// Wasnt we already been notified about this contact? And was this real friend?
if (!getDword(hContact, FACEBOOK_KEY_DELETED, 0) && getByte(hContact, FACEBOOK_KEY_CONTACT_TYPE, 0) == CONTACT_FRIEND) {
setDword(hContact, FACEBOOK_KEY_DELETED, ::time(NULL));
setByte(hContact, FACEBOOK_KEY_CONTACT_TYPE, CONTACT_NONE);
-
+
std::string contactname = id;
DBVARIANT dbv;
@@ -264,7 +266,7 @@ void FacebookProto::ProcessFriendList(void*)
std::string url = FACEBOOK_URL_PROFILE + std::string(id);
- ptrT szTitle( mir_utf8decodeT(contactname.c_str()));
+ ptrT szTitle(mir_utf8decodeT(contactname.c_str()));
NotifyEvent(szTitle, TranslateT("Contact is no longer on server-list."), hContact, FACEBOOK_EVENT_OTHER, &url);
}
}
@@ -272,7 +274,7 @@ void FacebookProto::ProcessFriendList(void*)
}
// Check remaining contacts in map and add them to contact list
- for (std::map< std::string, facebook_user* >::iterator it = friends.begin(); it != friends.end(); ) {
+ for (std::map< std::string, facebook_user* >::iterator it = friends.begin(); it != friends.end();) {
if (!it->second->deleted)
AddToContactList(it->second, CONTACT_FRIEND, true); // we know this contact doesn't exists, so we force add it
@@ -285,7 +287,7 @@ void FacebookProto::ProcessFriendList(void*)
CODE_BLOCK_CATCH
- debugLogA("***** Error processing friend list: %s", e.what());
+ debugLogA("***** Error processing friend list: %s", e.what());
CODE_BLOCK_END
}
@@ -314,10 +316,10 @@ void FacebookProto::ProcessUnreadMessages(void*)
facy.handle_error("ProcessUnreadMessages");
return;
}
-
+
CODE_BLOCK_TRY
-
- std::vector<std::string> threads;
+
+ std::vector<std::string> threads;
facebook_json_parser* p = new facebook_json_parser(this);
p->parse_unread_threads(&resp.data, &threads, inboxOnly);
@@ -329,11 +331,11 @@ void FacebookProto::ProcessUnreadMessages(void*)
CODE_BLOCK_CATCH
- debugLogA("***** Error processing unread threads list: %s", e.what());
+ debugLogA("***** Error processing unread threads list: %s", e.what());
CODE_BLOCK_END
-
- facy.handle_success("ProcessUnreadMessages");
+
+ facy.handle_success("ProcessUnreadMessages");
}
void FacebookProto::ProcessUnreadMessage(void *p)
@@ -366,7 +368,7 @@ void FacebookProto::ProcessUnreadMessage(void *p)
data += "&__user=" + facy.self_.user_id;
data += "&fb_dtsg=" + facy.dtsg_;
data += "&__a=1&__dyn=&__req=&ttstamp=" + facy.ttstamp();
-
+
for (std::vector<std::string>::size_type i = 0; i < threads.size(); i++) {
std::string thread_id = utils::url::encode(threads[i]);
@@ -375,7 +377,7 @@ void FacebookProto::ProcessUnreadMessage(void *p)
data += "][offset]=" + utils::conversion::to_string(&offset, UTILS_CONV_SIGNED_NUMBER);
data += "&messages[thread_ids][" + thread_id;
data += "][limit]=" + utils::conversion::to_string(&limit, UTILS_CONV_SIGNED_NUMBER);
-
+
// request info about thread
data += "&threads[thread_ids][" + utils::conversion::to_string(&i, UTILS_CONV_UNSIGNED_NUMBER);
data += "]=" + thread_id;
@@ -384,17 +386,17 @@ void FacebookProto::ProcessUnreadMessage(void *p)
resp = facy.flap(REQUEST_THREAD_INFO, &data);
if (resp.code == HTTP_CODE_OK) {
-
+
CODE_BLOCK_TRY
-
- std::vector<facebook_message*> messages;
+
+ std::vector<facebook_message*> messages;
std::map<std::string, facebook_chatroom*> chatrooms;
facebook_json_parser* p = new facebook_json_parser(this);
- p->parse_thread_messages(&resp.data, &messages, &chatrooms, false, inboxOnly, limit);
- delete p;
+ p->parse_thread_messages(&resp.data, &messages, &chatrooms, false, inboxOnly);
+ delete p;
- for (std::map<std::string, facebook_chatroom*>::iterator it = chatrooms.begin(); it != chatrooms.end(); ) {
+ for (std::map<std::string, facebook_chatroom*>::iterator it = chatrooms.begin(); it != chatrooms.end();) {
// TODO: refactor this too!
// TODO: have all chatrooms in facy, in memory, and then handle them as needed... somehow think about it...
@@ -402,19 +404,19 @@ void FacebookProto::ProcessUnreadMessage(void *p)
MCONTACT hChatContact = NULL;
ptrA users(GetChatUsers(room->thread_id.c_str()));
if (users == NULL) {
- AddChat(room->thread_id.c_str(), room->chat_name.c_str());
- hChatContact = ChatIDToHContact(room->thread_id);
- // Set thread id (TID) for later
- setTString(hChatContact, FACEBOOK_KEY_TID, room->thread_id.c_str());
-
- for (std::map<std::string, std::string>::iterator jt = room->participants.begin(); jt != room->participants.end(); ) {
- AddChatContact(room->thread_id.c_str(), jt->first.c_str(), jt->second.c_str());
- ++jt;
- }
+ AddChat(room->thread_id.c_str(), room->chat_name.c_str());
+ hChatContact = ChatIDToHContact(room->thread_id);
+ // Set thread id (TID) for later
+ setTString(hChatContact, FACEBOOK_KEY_TID, room->thread_id.c_str());
+
+ for (std::map<std::string, std::string>::iterator jt = room->participants.begin(); jt != room->participants.end(); ) {
+ AddChatContact(room->thread_id.c_str(), jt->first.c_str(), jt->second.c_str());
+ ++jt;
+ }
}
if (!hChatContact)
- hChatContact = ChatIDToHContact(room->thread_id);
+ hChatContact = ChatIDToHContact(room->thread_id);
ForkThread(&FacebookProto::ReadMessageWorker, (void*)hChatContact);*/
@@ -429,18 +431,19 @@ void FacebookProto::ProcessUnreadMessage(void *p)
CODE_BLOCK_CATCH
- debugLogA("***** Error processing unread messages: %s", e.what());
+ debugLogA("***** Error processing unread messages: %s", e.what());
CODE_BLOCK_END
-
- facy.handle_success("ProcessUnreadMessage");
- } else {
+
+ facy.handle_success("ProcessUnreadMessage");
+ }
+ else {
facy.handle_error("ProcessUnreadMessage");
}
offset += limit;
limit = 20; // TODO: use better limits?
-
+
threads.clear(); // TODO: if we have limit messages from one user, there may be more unread messages... continue with it... otherwise remove that threadd from threads list -- or do it in json parser? hm = allow more than "limit" unread messages to be parsed
}
}
@@ -499,17 +502,17 @@ void FacebookProto::LoadLastMessages(void *p)
facy.handle_error("LoadLastMessages");
return;
}
-
+
// Temporarily disable marking messages as read for this contact
facy.ignore_read.insert(hContact);
-CODE_BLOCK_TRY
+ CODE_BLOCK_TRY
- std::vector<facebook_message*> messages;
+ std::vector<facebook_message*> messages;
std::map<std::string, facebook_chatroom*> chatrooms;
facebook_json_parser* p = new facebook_json_parser(this);
- p->parse_thread_messages(&resp.data, &messages, &chatrooms, false, false, 20);
+ p->parse_thread_messages(&resp.data, &messages, &chatrooms, false, false);
delete p;
// TODO: do something with this, chat is loading somewhere else... (in receiveMessages method right now)
@@ -519,39 +522,39 @@ CODE_BLOCK_TRY
MCONTACT hChatContact = NULL;
ptrA users(GetChatUsers(room->thread_id.c_str()));
if (users == NULL) {
- AddChat(room->thread_id.c_str(), room->chat_name.c_str());
- hChatContact = ChatIDToHContact(room->thread_id);
- // Set thread id (TID) for later
- setTString(hChatContact, FACEBOOK_KEY_TID, room->thread_id.c_str());
-
- for (std::map<std::string, std::string>::iterator jt = room->participants.begin(); jt != room->participants.end();) {
- AddChatContact(room->thread_id.c_str(), jt->first.c_str(), jt->second.c_str());
- ++jt;
- }
+ AddChat(room->thread_id.c_str(), room->chat_name.c_str());
+ hChatContact = ChatIDToHContact(room->thread_id);
+ // Set thread id (TID) for later
+ setTString(hChatContact, FACEBOOK_KEY_TID, room->thread_id.c_str());
+
+ for (std::map<std::string, std::string>::iterator jt = room->participants.begin(); jt != room->participants.end();) {
+ AddChatContact(room->thread_id.c_str(), jt->first.c_str(), jt->second.c_str());
+ ++jt;
+ }
}
if (!hChatContact)
- hChatContact = ChatIDToHContact(room->thread_id);
+ hChatContact = ChatIDToHContact(room->thread_id);
ForkThread(&FacebookProto::ReadMessageWorker, (void*)hChatContact);
delete it->second;
it = chatrooms.erase(it);
- }
- chatrooms.clear();*/
+ }
+ chatrooms.clear();*/
bool local_timestamp = getBool(FACEBOOK_KEY_LOCAL_TIMESTAMP_UNREAD, 0);
ReceiveMessages(messages, local_timestamp, true);
debugLogA("***** Thread messages processed");
-CODE_BLOCK_CATCH
+ CODE_BLOCK_CATCH
- debugLogA("***** Error processing thread messages: %s", e.what());
+ debugLogA("***** Error processing thread messages: %s", e.what());
-CODE_BLOCK_END
+ CODE_BLOCK_END
- facy.handle_success("LoadLastMessages");
+ facy.handle_success("LoadLastMessages");
// Enable marking messages as read for this contact
facy.ignore_read.erase(hContact);
@@ -564,7 +567,7 @@ void FacebookProto::SyncThreads(void*)
{
facy.handle_entry("SyncThreads");
- if (isOffline())
+ if (isOffline())
return;
// get timestamp of last action (last message or possibly logout time)
@@ -580,14 +583,14 @@ void FacebookProto::SyncThreads(void*)
time /= 1000;
}
- if (time < (unsigned) ::time(NULL) - 24*60*60) {
- time_t last = ::time(NULL) - 24*60*60;
- timestamp = utils::conversion::to_string((void*)&last, UTILS_CONV_TIME_T) + "000";
+ if (time < (unsigned) ::time(NULL) - 24 * 60 * 60) {
+ time_t last = ::time(NULL) - 24 * 60 * 60;
+ timestamp = utils::conversion::to_string((void*)&last, UTILS_CONV_TIME_T) + "000";
ForkThread(&FacebookProto::ProcessUnreadMessages, NULL); // for older unread messages (necessary?)
}
- setString(FACEBOOK_KEY_LAST_ACTION_TIMESTAMP, utils::time::mili_timestamp().c_str());
+ setString(FACEBOOK_KEY_LAST_ACTION_TIMESTAMP, utils::time::mili_timestamp().c_str());
// receive messages from all folders by default, use hidden setting to receive only inbox messages
@@ -612,13 +615,13 @@ void FacebookProto::SyncThreads(void*)
}
-CODE_BLOCK_TRY
+ CODE_BLOCK_TRY
- std::vector<facebook_message*> messages;
+ std::vector<facebook_message*> messages;
std::map<std::string, facebook_chatroom*> chatrooms;
facebook_json_parser* p = new facebook_json_parser(this);
- p->parse_thread_messages(&resp.data, &messages, &chatrooms, false, false, 20);
+ p->parse_thread_messages(&resp.data, &messages, &chatrooms, false, false);
delete p;
@@ -627,13 +630,13 @@ CODE_BLOCK_TRY
debugLogA("***** Thread messages processed");
-CODE_BLOCK_CATCH
+ CODE_BLOCK_CATCH
- debugLogA("***** Error processing thread messages: %s", e.what());
+ debugLogA("***** Error processing thread messages: %s", e.what());
-CODE_BLOCK_END
+ CODE_BLOCK_END
- facy.handle_success("SyncThreads");
+ facy.handle_success("SyncThreads");
}
@@ -682,7 +685,7 @@ void FacebookProto::ReceiveMessages(std::vector<facebook_message*> messages, boo
std::set<MCONTACT> *hChatContacts = new std::set<MCONTACT>();
- for(std::vector<facebook_message*>::size_type i = 0; i < messages.size(); i++) {
+ for (std::vector<facebook_message*>::size_type i = 0; i < messages.size(); i++) {
DWORD timestamp = local_timestamp || !messages[i]->time ? ::time(NULL) : messages[i]->time;
if (messages[i]->isChat) {
@@ -700,7 +703,8 @@ void FacebookProto::ReceiveMessages(std::vector<facebook_message*> messages, boo
std::map<std::tstring, facebook_chatroom*>::iterator it = facy.chat_rooms.find(tthread_id);
if (it != facy.chat_rooms.end()) {
fbc = it->second;
- } else {
+ }
+ else {
// In Naseem's spam mode we ignore outgoing messages sent from other instances
if (naseemsSpamMode && !messages[i]->isIncoming) {
delete messages[i];
@@ -741,7 +745,7 @@ void FacebookProto::ReceiveMessages(std::vector<facebook_message*> messages, boo
// We don't want to save (this) message ID for chatrooms
// setString(hChatContact, FACEBOOK_KEY_MESSAGE_ID, messages[i]->message_id.c_str());
setString(FACEBOOK_KEY_LAST_ACTION_TIMESTAMP, messages[i]->timestamp.c_str());
-
+
// Save TID if not exists already
ptrA tid(getStringA(hChatContact, FACEBOOK_KEY_TID));
if (!tid || strcmp(tid, messages[i]->thread_id.c_str()))
@@ -759,7 +763,8 @@ void FacebookProto::ReceiveMessages(std::vector<facebook_message*> messages, boo
// Automatically mark message as read because chatroom doesn't support onRead event (yet)
hChatContacts->insert(hChatContact); // std::set checks duplicates at insert automatically
- } else {
+ }
+ else {
// Single-user message
debugLogA(" Got message: %s", messages[i]->message_text.c_str());
@@ -802,15 +807,16 @@ void FacebookProto::ReceiveMessages(std::vector<facebook_message*> messages, boo
recv.szMessage = const_cast<char*>(messages[i]->message_text.c_str());
recv.timestamp = timestamp;
ProtoChainRecvMsg(hContact, &recv);
- } else {
+ }
+ else {
DBEVENTINFO dbei = { 0 };
dbei.cbSize = sizeof(dbei);
-
+
if (messages[i]->type == CALL)
dbei.eventType = FACEBOOK_EVENTTYPE_CALL;
else
dbei.eventType = EVENTTYPE_MESSAGE;
-
+
dbei.flags = DBEF_UTF;
if (!messages[i]->isIncoming)
@@ -832,7 +838,8 @@ void FacebookProto::ReceiveMessages(std::vector<facebook_message*> messages, boo
if (!hChatContacts->empty()) {
ForkThread(&FacebookProto::ReadMessageWorker, (void*)hChatContacts);
- } else {
+ }
+ else {
delete hChatContacts;
}
}
@@ -859,7 +866,7 @@ void FacebookProto::ProcessMessages(void* data)
CODE_BLOCK_TRY
- std::vector< facebook_message* > messages;
+ std::vector< facebook_message* > messages;
facebook_json_parser* p = new facebook_json_parser(this);
p->parse_messages(data, &messages, &facy.notifications, inboxOnly);
@@ -875,11 +882,11 @@ void FacebookProto::ProcessMessages(void* data)
CODE_BLOCK_CATCH
- debugLogA("***** Error processing messages: %s", e.what());
+ debugLogA("***** Error processing messages: %s", e.what());
CODE_BLOCK_END
-exit:
+ exit :
delete resp;
}
@@ -922,7 +929,7 @@ void FacebookProto::ProcessNotifications(void*)
CODE_BLOCK_TRY
- facebook_json_parser* p = new facebook_json_parser(this);
+ facebook_json_parser* p = new facebook_json_parser(this);
p->parse_notifications(&(resp.data), &facy.notifications);
delete p;
@@ -932,7 +939,7 @@ void FacebookProto::ProcessNotifications(void*)
CODE_BLOCK_CATCH
- debugLogA("***** Error processing notifications: %s", e.what());
+ debugLogA("***** Error processing notifications: %s", e.what());
CODE_BLOCK_END
}
@@ -951,7 +958,7 @@ void FacebookProto::ProcessFriendRequests(void*)
facy.handle_error("friendRequests");
return;
}
-
+
// Parse it
std::string reqs = utils::text::source_get_value(&resp.data, 3, "id=\"friend_requests_section\"", "</h4>", "<h4");
@@ -964,11 +971,12 @@ void FacebookProto::ProcessFriendRequests(void*)
if ((pos2 = reqs.find("<img src=", pos)) != std::string::npos) {
req = reqs.substr(pos, pos2 - pos);
pos = pos2 + 9;
- } else {
+ }
+ else {
req = reqs.substr(pos);
last = true;
}
-
+
std::string get = utils::text::source_get_value(&req, 3, "<form", "action=\"", "\">");
std::string time = utils::text::source_get_value2(&get, "seenrequesttime=", "&\"");
std::string reason = utils::text::remove_html(utils::text::source_get_value(&req, 3, "<span", ">", "</span>"));
@@ -989,15 +997,15 @@ void FacebookProto::ProcessFriendRequests(void*)
//blob is: uin(DWORD), hContact(HANDLE), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ), reason(ASCIIZ)
//blob is: 0(DWORD), hContact(HANDLE), nick(ASCIIZ), ""(ASCIIZ), ""(ASCIIZ), email(ASCIIZ), reason(ASCIIZ)
- DBEVENTINFO dbei = {0};
+ DBEVENTINFO dbei = { 0 };
dbei.cbSize = sizeof(DBEVENTINFO);
dbei.szModule = m_szModuleName;
dbei.timestamp = ::time(NULL);
dbei.flags = DBEF_UTF;
dbei.eventType = EVENTTYPE_AUTHREQUEST;
- dbei.cbBlob = (DWORD)(sizeof(DWORD)*2 + fbu->real_name.length() + fbu->user_id.length() + reason.length() + 5);
-
- PBYTE pCurBlob = dbei.pBlob = (PBYTE) mir_alloc(dbei.cbBlob);
+ dbei.cbBlob = (DWORD)(sizeof(DWORD) * 2 + fbu->real_name.length() + fbu->user_id.length() + reason.length() + 5);
+
+ PBYTE pCurBlob = dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob);
*(PDWORD)pCurBlob = 0; pCurBlob += sizeof(DWORD); // UID
*(PDWORD)pCurBlob = (DWORD)hContact; pCurBlob += sizeof(DWORD); // Contact Handle
strcpy((char*)pCurBlob, fbu->real_name.data()); pCurBlob += fbu->real_name.length() + 1; // Nickname
@@ -1006,13 +1014,15 @@ void FacebookProto::ProcessFriendRequests(void*)
strcpy((char*)pCurBlob, fbu->user_id.data()); pCurBlob += fbu->user_id.length() + 1; // E-mail (we use it for string ID)
strcpy((char*)pCurBlob, reason.data()); pCurBlob += reason.length() + 1; // Reason (we use it for info about common friends)
- db_event_add(0, &dbei);
+ db_event_add(0, &dbei);
debugLogA(" (New) Friendship request from: %s (%s) [%s]", fbu->real_name.c_str(), fbu->user_id.c_str(), time.c_str());
- } else {
+ }
+ else {
debugLogA(" (Old) Friendship request from: %s (%s) [%s]", fbu->real_name.c_str(), fbu->user_id.c_str(), time.c_str());
}
- } else {
+ }
+ else {
debugLogA(" !!! Wrong friendship request");
debugLogA("%s", req.c_str());
}
@@ -1021,7 +1031,7 @@ void FacebookProto::ProcessFriendRequests(void*)
facy.handle_success("friendRequests");
}
-void FacebookProto::ProcessFeeds(void* data)
+void FacebookProto::ProcessFeeds(void*)
{
if (!isOnline())
return;
@@ -1038,7 +1048,7 @@ void FacebookProto::ProcessFeeds(void* data)
CODE_BLOCK_TRY
- debugLogA("***** Starting processing feeds");
+ debugLogA("***** Starting processing feeds");
std::vector< facebook_newsfeed* > news;
@@ -1051,11 +1061,11 @@ void FacebookProto::ProcessFeeds(void* data)
debugLogA(" Last feeds update (old): %d", facy.last_feeds_update_);
while ((pos = resp.data.find("<div class=\"userContentWrapper", pos)) != std::string::npos && limit <= 25)
- {
+ {
/*std::string::size_type pos2 = resp.data.find("<div class=\"userContentWrapper", pos+5);
if (pos2 == std::string::npos)
- pos2 = resp.data.length();
-
+ pos2 = resp.data.length();
+
std::string post = resp.data.substr(pos, pos2 - pos);*/
std::string post = resp.data.substr(pos, resp.data.find("</form>", pos) - pos);
pos += 5;
@@ -1084,7 +1094,7 @@ void FacebookProto::ProcessFeeds(void* data)
if (ttime > new_time) {
new_time = ttime; // remember newest time from all these posts
debugLogA(" - Newsfeed time: %d (new)", ttime);
- }
+ }
else if (ttime <= facy.last_feeds_update_) {
debugLogA(" - Newsfeed time: %d (ignored)", ttime);
continue; // ignore posts older than newest post of previous check
@@ -1109,7 +1119,8 @@ void FacebookProto::ProcessFeeds(void* data)
if (pos2 != std::string::npos) {
utils::text::replace_first(&post_header, "‎", " → ");
- } else {
+ }
+ else {
pos2 = post_header.find("</a></");
if (pos2 != std::string::npos) {
pos2 += 4;
@@ -1135,12 +1146,12 @@ void FacebookProto::ProcessFeeds(void* data)
nf->title = utils::text::trim(
utils::text::html_entities_decode(
- utils::text::remove_html(post_header)));
+ utils::text::remove_html(post_header)));
nf->user_id = utils::text::source_get_value(&post_header, 2, "user.php?id=", "&amp;");
-
+
nf->link = utils::text::html_entities_decode(post_link);
-
+
// Check if we don't want to show ads posts
bool filtered = filterAds && (nf->link.find("/about/ads") != std::string::npos
|| post.find("class=\"uiStreamSponsoredLink\"") != std::string::npos
@@ -1148,8 +1159,8 @@ void FacebookProto::ProcessFeeds(void* data)
nf->text = utils::text::trim(
utils::text::html_entities_decode(
- utils::text::remove_html(
- utils::text::edit_html(post_message))));
+ utils::text::remove_html(
+ 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"));
@@ -1167,10 +1178,10 @@ void FacebookProto::ProcessFeeds(void* data)
debugLogA(" Last feeds update (new): %d", new_time);
- for(std::vector<facebook_newsfeed*>::size_type i=0; i<news.size(); i++)
+ for (std::vector<facebook_newsfeed*>::size_type i = 0; i < news.size(); i++)
{
- ptrT tszTitle( mir_utf8decodeT(news[i]->title.c_str()));
- ptrT tszText( mir_utf8decodeT(news[i]->text.c_str()));
+ ptrT tszTitle(mir_utf8decodeT(news[i]->title.c_str()));
+ ptrT tszText(mir_utf8decodeT(news[i]->text.c_str()));
// Truncate text of newsfeed when it's too long
if (_tcslen(tszText) > MAX_NEWSFEED_LEN) {
@@ -1192,11 +1203,11 @@ void FacebookProto::ProcessFeeds(void* data)
CODE_BLOCK_CATCH
- debugLogA("***** Error processing feeds: %s", e.what());
+ debugLogA("***** Error processing feeds: %s", e.what());
CODE_BLOCK_END
- facy.handle_success("feeds");
+ facy.handle_success("feeds");
}
void FacebookProto::ProcessPages(void*)
@@ -1298,17 +1309,17 @@ void FacebookProto::SearchAckThread(void *targ)
if (id.empty() || id == facy.self_.user_id)
continue;
- ptrT tid( mir_utf8decodeT(id.c_str()));
- ptrT tname( mir_utf8decodeT(utils::text::html_entities_decode(name).c_str()));
- ptrT tsurname( mir_utf8decodeT(utils::text::html_entities_decode(surname).c_str()));
- ptrT tnick( mir_utf8decodeT(utils::text::html_entities_decode(nick).c_str()));
- ptrT tcommon( mir_utf8decodeT(utils::text::html_entities_decode(common).c_str()));
+ ptrT tid(mir_utf8decodeT(id.c_str()));
+ ptrT tname(mir_utf8decodeT(utils::text::html_entities_decode(name).c_str()));
+ ptrT tsurname(mir_utf8decodeT(utils::text::html_entities_decode(surname).c_str()));
+ ptrT tnick(mir_utf8decodeT(utils::text::html_entities_decode(nick).c_str()));
+ ptrT tcommon(mir_utf8decodeT(utils::text::html_entities_decode(common).c_str()));
- PROTOSEARCHRESULT isr = {0};
+ PROTOSEARCHRESULT isr = { 0 };
isr.cbSize = sizeof(isr);
isr.flags = PSR_TCHAR;
- isr.id = tid;
- isr.nick = tnick;
+ isr.id = tid;
+ isr.nick = tnick;
isr.firstName = tname;
isr.lastName = tsurname;
isr.email = tcommon;
@@ -1349,7 +1360,7 @@ void FacebookProto::SearchIdAckThread(void *targ)
if (resp.code == HTTP_CODE_OK)
{
std::string about = utils::text::source_get_value(&resp.data, 2, "<div id=\"root\"", "</body>");
-
+
std::string id = utils::text::source_get_value2(&about, ";id=", "&\"");
if (id.empty())
id = utils::text::source_get_value2(&about, "?bid=", "&\"");
@@ -1364,11 +1375,11 @@ void FacebookProto::SearchIdAckThread(void *targ)
// ignore self contact and empty ids
if (!id.empty() && id != facy.self_.user_id){
- ptrT tid( mir_utf8decodeT(id.c_str()));
- ptrT tname( mir_utf8decodeT(name.c_str()));
- ptrT tsurname( mir_utf8decodeT(surname.c_str()));
+ ptrT tid(mir_utf8decodeT(id.c_str()));
+ ptrT tname(mir_utf8decodeT(name.c_str()));
+ ptrT tsurname(mir_utf8decodeT(surname.c_str()));
- PROTOSEARCHRESULT isr = {0};
+ PROTOSEARCHRESULT isr = { 0 };
isr.cbSize = sizeof(isr);
isr.flags = PSR_TCHAR;
isr.id = tid;
@@ -1380,9 +1391,9 @@ void FacebookProto::SearchIdAckThread(void *targ)
}
}
- ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, targ, 0);
+ ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, targ, 0);
- facy.handle_success("searchIdAckThread");
+ facy.handle_success("searchIdAckThread");
mir_free(targ);
mir_free(arg);
diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp
index 4fdc637bed..94fc964b18 100644
--- a/protocols/FacebookRM/src/proto.cpp
+++ b/protocols/FacebookRM/src/proto.cpp
@@ -22,8 +22,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "common.h"
-FacebookProto::FacebookProto(const char* proto_name,const TCHAR* username) :
- PROTO<FacebookProto>(proto_name, username)
+FacebookProto::FacebookProto(const char* proto_name, const TCHAR* username) :
+PROTO<FacebookProto>(proto_name, username)
{
facy.parent = this;
@@ -38,34 +38,34 @@ FacebookProto::FacebookProto(const char* proto_name,const TCHAR* username) :
m_invisible = false;
m_signingOut = false;
-
+
// Load custom locale, if set
- ptrA locale( getStringA(FACEBOOK_KEY_LOCALE));
+ ptrA locale(getStringA(FACEBOOK_KEY_LOCALE));
if (locale != NULL)
m_locale = locale;
- CreateProtoService(PS_CREATEACCMGRUI, &FacebookProto::SvcCreateAccMgrUI);
- CreateProtoService(PS_GETMYAWAYMSG, &FacebookProto::GetMyAwayMsg);
- CreateProtoService(PS_GETMYAVATART, &FacebookProto::GetMyAvatar);
- CreateProtoService(PS_GETAVATARINFOT, &FacebookProto::GetAvatarInfo);
- CreateProtoService(PS_GETAVATARCAPS, &FacebookProto::GetAvatarCaps);
- CreateProtoService(PS_GETUNREADEMAILCOUNT, &FacebookProto::GetNotificationsCount);
+ CreateProtoService(PS_CREATEACCMGRUI, &FacebookProto::SvcCreateAccMgrUI);
+ CreateProtoService(PS_GETMYAWAYMSG, &FacebookProto::GetMyAwayMsg);
+ CreateProtoService(PS_GETMYAVATART, &FacebookProto::GetMyAvatar);
+ CreateProtoService(PS_GETAVATARINFOT, &FacebookProto::GetAvatarInfo);
+ CreateProtoService(PS_GETAVATARCAPS, &FacebookProto::GetAvatarCaps);
+ CreateProtoService(PS_GETUNREADEMAILCOUNT, &FacebookProto::GetNotificationsCount);
- CreateProtoService(PS_JOINCHAT, &FacebookProto::OnJoinChat);
- CreateProtoService(PS_LEAVECHAT, &FacebookProto::OnLeaveChat);
+ CreateProtoService(PS_JOINCHAT, &FacebookProto::OnJoinChat);
+ CreateProtoService(PS_LEAVECHAT, &FacebookProto::OnLeaveChat);
- CreateProtoService("/Mind", &FacebookProto::OnMind);
- CreateProtoService("/VisitProfile", &FacebookProto::VisitProfile);
- CreateProtoService("/VisitNotifications", &FacebookProto::VisitNotifications);
+ CreateProtoService("/Mind", &FacebookProto::OnMind);
+ CreateProtoService("/VisitProfile", &FacebookProto::VisitProfile);
+ CreateProtoService("/VisitNotifications", &FacebookProto::VisitNotifications);
HookProtoEvent(ME_CLIST_PREBUILDSTATUSMENU, &FacebookProto::OnBuildStatusMenu);
- HookProtoEvent(ME_OPT_INITIALISE, &FacebookProto::OnOptionsInit);
- HookProtoEvent(ME_IDLE_CHANGED, &FacebookProto::OnIdleChanged);
- HookProtoEvent(ME_TTB_MODULELOADED, &FacebookProto::OnToolbarInit);
- HookProtoEvent(ME_GC_EVENT, &FacebookProto::OnGCEvent);
- HookProtoEvent(ME_GC_BUILDMENU, &FacebookProto::OnGCMenuHook);
- HookProtoEvent(ME_DB_EVENT_MARKED_READ, &FacebookProto::OnDbEventRead);
- HookProtoEvent(ME_MSG_WINDOWEVENT, &FacebookProto::OnProcessSrmmEvent);
+ HookProtoEvent(ME_OPT_INITIALISE, &FacebookProto::OnOptionsInit);
+ HookProtoEvent(ME_IDLE_CHANGED, &FacebookProto::OnIdleChanged);
+ HookProtoEvent(ME_TTB_MODULELOADED, &FacebookProto::OnToolbarInit);
+ HookProtoEvent(ME_GC_EVENT, &FacebookProto::OnGCEvent);
+ HookProtoEvent(ME_GC_BUILDMENU, &FacebookProto::OnGCMenuHook);
+ HookProtoEvent(ME_DB_EVENT_MARKED_READ, &FacebookProto::OnDbEventRead);
+ HookProtoEvent(ME_MSG_WINDOWEVENT, &FacebookProto::OnProcessSrmmEvent);
db_set_resident(m_szModuleName, "Status");
db_set_resident(m_szModuleName, "IdleTS");
@@ -77,7 +77,7 @@ FacebookProto::FacebookProto(const char* proto_name,const TCHAR* username) :
// Create standard network connection
TCHAR descr[512];
- NETLIBUSER nlu = {sizeof(nlu)};
+ NETLIBUSER nlu = { sizeof(nlu) };
nlu.flags = NUF_INCOMING | NUF_OUTGOING | NUF_HTTPCONNS | NUF_TCHAR;
nlu.szSettingsModule = m_szModuleName;
mir_sntprintf(descr, SIZEOF(descr), TranslateT("%s server connection"), m_tszUserName);
@@ -86,7 +86,7 @@ FacebookProto::FacebookProto(const char* proto_name,const TCHAR* username) :
if (m_hNetlibUser == NULL)
MessageBox(NULL, TranslateT("Unable to get Netlib connection for Facebook"), m_tszUserName, MB_OK);
- facy.set_handle(m_hNetlibUser);
+ facy.set_handle(m_hNetlibUser);
// Set all contacts offline -- in case we crashed
SetAllContactStatuses(ID_STATUS_OFFLINE);
@@ -108,8 +108,8 @@ FacebookProto::~FacebookProto()
// Uninit popup classes
for (std::vector<HANDLE>::size_type i = 0; i < popupClasses.size(); i++)
Popup_UnregisterClass(popupClasses[i]);
- popupClasses.clear();
-
+ popupClasses.clear();
+
Netlib_CloseHandle(m_hNetlibUser);
WaitForSingleObject(signon_lock_, IGNORE);
@@ -131,9 +131,9 @@ FacebookProto::~FacebookProto()
//////////////////////////////////////////////////////////////////////////////
-DWORD_PTR FacebookProto::GetCaps(int type, MCONTACT hContact)
+DWORD_PTR FacebookProto::GetCaps(int type, MCONTACT)
{
- switch(type)
+ switch (type)
{
case PFLAGNUM_1:
{
@@ -160,7 +160,7 @@ DWORD_PTR FacebookProto::GetCaps(int type, MCONTACT hContact)
case PFLAG_UNIQUEIDTEXT:
return (DWORD_PTR) "Facebook ID";
case PFLAG_UNIQUEIDSETTING:
- return (DWORD_PTR) FACEBOOK_KEY_ID;
+ return (DWORD_PTR)FACEBOOK_KEY_ID;
}
return 0;
}
@@ -206,7 +206,7 @@ int FacebookProto::SetStatus(int new_status)
return 0;
}
-int FacebookProto::SetAwayMsg(int status, const PROTOCHAR *msg)
+int FacebookProto::SetAwayMsg(int, const PROTOCHAR *msg)
{
if (!msg) {
last_status_msg_.clear();
@@ -230,7 +230,8 @@ void FacebookProto::SetAwayMsgWorker(void *p)
status_data *data = static_cast<status_data*>(p);
facy.post_status(data);
delete data;
- } else if (!last_status_msg_.empty()) {
+ }
+ else if (!last_status_msg_.empty()) {
status_data data;
data.text = last_status_msg_;
data.privacy = facy.get_privacy_type();
@@ -261,15 +262,15 @@ HANDLE FacebookProto::SearchByEmail(const PROTOCHAR* email)
HANDLE FacebookProto::SearchByName(const PROTOCHAR* nick, const PROTOCHAR* firstName, const PROTOCHAR* lastName)
{
TCHAR arg[200];
- mir_sntprintf (arg, SIZEOF(arg), _T("%s %s %s"), nick, firstName, lastName);
+ mir_sntprintf(arg, SIZEOF(arg), _T("%s %s %s"), nick, firstName, lastName);
return SearchByEmail(arg); // Facebook is using one search method for everything (except IDs)
}
MCONTACT FacebookProto::AddToList(int flags, PROTOSEARCHRESULT* psr)
{
- ptrA id( mir_t2a_cp(psr->id, CP_UTF8));
- ptrA name( mir_t2a_cp(psr->firstName, CP_UTF8));
- ptrA surname( mir_t2a_cp(psr->lastName, CP_UTF8));
+ ptrA id(mir_t2a_cp(psr->id, CP_UTF8));
+ ptrA name(mir_t2a_cp(psr->firstName, CP_UTF8));
+ ptrA surname(mir_t2a_cp(psr->lastName, CP_UTF8));
if (id == NULL)
return NULL;
@@ -300,7 +301,7 @@ MCONTACT FacebookProto::AddToList(int flags, PROTOSEARCHRESULT* psr)
return hContact;
}
-int FacebookProto::AuthRequest(MCONTACT hContact,const PROTOCHAR *message)
+int FacebookProto::AuthRequest(MCONTACT hContact, const PROTOCHAR *)
{
return RequestFriendship(hContact, NULL);
}
@@ -317,7 +318,7 @@ int FacebookProto::Authorize(HANDLE hDbEvent)
return ApproveFriendship(hContact, NULL);
}
-int FacebookProto::AuthDeny(HANDLE hDbEvent, const PROTOCHAR *reason)
+int FacebookProto::AuthDeny(HANDLE hDbEvent, const PROTOCHAR *)
{
if (!hDbEvent || isOffline())
return 1;
@@ -329,12 +330,12 @@ int FacebookProto::AuthDeny(HANDLE hDbEvent, const PROTOCHAR *reason)
return DenyFriendship(hContact, NULL);
}
-int FacebookProto::GetInfo(MCONTACT hContact, int infoType)
+int FacebookProto::GetInfo(MCONTACT hContact, int)
{
ptrA user_id(getStringA(hContact, FACEBOOK_KEY_ID));
if (user_id == NULL)
return 1;
-
+
facebook_user fbu;
fbu.user_id = user_id;
@@ -361,7 +362,7 @@ int FacebookProto::GetInfo(MCONTACT hContact, int infoType)
//////////////////////////////////////////////////////////////////////////////
// SERVICES
-INT_PTR FacebookProto::GetMyAwayMsg(WPARAM wParam, LPARAM lParam)
+INT_PTR FacebookProto::GetMyAwayMsg(WPARAM, LPARAM lParam)
{
ptrT statusMsg(getTStringA("StatusMsg"));
if (statusMsg == NULL || statusMsg[0] == '\0')
@@ -370,7 +371,7 @@ INT_PTR FacebookProto::GetMyAwayMsg(WPARAM wParam, LPARAM lParam)
return (lParam & SGMA_UNICODE) ? (INT_PTR)mir_t2u(statusMsg) : (INT_PTR)mir_t2a(statusMsg);
}
-int FacebookProto::OnIdleChanged(WPARAM wParam, LPARAM lParam)
+int FacebookProto::OnIdleChanged(WPARAM, LPARAM lParam)
{
if (m_iStatus == ID_STATUS_INVISIBLE || m_iStatus <= ID_STATUS_OFFLINE)
return 0;
@@ -392,7 +393,7 @@ int FacebookProto::OnIdleChanged(WPARAM wParam, LPARAM lParam)
return 0;
}
-INT_PTR FacebookProto::GetNotificationsCount(WPARAM wParam, LPARAM lParam)
+INT_PTR FacebookProto::GetNotificationsCount(WPARAM, LPARAM)
{
if (isOffline())
return 0;
@@ -404,19 +405,19 @@ INT_PTR FacebookProto::GetNotificationsCount(WPARAM wParam, LPARAM lParam)
int FacebookProto::OnEvent(PROTOEVENTTYPE event, WPARAM wParam, LPARAM lParam)
{
- switch(event)
+ switch (event)
{
case EV_PROTO_ONLOAD:
- return OnModulesLoaded(wParam,lParam);
+ return OnModulesLoaded(wParam, lParam);
case EV_PROTO_ONEXIT:
- return OnPreShutdown(wParam,lParam);
+ return OnPreShutdown(wParam, lParam);
case EV_PROTO_ONOPTIONS:
- return OnOptionsInit(wParam,lParam);
+ return OnOptionsInit(wParam, lParam);
case EV_PROTO_ONCONTACTDELETED:
- return OnContactDeleted(wParam,lParam);
+ return OnContactDeleted(wParam, lParam);
}
return 1;
@@ -425,13 +426,13 @@ int FacebookProto::OnEvent(PROTOEVENTTYPE event, WPARAM wParam, LPARAM lParam)
//////////////////////////////////////////////////////////////////////////////
// EVENTS
-INT_PTR FacebookProto::SvcCreateAccMgrUI(WPARAM wParam, LPARAM lParam)
+INT_PTR FacebookProto::SvcCreateAccMgrUI(WPARAM, LPARAM lParam)
{
- return (INT_PTR)CreateDialogParam(g_hInstance,MAKEINTRESOURCE(IDD_FACEBOOKACCOUNT),
- (HWND)lParam, FBAccountProc, (LPARAM)this);
+ return (INT_PTR)CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_FACEBOOKACCOUNT),
+ (HWND)lParam, FBAccountProc, (LPARAM)this);
}
-int FacebookProto::OnModulesLoaded(WPARAM wParam, LPARAM lParam)
+int FacebookProto::OnModulesLoaded(WPARAM, LPARAM)
{
// Register group chat
GCREGISTER gcr = { sizeof(gcr) };
@@ -446,43 +447,43 @@ int FacebookProto::OnModulesLoaded(WPARAM wParam, LPARAM lParam)
return 0;
}
-int FacebookProto::OnPreShutdown(WPARAM wParam, LPARAM lParam)
+int FacebookProto::OnPreShutdown(WPARAM, LPARAM)
{
SetStatus(ID_STATUS_OFFLINE);
return 0;
}
-int FacebookProto::OnOptionsInit(WPARAM wParam, LPARAM lParam)
+int FacebookProto::OnOptionsInit(WPARAM wParam, LPARAM)
{
- OPTIONSDIALOGPAGE odp = {sizeof(odp)};
- odp.hInstance = g_hInstance;
- odp.ptszTitle = m_tszUserName;
+ OPTIONSDIALOGPAGE odp = { sizeof(odp) };
+ odp.hInstance = g_hInstance;
+ odp.ptszTitle = m_tszUserName;
odp.dwInitParam = LPARAM(this);
- odp.flags = ODPF_BOLDGROUPS | ODPF_TCHAR | ODPF_DONTTRANSLATE;
+ odp.flags = ODPF_BOLDGROUPS | ODPF_TCHAR | ODPF_DONTTRANSLATE;
- odp.position = 271828;
- odp.ptszGroup = LPGENT("Network");
- odp.ptszTab = LPGENT("Account");
+ odp.position = 271828;
+ odp.ptszGroup = LPGENT("Network");
+ odp.ptszTab = LPGENT("Account");
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS);
- odp.pfnDlgProc = FBOptionsProc;
+ odp.pfnDlgProc = FBOptionsProc;
Options_AddPage(wParam, &odp);
- odp.position = 271829;
- odp.ptszTab = LPGENT("Events");
+ odp.position = 271829;
+ odp.ptszTab = LPGENT("Events");
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS_EVENTS);
- odp.pfnDlgProc = FBOptionsEventsProc;
+ odp.pfnDlgProc = FBOptionsEventsProc;
Options_AddPage(wParam, &odp);
- odp.position = 271830;
- odp.ptszTab = LPGENT("Statuses");
+ odp.position = 271830;
+ odp.ptszTab = LPGENT("Statuses");
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS_STATUSES);
- odp.pfnDlgProc = FBOptionsStatusesProc;
+ odp.pfnDlgProc = FBOptionsStatusesProc;
Options_AddPage(wParam, &odp);
- odp.position = 271831;
- odp.ptszTab = LPGENT("Messaging");
+ odp.position = 271831;
+ odp.ptszTab = LPGENT("Messaging");
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS_MESSAGING);
- odp.pfnDlgProc = FBOptionsMessagingProc;
+ odp.pfnDlgProc = FBOptionsMessagingProc;
Options_AddPage(wParam, &odp);
return 0;
}
@@ -503,7 +504,7 @@ int FacebookProto::OnToolbarInit(WPARAM, LPARAM)
return 0;
}
-INT_PTR FacebookProto::OnMind(WPARAM wParam, LPARAM lParam)
+INT_PTR FacebookProto::OnMind(WPARAM wParam, LPARAM)
{
if (!isOnline())
return 1;
@@ -513,13 +514,14 @@ INT_PTR FacebookProto::OnMind(WPARAM wParam, LPARAM lParam)
ptrA id(getStringA(hContact, FACEBOOK_KEY_ID));
if (!id)
return 1;
-
+
wall_data *wall = new wall_data();
wall->user_id = id;
wall->isPage = false;
if (wall->user_id == facy.self_.user_id) {
wall->title = _tcsdup(TranslateT("Own wall"));
- } else
+ }
+ else
wall->title = getTStringA(hContact, FACEBOOK_KEY_NICK);
post_status_data *data = new post_status_data(this, wall);
@@ -529,14 +531,14 @@ INT_PTR FacebookProto::OnMind(WPARAM wParam, LPARAM lParam)
data->walls.push_back(new wall_data(iter->first, mir_utf8decodeT(iter->second.c_str()), true));
}
}
-
+
HWND hDlg = CreateDialogParam(g_hInstance, MAKEINTRESOURCE(IDD_MIND), (HWND)0, FBMindProc, reinterpret_cast<LPARAM>(data));
ShowWindow(hDlg, SW_SHOW);
return 0;
}
-int FacebookProto::OnDbEventRead(WPARAM wParam, LPARAM lParam)
+int FacebookProto::OnDbEventRead(WPARAM wParam, LPARAM)
{
MCONTACT hContact = (MCONTACT)wParam;
@@ -562,7 +564,8 @@ int FacebookProto::OnProcessSrmmEvent(WPARAM, LPARAM lParam)
if (event->uType == MSG_WINDOW_EVT_OPENING) {
// Set statusbar to "Message read" time (if present)
MessageRead(event->hContact);
- } else if (event->uType == MSG_WINDOW_EVT_OPEN) {
+ }
+ else if (event->uType == MSG_WINDOW_EVT_OPEN) {
// Check if we have enabled loading messages on open window
if (!getBool(FACEBOOK_KEY_MESSAGES_ON_OPEN, DEFAULT_MESSAGES_ON_OPEN) || isChatRoom(event->hContact))
return 0;
@@ -603,7 +606,7 @@ INT_PTR FacebookProto::RefreshBuddyList(WPARAM, LPARAM)
}
-INT_PTR FacebookProto::VisitProfile(WPARAM wParam,LPARAM lParam)
+INT_PTR FacebookProto::VisitProfile(WPARAM wParam, LPARAM)
{
MCONTACT hContact = MCONTACT(wParam);
@@ -613,7 +616,8 @@ INT_PTR FacebookProto::VisitProfile(WPARAM wParam,LPARAM lParam)
if (val != NULL) {
// Homepage link already present, get it
url = val;
- } else {
+ }
+ else {
// No homepage link, create and save it
val = getStringA(hContact, FACEBOOK_KEY_ID);
if (val != NULL) {
@@ -626,7 +630,7 @@ INT_PTR FacebookProto::VisitProfile(WPARAM wParam,LPARAM lParam)
return 0;
}
-INT_PTR FacebookProto::VisitFriendship(WPARAM wParam,LPARAM lParam)
+INT_PTR FacebookProto::VisitFriendship(WPARAM wParam, LPARAM)
{
MCONTACT hContact = MCONTACT(wParam);
@@ -645,7 +649,7 @@ INT_PTR FacebookProto::VisitFriendship(WPARAM wParam,LPARAM lParam)
return 0;
}
-INT_PTR FacebookProto::VisitConversation(WPARAM wParam, LPARAM lParam)
+INT_PTR FacebookProto::VisitConversation(WPARAM wParam, LPARAM)
{
MCONTACT hContact = MCONTACT(wParam);
@@ -663,23 +667,23 @@ INT_PTR FacebookProto::VisitConversation(WPARAM wParam, LPARAM lParam)
return 0;
}
-INT_PTR FacebookProto::VisitNotifications(WPARAM wParam, LPARAM lParam)
+INT_PTR FacebookProto::VisitNotifications(WPARAM, LPARAM)
{
/*bool useChatRoom = getBool(FACEBOOK_KEY_NOTIFICATIONS_CHATROOM, DEFAULT_NOTIFICATIONS_CHATROOM);
if (useChatRoom) {
- GCDEST gcd = { m_szModuleName, _T(FACEBOOK_NOTIFICATIONS_CHATROOM), GC_EVENT_CONTROL };
- GCEVENT gce = { sizeof(gce), &gcd };
- CallServiceSync(MS_GC_EVENT, WINDOW_VISIBLE, reinterpret_cast<LPARAM>(&gce));
+ GCDEST gcd = { m_szModuleName, _T(FACEBOOK_NOTIFICATIONS_CHATROOM), GC_EVENT_CONTROL };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ CallServiceSync(MS_GC_EVENT, WINDOW_VISIBLE, reinterpret_cast<LPARAM>(&gce));
}
else {*/
- OpenUrl(FACEBOOK_URL_NOTIFICATIONS);
+ OpenUrl(FACEBOOK_URL_NOTIFICATIONS);
/*}*/
return 0;
}
-INT_PTR FacebookProto::Poke(WPARAM wParam,LPARAM lParam)
+INT_PTR FacebookProto::Poke(WPARAM wParam, LPARAM)
{
if (wParam == NULL || isOffline())
return 1;
@@ -694,7 +698,7 @@ INT_PTR FacebookProto::Poke(WPARAM wParam,LPARAM lParam)
return 0;
}
-INT_PTR FacebookProto::CancelFriendship(WPARAM wParam,LPARAM lParam)
+INT_PTR FacebookProto::CancelFriendship(WPARAM wParam, LPARAM lParam)
{
if (wParam == NULL || isOffline())
return 1;
@@ -710,12 +714,12 @@ INT_PTR FacebookProto::CancelFriendship(WPARAM wParam,LPARAM lParam)
ptrT tname(getTStringA(hContact, FACEBOOK_KEY_NICK));
if (tname == NULL)
tname = getTStringA(hContact, FACEBOOK_KEY_ID);
-
+
if (tname == NULL)
return 1;
TCHAR tstr[256];
- mir_sntprintf(tstr,SIZEOF(tstr),TranslateT("Do you want to cancel your friendship with '%s'?"), tname);
+ mir_sntprintf(tstr, SIZEOF(tstr), TranslateT("Do you want to cancel your friendship with '%s'?"), tname);
if (MessageBox(0, tstr, m_tszUserName, MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2) == IDYES) {
ptrA id(getStringA(hContact, FACEBOOK_KEY_ID));
@@ -736,7 +740,7 @@ INT_PTR FacebookProto::CancelFriendship(WPARAM wParam,LPARAM lParam)
return 0;
}
-INT_PTR FacebookProto::RequestFriendship(WPARAM wParam,LPARAM lParam)
+INT_PTR FacebookProto::RequestFriendship(WPARAM wParam, LPARAM)
{
if (wParam == NULL || isOffline())
return 1;
@@ -751,7 +755,7 @@ INT_PTR FacebookProto::RequestFriendship(WPARAM wParam,LPARAM lParam)
return 0;
}
-INT_PTR FacebookProto::ApproveFriendship(WPARAM wParam,LPARAM lParam)
+INT_PTR FacebookProto::ApproveFriendship(WPARAM wParam, LPARAM)
{
if (wParam == NULL || isOffline())
return 1;
@@ -762,7 +766,7 @@ INT_PTR FacebookProto::ApproveFriendship(WPARAM wParam,LPARAM lParam)
return 0;
}
-INT_PTR FacebookProto::DenyFriendship(WPARAM wParam, LPARAM lParam)
+INT_PTR FacebookProto::DenyFriendship(WPARAM wParam, LPARAM)
{
if (wParam == NULL || isOffline())
return 1;
@@ -774,7 +778,7 @@ INT_PTR FacebookProto::DenyFriendship(WPARAM wParam, LPARAM lParam)
return 0;
}
-INT_PTR FacebookProto::OnCancelFriendshipRequest(WPARAM wParam,LPARAM lParam)
+INT_PTR FacebookProto::OnCancelFriendshipRequest(WPARAM wParam, LPARAM)
{
if (wParam == NULL || isOffline())
return 1;
@@ -789,7 +793,7 @@ MCONTACT FacebookProto::HContactFromAuthEvent(HANDLE hEvent)
{
DWORD body[2];
DBEVENTINFO dbei = { sizeof(dbei) };
- dbei.cbBlob = sizeof(DWORD)*2;
+ dbei.cbBlob = sizeof(DWORD) * 2;
dbei.pBlob = (PBYTE)&body;
if (db_event_get(hEvent, &dbei))
@@ -809,7 +813,7 @@ void FacebookProto::OpenUrlThread(void *p) {
return;
open_url *data = static_cast<open_url*>(p);
-
+
ShellExecute(NULL, _T("open"), data->browser, data->url, NULL, SW_SHOWDEFAULT);
delete data;
@@ -843,7 +847,7 @@ std::string FacebookProto::PrepareUrl(std::string url) {
void FacebookProto::OpenUrl(std::string url)
{
url = PrepareUrl(url);
- ptrT data( mir_utf8decodeT(url.c_str()));
+ ptrT data(mir_utf8decodeT(url.c_str()));
// Check if there is user defined browser for opening links
ptrT browser(getTStringA(FACEBOOK_KEY_OPEN_URL_BROWSER));
@@ -881,7 +885,7 @@ void FacebookProto::ReadNotificationWorker(void *p)
*/
LRESULT CALLBACK PopupDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- switch(message)
+ switch (message)
{
case WM_COMMAND:
case WM_CONTEXTMENU:
@@ -918,9 +922,9 @@ LRESULT CALLBACK PopupDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lPa
* Popup classes initialization
*/
void FacebookProto::InitPopups()
-{
+{
POPUPCLASS ppc = { sizeof(ppc) };
- ppc.flags = PCF_TCHAR;
+ ppc.flags = PCF_TCHAR;
ppc.PluginWindowProc = PopupDlgProc;
ppc.lParam = APF_RETURN_HWND;
@@ -1018,13 +1022,13 @@ void FacebookProto::MessageRead(MCONTACT hContact)
{
/*std::map<MCONTACT, time_t>::iterator it = facy.readers.find(hContact);
if (it == facy.readers.end())
- return;*/
+ return;*/
// We may use this instead of checing map as we have this info already in memory (this value is resident)
time_t time = getDword(hContact, FACEBOOK_KEY_MESSAGE_READ, 0);
if (!time)
return;
-
+
TCHAR ttime[64];
_tcsftime(ttime, SIZEOF(ttime), _T("%X"), localtime(&time));
@@ -1032,6 +1036,6 @@ void FacebookProto::MessageRead(MCONTACT hContact)
st.cbSize = sizeof(st);
st.hIcon = Skin_GetIconByHandle(GetIconHandle("read"));
mir_sntprintf(st.tszText, SIZEOF(st.tszText), TranslateT("Message read: %s"), ttime);
-
+
CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)hContact, (LPARAM)&st);
}
diff --git a/protocols/FacebookRM/src/stubs.cpp b/protocols/FacebookRM/src/stubs.cpp
index e53960636f..a52baef931 100644
--- a/protocols/FacebookRM/src/stubs.cpp
+++ b/protocols/FacebookRM/src/stubs.cpp
@@ -22,82 +22,82 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "common.h"
-MCONTACT FacebookProto::AddToListByEvent(int flags,int iContact,HANDLE hDbEvent)
+MCONTACT FacebookProto::AddToListByEvent(int, int, HANDLE)
{
return NULL;
}
-int FacebookProto::AuthRecv(MCONTACT hContact,PROTORECVEVENT *)
+int FacebookProto::AuthRecv(MCONTACT, PROTORECVEVENT *)
{
return 1;
}
-HANDLE FacebookProto::FileAllow(MCONTACT hContact,HANDLE hTransfer,const PROTOCHAR *path)
+HANDLE FacebookProto::FileAllow(MCONTACT, HANDLE, const PROTOCHAR *)
{
return NULL;
}
-int FacebookProto::FileCancel(MCONTACT hContact,HANDLE hTransfer)
+int FacebookProto::FileCancel(MCONTACT, HANDLE)
{
return 1;
}
-int FacebookProto::FileDeny(MCONTACT hContact,HANDLE hTransfer,const PROTOCHAR *reason)
+int FacebookProto::FileDeny(MCONTACT, HANDLE, const PROTOCHAR *)
{
return 1;
}
-int FacebookProto::FileResume(HANDLE hTransfer,int *action,const PROTOCHAR **filename)
+int FacebookProto::FileResume(HANDLE, int *, const PROTOCHAR **)
{
return 1;
}
-HWND FacebookProto::SearchAdvanced(HWND owner)
+HWND FacebookProto::SearchAdvanced(HWND)
{
return NULL;
}
-HWND FacebookProto::CreateExtendedSearchUI(HWND owner)
+HWND FacebookProto::CreateExtendedSearchUI(HWND)
{
return NULL;
}
-int FacebookProto::RecvContacts(MCONTACT hContact,PROTORECVEVENT *)
+int FacebookProto::RecvContacts(MCONTACT, PROTORECVEVENT *)
{
return 1;
}
-int FacebookProto::RecvFile(MCONTACT hContact,PROTORECVFILET *)
+int FacebookProto::RecvFile(MCONTACT, PROTORECVFILET *)
{
return 1;
}
-int FacebookProto::RecvUrl(MCONTACT hContact,PROTORECVEVENT *)
+int FacebookProto::RecvUrl(MCONTACT, PROTORECVEVENT *)
{
return 1;
}
-int FacebookProto::SendContacts(MCONTACT hContact, int flags, int nContacts, MCONTACT *hContactsList)
+int FacebookProto::SendContacts(MCONTACT, int, int, MCONTACT *)
{
return 1;
}
-HANDLE FacebookProto::SendFile(MCONTACT hContact,const PROTOCHAR *desc, PROTOCHAR **files)
+HANDLE FacebookProto::SendFile(MCONTACT, const PROTOCHAR *, PROTOCHAR **)
{
return NULL;
}
-int FacebookProto::SendUrl(MCONTACT hContact,int flags,const char *url)
+int FacebookProto::SendUrl(MCONTACT, int, const char *)
{
return 1;
}
-int FacebookProto::SetApparentMode(MCONTACT hContact,int mode)
+int FacebookProto::SetApparentMode(MCONTACT, int)
{
return 1;
}
-int FacebookProto::RecvAwayMsg(MCONTACT hContact,int mode,PROTORECVEVENT *evt)
+int FacebookProto::RecvAwayMsg(MCONTACT, int, PROTORECVEVENT *)
{
return 1;
}
diff --git a/protocols/FacebookRM/src/theme.cpp b/protocols/FacebookRM/src/theme.cpp
index 8bc989036d..67b6701a2f 100644
--- a/protocols/FacebookRM/src/theme.cpp
+++ b/protocols/FacebookRM/src/theme.cpp
@@ -26,15 +26,15 @@ extern OBJLIST<FacebookProto> g_Instances;
static IconItem icons[] =
{
- { LPGEN("Facebook icon"), "facebook", IDI_FACEBOOK },
- { LPGEN("Mind"), "mind", IDI_MIND },
- { LPGEN("Poke"), "poke", IDI_POKE },
- { LPGEN("Notification"), "notification", IDI_NOTIFICATION },
- { LPGEN("Newsfeed"), "newsfeed", IDI_NEWSFEED },
- { LPGEN("Friendship details"), "friendship", IDI_FRIENDS },
- { LPGEN("Conversation"), "conversation", IDI_CONVERSATION },
- { LPGEN("Message read"), "read", IDI_READ },
- { LPGEN("Captcha form icon"), "key", IDI_KEYS }
+ { LPGEN("Facebook icon"), "facebook", IDI_FACEBOOK },
+ { LPGEN("Mind"), "mind", IDI_MIND },
+ { LPGEN("Poke"), "poke", IDI_POKE },
+ { LPGEN("Notification"), "notification", IDI_NOTIFICATION },
+ { LPGEN("Newsfeed"), "newsfeed", IDI_NEWSFEED },
+ { LPGEN("Friendship details"), "friendship", IDI_FRIENDS },
+ { LPGEN("Conversation"), "conversation", IDI_CONVERSATION },
+ { LPGEN("Message read"), "read", IDI_READ },
+ { LPGEN("Captcha form icon"), "key", IDI_KEYS }
};
// TODO: uninit
@@ -45,8 +45,8 @@ void InitIcons(void)
HANDLE GetIconHandle(const char* name)
{
- for(size_t i=0; i<SIZEOF(icons); i++)
- if(strcmp(icons[i].szName, name) == 0)
+ for (size_t i = 0; i < SIZEOF(icons); i++)
+ if (strcmp(icons[i].szName, name) == 0)
return icons[i].hIcolib;
return 0;
@@ -59,49 +59,49 @@ HGENMENU g_hContactMenuItems[CMITEMS_COUNT];
static FacebookProto * GetInstanceByHContact(MCONTACT hContact)
{
char *proto = GetContactProto(hContact);
- if(!proto)
+ if (!proto)
return 0;
- for(int i=0; i<g_Instances.getCount(); i++)
- if(!strcmp(proto,g_Instances[i].m_szModuleName))
+ for (int i = 0; i < g_Instances.getCount(); i++)
+ if (!strcmp(proto, g_Instances[i].m_szModuleName))
return &g_Instances[i];
return 0;
}
-template<INT_PTR (__cdecl FacebookProto::*Fcn)(WPARAM,LPARAM)>
-INT_PTR GlobalService(WPARAM wParam,LPARAM lParam)
+template<INT_PTR(__cdecl FacebookProto::*Fcn)(WPARAM, LPARAM)>
+INT_PTR GlobalService(WPARAM wParam, LPARAM lParam)
{
FacebookProto *proto = GetInstanceByHContact(MCONTACT(wParam));
- return proto ? (proto->*Fcn)(wParam,lParam) : 0;
+ return proto ? (proto->*Fcn)(wParam, lParam) : 0;
}
-static int PrebuildContactMenu(WPARAM wParam,LPARAM lParam)
+static int PrebuildContactMenu(WPARAM wParam, LPARAM lParam)
{
- for (size_t i=0; i<SIZEOF(g_hContactMenuItems); i++)
+ for (size_t i = 0; i < SIZEOF(g_hContactMenuItems); i++)
Menu_ShowItem(g_hContactMenuItems[i], false);
FacebookProto *proto = GetInstanceByHContact(MCONTACT(wParam));
- return proto ? proto->OnPrebuildContactMenu(wParam,lParam) : 0;
+ return proto ? proto->OnPrebuildContactMenu(wParam, lParam) : 0;
}
void InitContactMenus()
{
- HookEvent(ME_CLIST_PREBUILDCONTACTMENU,PrebuildContactMenu);
+ HookEvent(ME_CLIST_PREBUILDCONTACTMENU, PrebuildContactMenu);
- CLISTMENUITEM mi = {sizeof(mi)};
- mi.position=-2000006000;
+ CLISTMENUITEM mi = { sizeof(mi) };
+ mi.position = -2000006000;
mi.icolibItem = LoadSkinnedIconHandle(SKINICON_EVENT_URL);
mi.pszName = LPGEN("Visit profile");
mi.pszService = "FacebookProto/VisitProfile";
- CreateServiceFunction(mi.pszService,GlobalService<&FacebookProto::VisitProfile>);
+ CreateServiceFunction(mi.pszService, GlobalService<&FacebookProto::VisitProfile>);
g_hContactMenuItems[CMI_VISIT_PROFILE] = Menu_AddContactMenuItem(&mi);
- mi.position=-2000006001;
+ mi.position = -2000006001;
mi.icolibItem = GetIconHandle("friendship");
mi.pszName = LPGEN("Visit friendship details");
mi.pszService = "FacebookProto/VisitFriendship";
- CreateServiceFunction(mi.pszService,GlobalService<&FacebookProto::VisitFriendship>);
+ CreateServiceFunction(mi.pszService, GlobalService<&FacebookProto::VisitFriendship>);
g_hContactMenuItems[CMI_VISIT_FRIENDSHIP] = Menu_AddContactMenuItem(&mi);
mi.position = -2000006002;
@@ -111,46 +111,46 @@ void InitContactMenus()
CreateServiceFunction(mi.pszService, GlobalService<&FacebookProto::VisitConversation>);
g_hContactMenuItems[CMI_VISIT_CONVERSATION] = Menu_AddContactMenuItem(&mi);
- mi.position=-2000006003;
+ mi.position = -2000006003;
mi.icolibItem = GetIconHandle("mind");
mi.pszName = LPGEN("Share status...");
mi.pszService = "FacebookProto/Mind";
- CreateServiceFunction(mi.pszService,GlobalService<&FacebookProto::OnMind>);
+ CreateServiceFunction(mi.pszService, GlobalService<&FacebookProto::OnMind>);
g_hContactMenuItems[CMI_POST_STATUS] = Menu_AddContactMenuItem(&mi);
- mi.position=-2000006004;
+ mi.position = -2000006004;
mi.icolibItem = GetIconHandle("poke");
mi.pszName = LPGEN("Poke");
mi.pszService = "FacebookProto/Poke";
- CreateServiceFunction(mi.pszService,GlobalService<&FacebookProto::Poke>);
+ CreateServiceFunction(mi.pszService, GlobalService<&FacebookProto::Poke>);
g_hContactMenuItems[CMI_POKE] = Menu_AddContactMenuItem(&mi);
- mi.position=-2000006010;
+ mi.position = -2000006010;
mi.icolibItem = LoadSkinnedIconHandle(SKINICON_AUTH_REVOKE);
mi.pszName = LPGEN("Cancel friendship");
mi.pszService = "FacebookProto/CancelFriendship";
- CreateServiceFunction(mi.pszService,GlobalService<&FacebookProto::CancelFriendship>);
+ CreateServiceFunction(mi.pszService, GlobalService<&FacebookProto::CancelFriendship>);
g_hContactMenuItems[CMI_AUTH_REVOKE] = Menu_AddContactMenuItem(&mi);
- mi.position=-2000006011;
+ mi.position = -2000006011;
mi.icolibItem = LoadSkinnedIconHandle(SKINICON_AUTH_REVOKE);
mi.pszName = LPGEN("Cancel friendship request");
mi.pszService = "FacebookProto/CancelFriendshipRequest";
- CreateServiceFunction(mi.pszService,GlobalService<&FacebookProto::OnCancelFriendshipRequest>);
+ CreateServiceFunction(mi.pszService, GlobalService<&FacebookProto::OnCancelFriendshipRequest>);
g_hContactMenuItems[CMI_AUTH_CANCEL] = Menu_AddContactMenuItem(&mi);
- mi.position=-2000006012;
+ mi.position = -2000006012;
mi.icolibItem = LoadSkinnedIconHandle(SKINICON_AUTH_REQUEST);
mi.pszName = LPGEN("Request friendship");
mi.pszService = "FacebookProto/RequestFriendship";
- CreateServiceFunction(mi.pszService,GlobalService<&FacebookProto::RequestFriendship>);
+ CreateServiceFunction(mi.pszService, GlobalService<&FacebookProto::RequestFriendship>);
g_hContactMenuItems[CMI_AUTH_ASK] = Menu_AddContactMenuItem(&mi);
- mi.position=-2000006013;
+ mi.position = -2000006013;
mi.icolibItem = LoadSkinnedIconHandle(SKINICON_AUTH_GRANT);
mi.pszName = LPGEN("Approve friendship");
mi.pszService = "FacebookProto/ApproveFriendship";
- CreateServiceFunction(mi.pszService,GlobalService<&FacebookProto::ApproveFriendship>);
+ CreateServiceFunction(mi.pszService, GlobalService<&FacebookProto::ApproveFriendship>);
g_hContactMenuItems[CMI_AUTH_GRANT] = Menu_AddContactMenuItem(&mi);
mi.position = -2000006014;
@@ -163,12 +163,12 @@ void InitContactMenus()
void UninitContactMenus()
{
- for(size_t i=0; i<SIZEOF(g_hContactMenuItems); i++)
+ for (size_t i = 0; i < SIZEOF(g_hContactMenuItems); i++)
CallService(MO_REMOVEMENUITEM, (WPARAM)g_hContactMenuItems[i], 0);
}
-int FacebookProto::OnPrebuildContactMenu(WPARAM wParam,LPARAM lParam)
-{
+int FacebookProto::OnPrebuildContactMenu(WPARAM wParam, LPARAM)
+{
MCONTACT hContact = MCONTACT(wParam);
bool bIsChatroom = isChatRoom(hContact);
@@ -177,7 +177,7 @@ int FacebookProto::OnPrebuildContactMenu(WPARAM wParam,LPARAM lParam)
Menu_ShowItem(g_hContactMenuItems[CMI_VISIT_CONVERSATION], true);
Menu_ShowItem(g_hContactMenuItems[CMI_POST_STATUS], !bIsChatroom);
- if (!isOffline() && !bIsChatroom)
+ if (!isOffline() && !bIsChatroom)
{
bool ctrlPressed = (GetKeyState(VK_CONTROL) & 0x8000) != 0;
BYTE type = getByte(hContact, FACEBOOK_KEY_CONTACT_TYPE, 0);
@@ -186,7 +186,7 @@ int FacebookProto::OnPrebuildContactMenu(WPARAM wParam,LPARAM lParam)
Menu_ShowItem(g_hContactMenuItems[CMI_AUTH_GRANT], ctrlPressed || type == CONTACT_APPROVE);
Menu_ShowItem(g_hContactMenuItems[CMI_AUTH_DENY], ctrlPressed || type == CONTACT_APPROVE);
Menu_ShowItem(g_hContactMenuItems[CMI_AUTH_REVOKE], ctrlPressed || type == CONTACT_FRIEND);
- Menu_ShowItem(g_hContactMenuItems[CMI_AUTH_CANCEL], ctrlPressed || type == CONTACT_REQUEST);
+ Menu_ShowItem(g_hContactMenuItems[CMI_AUTH_CANCEL], ctrlPressed || type == CONTACT_REQUEST);
Menu_ShowItem(g_hContactMenuItems[CMI_POKE], true);
}
@@ -194,13 +194,13 @@ int FacebookProto::OnPrebuildContactMenu(WPARAM wParam,LPARAM lParam)
return 0;
}
-int FacebookProto::OnBuildStatusMenu(WPARAM wParam,LPARAM lParam)
+int FacebookProto::OnBuildStatusMenu(WPARAM, LPARAM)
{
char text[200];
- strcpy(text,m_szModuleName);
- char *tDest = text+strlen(text);
+ strcpy(text, m_szModuleName);
+ char *tDest = text + strlen(text);
- CLISTMENUITEM mi = {sizeof(mi)};
+ CLISTMENUITEM mi = { sizeof(mi) };
mi.pszService = text;
HGENMENU hRoot = MO_GetProtoRootMenu(m_szModuleName);
@@ -224,13 +224,13 @@ int FacebookProto::OnBuildStatusMenu(WPARAM wParam,LPARAM lParam)
mi.hParentMenu = hRoot;
//CreateProtoService(m_szModuleName,"/Mind",&FacebookProto::OnMind,this);
- strcpy(tDest,"/Mind");
+ strcpy(tDest, "/Mind");
mi.pszName = LPGEN("Share status...");
mi.icolibItem = GetIconHandle("mind");
m_hStatusMind = Menu_AddProtoMenuItem(&mi);
//CreateProtoService("/VisitProfile",&FacebookProto::VisitProfile);
- strcpy(tDest,"/VisitProfile");
+ strcpy(tDest, "/VisitProfile");
mi.flags = CMIF_CHILDPOPUP;
mi.pszName = LPGEN("Visit profile");
mi.icolibItem = LoadSkinnedIconHandle(SKINICON_EVENT_URL);
@@ -250,8 +250,8 @@ int FacebookProto::OnBuildStatusMenu(WPARAM wParam,LPARAM lParam)
mi.icolibItem = LoadSkinnedIconHandle(SKINICON_OTHER_HELP);
m_hMenuServicesRoot = Menu_AddProtoMenuItem(&mi);
- CreateProtoService("/RefreshBuddyList",&FacebookProto::RefreshBuddyList);
- strcpy(tDest,"/RefreshBuddyList");
+ CreateProtoService("/RefreshBuddyList", &FacebookProto::RefreshBuddyList);
+ strcpy(tDest, "/RefreshBuddyList");
mi.flags = CMIF_ROOTHANDLE;
mi.pszName = LPGEN("Refresh Buddy List");
mi.pszPopupName = LPGEN("Services");
@@ -259,16 +259,16 @@ int FacebookProto::OnBuildStatusMenu(WPARAM wParam,LPARAM lParam)
mi.hParentMenu = m_hMenuServicesRoot;
Menu_AddProtoMenuItem(&mi);
- CreateProtoService("/CheckFriendRequests",&FacebookProto::CheckFriendRequests);
- strcpy(tDest,"/CheckFriendRequests");
+ CreateProtoService("/CheckFriendRequests", &FacebookProto::CheckFriendRequests);
+ strcpy(tDest, "/CheckFriendRequests");
mi.flags = CMIF_ROOTHANDLE;
mi.pszName = LPGEN("Check Friends Requests");
mi.icolibItem = LoadSkinnedIconHandle(SKINICON_AUTH_REQUEST);
mi.hParentMenu = m_hMenuServicesRoot;
Menu_AddProtoMenuItem(&mi);
- CreateProtoService("/CheckNewsfeeds",&FacebookProto::CheckNewsfeeds);
- strcpy(tDest,"/CheckNewsfeeds");
+ CreateProtoService("/CheckNewsfeeds", &FacebookProto::CheckNewsfeeds);
+ strcpy(tDest, "/CheckNewsfeeds");
mi.flags = CMIF_ROOTHANDLE;
mi.pszName = LPGEN("Check Newsfeeds");
mi.pszPopupName = LPGEN("Services");
@@ -281,7 +281,7 @@ int FacebookProto::OnBuildStatusMenu(WPARAM wParam,LPARAM lParam)
void FacebookProto::ToggleStatusMenuItems(BOOL bEnable)
{
- CLISTMENUITEM clmi = {sizeof(clmi)};
+ CLISTMENUITEM clmi = { sizeof(clmi) };
clmi.flags = CMIM_FLAGS | ((bEnable) ? 0 : CMIF_GRAYED);
Menu_ModifyItem(m_hMenuRoot, &clmi);
diff --git a/protocols/FacebookRM/src/utils.cpp b/protocols/FacebookRM/src/utils.cpp
index e4424f0b25..4ca4e0ea85 100644
--- a/protocols/FacebookRM/src/utils.cpp
+++ b/protocols/FacebookRM/src/utils.cpp
@@ -51,7 +51,7 @@ std::string utils::time::mili_timestamp()
std::string timestamp = utils::time::unix_timestamp();
GetSystemTime(&st);
timestamp.append(utils::conversion::to_string((void*)&st.wMilliseconds, UTILS_CONV_UNSIGNED_NUMBER));
- return timestamp.substr(0,13);
+ return timestamp.substr(0, 13);
}
DWORD utils::time::fix_timestamp(unsigned __int64 mili_timestamp)
@@ -60,7 +60,7 @@ DWORD utils::time::fix_timestamp(unsigned __int64 mili_timestamp)
if (mili_timestamp > 100000000000) {
mili_timestamp /= 1000;
}
- return (DWORD) mili_timestamp;
+ return (DWORD)mili_timestamp;
}
DWORD utils::conversion::to_timestamp(const std::string &data)
@@ -78,15 +78,15 @@ std::string utils::conversion::to_string(void* data, WORD type)
switch (type)
{
- case UTILS_CONV_BOOLEAN:
+ case UTILS_CONV_BOOLEAN:
out << (data ? "true" : "false");
- case UTILS_CONV_TIME_T:
+ case UTILS_CONV_TIME_T:
out << (*(time_t*)data);
break;
case UTILS_CONV_SIGNED_NUMBER:
- out << (*(signed int*)data);
+ out << (*(signed int*)data);
break;
case UTILS_CONV_UNSIGNED_NUMBER:
@@ -141,7 +141,7 @@ void utils::text::append_ordinal(unsigned long value, std::string* data)
{ // U+0080 .. U+07FF
*data += (char)(192 + (value / 64));
*data += (char)(128 + (value % 64));
- }
+ }
else if (value >= 2048 && value <= 65535)
{ // U+0800 .. U+FFFF
*data += (char)(224 + (value / 4096));
@@ -153,7 +153,7 @@ void utils::text::append_ordinal(unsigned long value, std::string* data)
*data += (char)((value >> 24) & 0xFF);
*data += (char)((value >> 16) & 0xFF);
*data += (char)((value >> 8) & 0xFF);
- *data += (char)((value) & 0xFF);
+ *data += (char)((value)& 0xFF);
}
}
@@ -165,7 +165,7 @@ std::string utils::text::html_entities_decode(std::string data)
utils::text::replace_all(&data, "&gt;", ">");
utils::text::replace_all(&data, "&hearts;", "\xE2\x99\xA5"); // direct byte replacement
-// utils::text::replace_all(&data, "&hearts;", "\\u2665"); // indirect slashu replacement
+ // utils::text::replace_all(&data, "&hearts;", "\\u2665"); // indirect slashu replacement
utils::text::replace_all(&data, "\\/", "/");
utils::text::replace_all(&data, "\\\\", "\\");
@@ -182,15 +182,16 @@ std::string utils::text::html_entities_decode(std::string data)
std::string new_string;
for (std::string::size_type i = 0; i < data.length(); i++)
{
- if (data.at(i) == '&' && (i+1) < data.length() && data.at(i+1) == '#')
+ if (data.at(i) == '&' && (i + 1) < data.length() && data.at(i + 1) == '#')
{
std::string::size_type comma = data.find(";", i);
if (comma != std::string::npos) {
bool hexa = false;
- if ((i+2) < data.length() && data.at(i+2) == 'x') {
+ if ((i + 2) < data.length() && data.at(i + 2) == 'x') {
hexa = true;
i += 3;
- } else {
+ }
+ else {
i += 2;
}
@@ -199,7 +200,7 @@ std::string utils::text::html_entities_decode(std::string data)
unsigned long udn = strtoul(num.c_str(), NULL, hexa ? 16 : 10);
utils::text::append_ordinal(udn, &new_string);
}
-
+
i = comma;
continue;
}
@@ -216,7 +217,7 @@ std::string utils::text::edit_html(std::string data)
std::string::size_type end = 0;
std::string::size_type start = 0;
std::string new_string;
-
+
while (end != std::string::npos)
{
end = data.find("<span class=\\\"text_exposed_hide", start);
@@ -224,7 +225,8 @@ std::string utils::text::edit_html(std::string data)
{
new_string += data.substr(start, end - start);
start = data.find("<\\/span", end);
- } else {
+ }
+ else {
new_string += data.substr(start, data.length() - start);
}
}
@@ -240,7 +242,8 @@ std::string utils::text::edit_html(std::string data)
{
new_string += data.substr(start, end - start);
start = data.find("<\\/span", end);
- } else {
+ }
+ else {
new_string += data.substr(start, data.length() - start);
}
}
@@ -256,7 +259,8 @@ std::string utils::text::edit_html(std::string data)
{
new_string += data.substr(start, end - start);
start = data.find("<\\/a", end);
- } else {
+ }
+ else {
new_string += data.substr(start, data.length() - start);
}
}
@@ -270,7 +274,7 @@ std::string utils::text::edit_html(std::string data)
start = new_string.find(">", start);
if (start != std::string::npos)
- new_string.insert(start+1, "\n\n");
+ new_string.insert(start + 1, "\n\n");
start = new_string.find("<\\/div>", start);
if (start != std::string::npos)
@@ -283,13 +287,13 @@ std::string utils::text::edit_html(std::string data)
{
start = new_string.find(">", start);
if (start != std::string::npos)
- new_string.insert(start+1, "\n");
+ new_string.insert(start + 1, "\n");
start = new_string.find("<\\/div>", start);
if (start != std::string::npos)
new_string.insert(start, "\n");
}
-
+
utils::text::replace_all(&new_string, "<br \\/>", "\n");
utils::text::replace_all(&new_string, "\n\n\n", "\n\n");
//utils::text::replace_all(&new_string, "\\t", "");
@@ -304,7 +308,7 @@ std::string utils::text::remove_html(const std::string &data)
for (std::string::size_type i = 0; i < data.length(); i++)
{
- if (data.at(i) == '<' && (i+1) < data.length() && data.at(i+1) != ' ')
+ if (data.at(i) == '<' && (i + 1) < data.length() && data.at(i + 1) != ' ')
{
i = data.find(">", i);
if (i == std::string::npos)
@@ -325,7 +329,7 @@ std::string utils::text::slashu_to_utf8(const std::string &data)
for (std::string::size_type i = 0; i < data.length(); i++)
{
- if (data.at(i) == '\\' && (i+1) < data.length() && data.at(i+1) == 'u')
+ if (data.at(i) == '\\' && (i + 1) < data.length() && data.at(i + 1) == 'u')
{
unsigned long udn = strtoul(data.substr(i + 2, 4).c_str(), NULL, 16);
append_ordinal(udn, &new_string);
@@ -354,9 +358,9 @@ void utils::text::explode(std::string str, const std::string &separator, std::ve
pos = str.find_first_of(separator);
while (pos != std::string::npos) {
if (pos > 0) {
- results->push_back(str.substr(0,pos));
+ results->push_back(str.substr(0, pos));
}
- str = str.substr(pos+1);
+ str = str.substr(pos + 1);
pos = str.find_first_of(separator);
}
if (str.length() > 0) {
@@ -369,9 +373,9 @@ std::string utils::text::source_get_value(std::string* data, unsigned int argume
va_list arg;
std::string ret;
std::string::size_type start = 0, end = 0;
-
+
va_start(arg, argument_count);
-
+
for (unsigned int i = argument_count; i > 0; i--)
{
if (i == 1)
@@ -380,7 +384,8 @@ std::string utils::text::source_get_value(std::string* data, unsigned int argume
if (start == std::string::npos || end == std::string::npos)
break;
ret = data->substr(start, end - start);
- } else {
+ }
+ else {
std::string term = va_arg(arg, char*);
start = data->find(term, start);
if (start == std::string::npos)
@@ -388,8 +393,8 @@ std::string utils::text::source_get_value(std::string* data, unsigned int argume
start += term.length();
}
}
-
- va_end(arg);
+
+ va_end(arg);
return ret;
}
@@ -405,7 +410,8 @@ std::string utils::text::source_get_value2(std::string* data, const char *term,
end = data->find_first_of(endings, start);
if (end != std::string::npos) {
ret = data->substr(start, end - start);
- } else if (wholeString) {
+ }
+ else if (wholeString) {
ret = data->substr(start);
}
}
@@ -419,7 +425,7 @@ std::string utils::text::source_get_form_data(std::string* data)
std::string::size_type start = 0;
start = data->find("<input", start);
- while (start != std::string::npos) {
+ while (start != std::string::npos) {
start++;
std::string attr, value;
@@ -430,7 +436,7 @@ std::string utils::text::source_get_form_data(std::string* data)
if (end != std::string::npos)
attr = data->substr(pos, end - pos);
-
+
end = data->find(">", pos);
pos = data->find("value=\"", pos);
if (pos != std::string::npos && end != std::string::npos && pos < end) {
@@ -465,6 +471,6 @@ std::string utils::text::rand_string(int len, const char *chars)
}
int utils::number::random(int min, int max)
-{
+{
return (rand() % (max - min)) + min;
}