summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2014-08-11 13:58:08 +0000
committerRobert Pösel <robyer@seznam.cz>2014-08-11 13:58:08 +0000
commite54f5144d2be315ee14ea7ae42a2a38f53e1162a (patch)
tree780cff78c56c8c384fe82ca66f9ac25a5bc25ac7 /protocols
parentfcd08bb4c2fb2ef60efa4a434a673941152916c7 (diff)
Facebook: Hidden option to disable multi user chat
git-svn-id: http://svn.miranda-ng.org/main/trunk@10155 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r--protocols/FacebookRM/docs/facebook - readme.txt1
-rw-r--r--protocols/FacebookRM/src/db.h1
-rw-r--r--protocols/FacebookRM/src/dialogs.cpp2
-rw-r--r--protocols/FacebookRM/src/json.cpp7
-rw-r--r--protocols/FacebookRM/src/process.cpp8
-rw-r--r--protocols/FacebookRM/src/proto.cpp27
-rw-r--r--protocols/FacebookRM/src/proto.h1
7 files changed, 35 insertions, 12 deletions
diff --git a/protocols/FacebookRM/docs/facebook - readme.txt b/protocols/FacebookRM/docs/facebook - readme.txt
index 49b79368ac..9b3d740536 100644
--- a/protocols/FacebookRM/docs/facebook - readme.txt
+++ b/protocols/FacebookRM/docs/facebook - readme.txt
@@ -32,6 +32,7 @@ Info:
"KeepUnread" (Byte) - 1 = Don't mark messages as read on server (works globally or per contact)
"NaseemsSpamMode" (Byte) - 1 = Don't add contacts when we send message to them from other instances, add them only when they reply
"NameAsNick" (Byte) - 0 = don't use real name as nickname, use nickname if possible (default is 1)
+"DisableChat" (Byte) - 1 = don't use multi user chat at all
--------------------------------
Version history
diff --git a/protocols/FacebookRM/src/db.h b/protocols/FacebookRM/src/db.h
index b6c44b717e..88a2b35988 100644
--- a/protocols/FacebookRM/src/db.h
+++ b/protocols/FacebookRM/src/db.h
@@ -68,6 +68,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define FACEBOOK_KEY_NASEEMS_SPAM_MODE "NaseemsSpamMode" // [HIDDEN] - 1 = don't load messages sent from other instances (e.g., browser) - known as "Naseem's spam mode"
#define FACEBOOK_KEY_NAME_AS_NICK "NameAsNick" // [HIDDEN] - 0 = don't use real name as nickname, use nickname if possible
#define FACEBOOK_KEY_OPEN_URL_BROWSER "OpenUrlBrowser" // [HIDDEN] - (unicode) = absolute path to browser to open url links with
+#define FACEBOOK_KEY_DISABLE_CHAT "DisableChat" // [HIDDEN] - 1 = don't use multi user chat at all
#define FACEBOOK_KEY_EVENT_NOTIFICATIONS_ENABLE "EventNotificationsEnable"
#define FACEBOOK_KEY_EVENT_FEEDS_ENABLE "EventFeedsEnable"
diff --git a/protocols/FacebookRM/src/dialogs.cpp b/protocols/FacebookRM/src/dialogs.cpp
index 449ad4507e..122cecc084 100644
--- a/protocols/FacebookRM/src/dialogs.cpp
+++ b/protocols/FacebookRM/src/dialogs.cpp
@@ -3,7 +3,7 @@
Facebook plugin for Miranda Instant Messenger
_____________________________________________
-Copyright � 2009-11 Michal Zelinka, 2011-13 Robert P�sel
+Copyright © 2009-11 Michal Zelinka, 2011-13 Robert Pösel
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp
index 2715ebc9ec..eb1bd02d95 100644
--- a/protocols/FacebookRM/src/json.cpp
+++ b/protocols/FacebookRM/src/json.cpp
@@ -444,6 +444,9 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa
JSONNODE *threadid = json_get(it, "tid");
if (threadid != NULL) { // multi user chat
+ if (proto->m_disableChat)
+ continue;
+
std::tstring tid = json_as_string(threadid);
std::string reader_id = json_as_pstring(reader);
@@ -603,6 +606,8 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa
proto->StopTyping(hContact);
} else if (t == "ttyp") {
// multi chat typing notification
+ if (proto->m_disableChat)
+ continue;
JSONNODE *from_ = json_get(it, "from");
JSONNODE *thread_ = json_get(it, "thread");
@@ -683,6 +688,8 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa
}*/
} else if (t == "mercury") {
// rename multi user chat, ...
+ if (proto->m_disableChat)
+ continue;
JSONNODE *actions_ = json_get(it, "actions");
if (actions_ == NULL)
diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp
index 6f52f02bba..da8fb609b8 100644
--- a/protocols/FacebookRM/src/process.cpp
+++ b/protocols/FacebookRM/src/process.cpp
@@ -461,6 +461,9 @@ void FacebookProto::LoadLastMessages(void *p)
bool isChat = isChatRoom(hContact);
+ if (isChat && m_disableChat)
+ return;
+
ptrA item_id(getStringA(hContact, isChat ? FACEBOOK_KEY_TID : FACEBOOK_KEY_ID));
if (item_id == NULL) {
debugLogA("!!!!! LoadLastMessages: Contact has no TID/ID");
@@ -598,6 +601,11 @@ void FacebookProto::ReceiveMessages(std::vector<facebook_message*> messages, boo
DWORD timestamp = local_timestamp || !messages[i]->time ? ::time(NULL) : messages[i]->time;
if (messages[i]->isChat) {
+ if (m_disableChat) {
+ delete messages[i];
+ continue;
+ }
+
// Multi-user message
debugLogA(" Got chat message: %s", messages[i]->message_text.c_str());
diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp
index e5e5f9c47c..708f692c64 100644
--- a/protocols/FacebookRM/src/proto.cpp
+++ b/protocols/FacebookRM/src/proto.cpp
@@ -36,6 +36,7 @@ FacebookProto::FacebookProto(const char* proto_name,const TCHAR* username) :
facy.fcb_conn_lock_ = CreateMutex(NULL, FALSE, NULL);
m_invisible = false;
+ m_disableChat = getBool(FACEBOOK_KEY_DISABLE_CHAT, false);
CreateProtoService(PS_CREATEACCMGRUI, &FacebookProto::SvcCreateAccMgrUI);
CreateProtoService(PS_GETMYAWAYMSG, &FacebookProto::GetMyAwayMsg);
@@ -44,8 +45,10 @@ FacebookProto::FacebookProto(const char* proto_name,const TCHAR* username) :
CreateProtoService(PS_GETAVATARCAPS, &FacebookProto::GetAvatarCaps);
CreateProtoService(PS_GETUNREADEMAILCOUNT, &FacebookProto::GetNotificationsCount);
- CreateProtoService(PS_JOINCHAT, &FacebookProto::OnJoinChat);
- CreateProtoService(PS_LEAVECHAT, &FacebookProto::OnLeaveChat);
+ if (!m_disableChat) {
+ CreateProtoService(PS_JOINCHAT, &FacebookProto::OnJoinChat);
+ CreateProtoService(PS_LEAVECHAT, &FacebookProto::OnLeaveChat);
+ }
CreateProtoService("/Mind", &FacebookProto::OnMind);
CreateProtoService("/VisitProfile", &FacebookProto::VisitProfile);
@@ -116,7 +119,7 @@ DWORD_PTR FacebookProto::GetCaps(int type, MCONTACT hContact)
{
case PFLAGNUM_1:
{
- DWORD_PTR flags = PF1_IM | PF1_CHAT | PF1_SERVERCLIST | PF1_AUTHREQ | /*PF1_ADDED |*/ PF1_BASICSEARCH | PF1_SEARCHBYEMAIL | PF1_SEARCHBYNAME | PF1_ADDSEARCHRES; // | PF1_VISLIST | PF1_INVISLIST;
+ DWORD_PTR flags = PF1_IM | (!m_disableChat ? PF1_CHAT : 0) | PF1_SERVERCLIST | PF1_AUTHREQ | /*PF1_ADDED |*/ PF1_BASICSEARCH | PF1_SEARCHBYEMAIL | PF1_SEARCHBYNAME | PF1_ADDSEARCHRES; // | PF1_VISLIST | PF1_INVISLIST;
if (getByte(FACEBOOK_KEY_SET_MIRANDA_STATUS, 0))
return flags |= PF1_MODEMSG;
@@ -416,14 +419,16 @@ INT_PTR FacebookProto::SvcCreateAccMgrUI(WPARAM wParam, LPARAM lParam)
int FacebookProto::OnModulesLoaded(WPARAM wParam, LPARAM lParam)
{
// Register group chat
- GCREGISTER gcr = {sizeof(gcr)};
- gcr.dwFlags = 0; //GC_ACKMSG;
- gcr.pszModule = m_szModuleName;
- gcr.ptszDispName = m_tszUserName;
- gcr.iMaxText = FACEBOOK_MESSAGE_LIMIT;
- gcr.nColors = 0;
- gcr.pColors = NULL;
- CallService(MS_GC_REGISTER,0,reinterpret_cast<LPARAM>(&gcr));
+ if (!m_disableChat) {
+ GCREGISTER gcr = { sizeof(gcr) };
+ gcr.dwFlags = 0; //GC_ACKMSG;
+ gcr.pszModule = m_szModuleName;
+ gcr.ptszDispName = m_tszUserName;
+ gcr.iMaxText = FACEBOOK_MESSAGE_LIMIT;
+ gcr.nColors = 0;
+ gcr.pColors = NULL;
+ CallService(MS_GC_REGISTER, 0, reinterpret_cast<LPARAM>(&gcr));
+ }
return 0;
}
diff --git a/protocols/FacebookRM/src/proto.h b/protocols/FacebookRM/src/proto.h
index 4a76454214..53d9f477fc 100644
--- a/protocols/FacebookRM/src/proto.h
+++ b/protocols/FacebookRM/src/proto.h
@@ -52,6 +52,7 @@ public:
}
bool m_invisible;
+ bool m_disableChat;
// DB utils missing in proto_interface