summaryrefslogtreecommitdiff
path: root/protocols/FacebookRM
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2016-07-25 19:20:57 +0000
committerRobert Pösel <robyer@seznam.cz>2016-07-25 19:20:57 +0000
commit9c4ce5c83b1b782d9031896454823e478611f6c2 (patch)
tree3bb2c5fe96c1c60cbb3a217a8c2dcf7bff7c10b9 /protocols/FacebookRM
parentb77891cf703512e3e4d957b1fda69a6a6e22995b (diff)
Facebook: Don't join archived or unsubscribed chatrooms at login
git-svn-id: http://svn.miranda-ng.org/main/trunk@17131 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM')
-rw-r--r--protocols/FacebookRM/src/chat.cpp10
-rw-r--r--protocols/FacebookRM/src/connection.cpp6
-rw-r--r--protocols/FacebookRM/src/contacts.cpp14
-rw-r--r--protocols/FacebookRM/src/db.h6
-rw-r--r--protocols/FacebookRM/src/proto.h5
5 files changed, 34 insertions, 7 deletions
diff --git a/protocols/FacebookRM/src/chat.cpp b/protocols/FacebookRM/src/chat.cpp
index 2db4c48b1e..a5a94c2d06 100644
--- a/protocols/FacebookRM/src/chat.cpp
+++ b/protocols/FacebookRM/src/chat.cpp
@@ -304,6 +304,16 @@ INT_PTR FacebookProto::OnJoinChat(WPARAM hContact, LPARAM)
fbc = new facebook_chatroom(thread_id);
LoadChatInfo(fbc);
facy.chat_rooms.insert(std::make_pair(thread_id, fbc));
+
+ // Update loaded info about this chat
+ if (getBool(hContact, FACEBOOK_KEY_CHAT_CAN_REPLY, true) != fbc->can_reply)
+ setByte(hContact, FACEBOOK_KEY_CHAT_CAN_REPLY, fbc->can_reply);
+ if (getBool(hContact, FACEBOOK_KEY_CHAT_READ_ONLY, false) != fbc->read_only)
+ setByte(hContact, FACEBOOK_KEY_CHAT_READ_ONLY, fbc->read_only);
+ if (getBool(hContact, FACEBOOK_KEY_CHAT_IS_ARCHIVED, false) != fbc->is_archived)
+ setByte(hContact, FACEBOOK_KEY_CHAT_IS_ARCHIVED, fbc->is_archived);
+ if (getBool(hContact, FACEBOOK_KEY_CHAT_IS_SUBSCRIBED, true) != fbc->is_subscribed)
+ setByte(hContact, FACEBOOK_KEY_CHAT_IS_SUBSCRIBED, fbc->is_subscribed);
}
// RM TODO: better use check if chatroom exists/is in db/is online... no?
diff --git a/protocols/FacebookRM/src/connection.cpp b/protocols/FacebookRM/src/connection.cpp
index ec322c844e..ea24c8ca37 100644
--- a/protocols/FacebookRM/src/connection.cpp
+++ b/protocols/FacebookRM/src/connection.cpp
@@ -157,11 +157,7 @@ void FacebookProto::ChangeStatus(void*)
}
// Join all locally present chatrooms
- for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
- if (isChatRoom(hContact)) {
- OnJoinChat(hContact, NULL);
- }
- }
+ JoinChatrooms();
ToggleStatusMenuItems(true);
debugLogA("*** SignOn complete");
diff --git a/protocols/FacebookRM/src/contacts.cpp b/protocols/FacebookRM/src/contacts.cpp
index 00da4ecd81..92e547a4a4 100644
--- a/protocols/FacebookRM/src/contacts.cpp
+++ b/protocols/FacebookRM/src/contacts.cpp
@@ -333,6 +333,20 @@ void FacebookProto::LoadParticipantsNames(facebook_chatroom *fbc)
}
}
+void FacebookProto::JoinChatrooms()
+{
+ for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
+ if (!isChatRoom(hContact))
+ continue;
+
+ // Ignore archived and unsubscribed chats
+ if (getBool(hContact, FACEBOOK_KEY_CHAT_IS_ARCHIVED, false) || !getBool(hContact, FACEBOOK_KEY_CHAT_IS_SUBSCRIBED, true))
+ continue;
+
+ OnJoinChat(hContact, NULL);
+ }
+}
+
void FacebookProto::LoadChatInfo(facebook_chatroom *fbc)
{
if (isOffline())
diff --git a/protocols/FacebookRM/src/db.h b/protocols/FacebookRM/src/db.h
index 8ac59f2fdc..5907a4d6b2 100644
--- a/protocols/FacebookRM/src/db.h
+++ b/protocols/FacebookRM/src/db.h
@@ -40,6 +40,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define FACEBOOK_KEY_MESSAGE_READ "LastMsgReadTime"
#define FACEBOOK_KEY_MESSAGE_READERS "MessageReaders"
+// Thread specific DB keys
+#define FACEBOOK_KEY_CHAT_CAN_REPLY "CanReply"
+#define FACEBOOK_KEY_CHAT_READ_ONLY "ReadOnly"
+#define FACEBOOK_KEY_CHAT_IS_ARCHIVED "IsArchived"
+#define FACEBOOK_KEY_CHAT_IS_SUBSCRIBED "IsSubscribed"
+
// Contact and account DB keys
#define FACEBOOK_KEY_KEEP_UNREAD "KeepUnread" // (byte) 1 = don't mark messages as read on server (works globally or per contact)
diff --git a/protocols/FacebookRM/src/proto.h b/protocols/FacebookRM/src/proto.h
index 4e9603e731..fb7502e1af 100644
--- a/protocols/FacebookRM/src/proto.h
+++ b/protocols/FacebookRM/src/proto.h
@@ -3,7 +3,7 @@
Facebook plugin for Miranda Instant Messenger
_____________________________________________
-Copyright © 2009-11 Michal Zelinka, 2011-16 Robert Pösel
+Copyright � 2009-11 Michal Zelinka, 2011-16 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
@@ -218,7 +218,8 @@ public:
void ReceiveMessages(std::vector<facebook_message> &messages, bool check_duplicates = false);
void LoadChatInfo(facebook_chatroom* fbc);
void LoadParticipantsNames(facebook_chatroom *fbc);
-
+ void JoinChatrooms();
+
bool IsSpecialChatRoom(MCONTACT hContact);
void PrepareNotificationsChatRoom();
void UpdateNotificationsChatRoom(facebook_notification *notification);