diff options
author | Robert Pösel <robyer@seznam.cz> | 2014-11-19 11:22:31 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2014-11-19 11:22:31 +0000 |
commit | abcda6e46fdfcb07f0c11115805131d6900e89ca (patch) | |
tree | 857f22c78ddea780a5a5eeb89e20004f0368fd12 /protocols/FacebookRM | |
parent | cf43b9022ce2afb922ad19773ffc369b461e9a34 (diff) |
Facebook: Option to log notifications into special chatroom; version bump
git-svn-id: http://svn.miranda-ng.org/main/trunk@11020 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM')
-rw-r--r-- | protocols/FacebookRM/res/facebook.rc | 13 | ||||
-rw-r--r-- | protocols/FacebookRM/src/chat.cpp | 26 | ||||
-rw-r--r-- | protocols/FacebookRM/src/client.h | 3 | ||||
-rw-r--r-- | protocols/FacebookRM/src/connection.cpp | 2 | ||||
-rw-r--r-- | protocols/FacebookRM/src/constants.h | 4 | ||||
-rw-r--r-- | protocols/FacebookRM/src/db.h | 1 | ||||
-rw-r--r-- | protocols/FacebookRM/src/dialogs.cpp | 3 | ||||
-rw-r--r-- | protocols/FacebookRM/src/entities.h | 4 | ||||
-rw-r--r-- | protocols/FacebookRM/src/json.cpp | 17 | ||||
-rw-r--r-- | protocols/FacebookRM/src/process.cpp | 73 | ||||
-rw-r--r-- | protocols/FacebookRM/src/proto.cpp | 42 | ||||
-rw-r--r-- | protocols/FacebookRM/src/proto.h | 3 | ||||
-rw-r--r-- | protocols/FacebookRM/src/resource.h | 3 | ||||
-rw-r--r-- | protocols/FacebookRM/src/version.h | 2 |
14 files changed, 154 insertions, 42 deletions
diff --git a/protocols/FacebookRM/res/facebook.rc b/protocols/FacebookRM/res/facebook.rc index 61cd38d25d..fdb94969ac 100644 --- a/protocols/FacebookRM/res/facebook.rc +++ b/protocols/FacebookRM/res/facebook.rc @@ -121,7 +121,7 @@ BEGIN CONTROL "Use bigger avatars",IDC_BIGGER_AVATARS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,114,271,10
END
-IDD_OPTIONS_EVENTS DIALOGEX 0, 0, 305, 166
+IDD_OPTIONS_EVENTS DIALOGEX 0, 0, 305, 185
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 400, 0, 0x1
@@ -134,10 +134,12 @@ BEGIN COMBOBOX IDC_FEED_TYPE,150,49,138,59,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "Don't show advertising posts",IDC_FILTER_ADS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,150,67,138,8
CONTROL "Other events",IDC_OTHER_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,79,272,8
- CONTROL "Client notifications",IDC_CLIENT_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,95,272,8
- PUSHBUTTON "Preview",IDC_PREVIEW,117,137,68,14
+ CONTROL "Client notifications",IDC_CLIENT_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,95,272,8
CONTROL "Use balloon notifications in system tray instead of popups",IDC_SYSTRAY_NOTIFY,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,121,272,8
+ CONTROL "Use logging notifications into special chatroom",IDC_NOTIFICATIONS_CHATROOM,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,138,272,8
+ PUSHBUTTON "Preview",IDC_PREVIEW,116,156,68,14
END
IDD_OPTIONS_ADVANCED DIALOGEX 0, 0, 308, 242
@@ -252,7 +254,7 @@ BEGIN VERTGUIDE, 150
VERTGUIDE, 288
TOPMARGIN, 7
- BOTTOMMARGIN, 158
+ BOTTOMMARGIN, 177
END
IDD_OPTIONS_ADVANCED, DIALOG
@@ -280,7 +282,8 @@ END //
// Generated from the TEXTINCLUDE 3 resource.
//
-
+
+
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
diff --git a/protocols/FacebookRM/src/chat.cpp b/protocols/FacebookRM/src/chat.cpp index 178ab890d4..684abe0671 100644 --- a/protocols/FacebookRM/src/chat.cpp +++ b/protocols/FacebookRM/src/chat.cpp @@ -24,7 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #include <m_history.h>
#include <m_userinfo.h>
-void FacebookProto::UpdateChat(const TCHAR *tchat_id, const char *id, const char *name, const char *message, DWORD timestamp)
+void FacebookProto::UpdateChat(const TCHAR *tchat_id, const char *id, const char *name, const char *message, DWORD timestamp, bool is_old)
{
// replace % to %% to not interfere with chat color codes
std::string smessage = message;
@@ -41,6 +41,10 @@ void FacebookProto::UpdateChat(const TCHAR *tchat_id, const char *id, const char if (id != NULL)
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));
@@ -67,7 +71,11 @@ int FacebookProto::OnGCEvent(WPARAM wParam,LPARAM lParam) {
GCHOOK *hook = reinterpret_cast<GCHOOK*>(lParam);
- if (strcmp(hook->pDest->pszModule,m_szModuleName))
+ if (strcmp(hook->pDest->pszModule, m_szModuleName))
+ return 0;
+
+ // Ignore for special chatrooms
+ if (!_tcscmp(hook->pDest->ptszID, _T(FACEBOOK_NOTIFICATIONS_CHATROOM)))
return 0;
switch(hook->pDest->iType)
@@ -291,9 +299,13 @@ INT_PTR FacebookProto::OnJoinChat(WPARAM hContact, LPARAM suppress) return 0;
}
-INT_PTR FacebookProto::OnLeaveChat(WPARAM,LPARAM)
+INT_PTR FacebookProto::OnLeaveChat(WPARAM wParam,LPARAM)
{
GCDEST gcd = { m_szModuleName, NULL, GC_EVENT_CONTROL };
+ if (wParam != NULL) {
+ gcd.ptszID = ptrT( getTStringA(wParam, "ChatRoomID"));
+ }
+
GCEVENT gce = { sizeof(gce), &gcd };
gce.time = ::time(NULL);
@@ -372,3 +384,11 @@ int FacebookProto::OnGCMenuHook(WPARAM, LPARAM lParam) return 0;
}
+
+bool FacebookProto::isSpecialChatRoom(MCONTACT hContact) {
+ if (!isChatRoom(hContact))
+ return false;
+
+ ptrT idT(getTStringA(hContact, "ChatRoomID"));
+ return idT && !_tcscmp(idT, _T(FACEBOOK_NOTIFICATIONS_CHATROOM));
+}
\ No newline at end of file diff --git a/protocols/FacebookRM/src/client.h b/protocols/FacebookRM/src/client.h index 58bbeb5a41..c4087c5f4c 100644 --- a/protocols/FacebookRM/src/client.h +++ b/protocols/FacebookRM/src/client.h @@ -45,7 +45,7 @@ public: https_ = is_idle_ = is_typing_ = false;
- buddies_lock_ = send_message_lock_ = NULL;
+ buddies_lock_ = send_message_lock_ = notifications_lock_ = NULL;
hMsgCon = NULL;
hFcbCon = NULL;
fcb_conn_lock_ = NULL;
@@ -179,6 +179,7 @@ public: List::List<facebook_user> buddies;
HANDLE buddies_lock_;
HANDLE send_message_lock_;
+ HANDLE notifications_lock_;
////////////////////////////////////////////////////////////
diff --git a/protocols/FacebookRM/src/connection.cpp b/protocols/FacebookRM/src/connection.cpp index a53e3e488c..d1a10bb756 100644 --- a/protocols/FacebookRM/src/connection.cpp +++ b/protocols/FacebookRM/src/connection.cpp @@ -92,6 +92,8 @@ void FacebookProto::ChangeStatus(void*) debugLogA("***** Beginning SignOn process"); + m_enableChat = getBool(FACEBOOK_KEY_ENABLE_CHAT, true); + m_iStatus = facy.self_.status_id = ID_STATUS_CONNECTING; ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, m_iStatus); diff --git a/protocols/FacebookRM/src/constants.h b/protocols/FacebookRM/src/constants.h index b0ec0d555b..3bd34a0ff0 100644 --- a/protocols/FacebookRM/src/constants.h +++ b/protocols/FacebookRM/src/constants.h @@ -49,6 +49,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define FACEBOOK_CLIENT_APP "Facebook App"
#define FACEBOOK_CLIENT_MESSENGER "Facebook Messenger"
+// Various constants
+#define FACEBOOK_NOTIFICATIONS_CHATROOM "_notifications"
+
// Limits
#define FACEBOOK_MESSAGE_LIMIT 200000 // this is guessed limit, in reality it is bigger
#define FACEBOOK_MESSAGE_LIMIT_TEXT "200000"
@@ -84,6 +87,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define DEFAULT_MESSAGES_ON_OPEN 0
#define DEFAULT_MESSAGES_ON_OPEN_COUNT 10
#define DEFAULT_HIDE_CHATS 0
+#define DEFAULT_NOTIFICATIONS_CHATROOM 0
#define DEFAULT_EVENT_NOTIFICATIONS_ENABLE 1
#define DEFAULT_EVENT_FEEDS_ENABLE 0
diff --git a/protocols/FacebookRM/src/db.h b/protocols/FacebookRM/src/db.h index 4cf23ee489..a397e46fe3 100644 --- a/protocols/FacebookRM/src/db.h +++ b/protocols/FacebookRM/src/db.h @@ -67,6 +67,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define FACEBOOK_KEY_MESSAGES_ON_OPEN "MessagesOnOpen"
#define FACEBOOK_KEY_MESSAGES_ON_OPEN_COUNT "MessagesOnOpenCount"
#define FACEBOOK_KEY_HIDE_CHATS "HideChats"
+#define FACEBOOK_KEY_NOTIFICATIONS_CHATROOM "NotificationsChatroom"
// Account DB keys - notifications
#define FACEBOOK_KEY_EVENT_NOTIFICATIONS_ENABLE "EventNotificationsEnable"
diff --git a/protocols/FacebookRM/src/dialogs.cpp b/protocols/FacebookRM/src/dialogs.cpp index bf2687a79d..0e13fc8317 100644 --- a/protocols/FacebookRM/src/dialogs.cpp +++ b/protocols/FacebookRM/src/dialogs.cpp @@ -551,6 +551,7 @@ INT_PTR CALLBACK FBEventsProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lpa } SendDlgItemMessage(hwnd, IDC_FEED_TYPE, CB_SETCURSEL, proto->getByte(FACEBOOK_KEY_FEED_TYPE, 0), 0); LoadDBCheckState(proto, hwnd, IDC_SYSTRAY_NOTIFY, FACEBOOK_KEY_SYSTRAY_NOTIFY, DEFAULT_SYSTRAY_NOTIFY); + LoadDBCheckState(proto, hwnd, IDC_NOTIFICATIONS_CHATROOM, FACEBOOK_KEY_NOTIFICATIONS_CHATROOM, DEFAULT_NOTIFICATIONS_CHATROOM); LoadDBCheckState(proto, hwnd, IDC_NOTIFICATIONS_ENABLE, FACEBOOK_KEY_EVENT_NOTIFICATIONS_ENABLE, DEFAULT_EVENT_NOTIFICATIONS_ENABLE); LoadDBCheckState(proto, hwnd, IDC_FEEDS_ENABLE, FACEBOOK_KEY_EVENT_FEEDS_ENABLE, DEFAULT_EVENT_FEEDS_ENABLE); @@ -585,6 +586,8 @@ INT_PTR CALLBACK FBEventsProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lpa proto->setByte(FACEBOOK_KEY_FEED_TYPE, SendDlgItemMessage(hwnd, IDC_FEED_TYPE, CB_GETCURSEL, 0, 0)); StoreDBCheckState(proto, hwnd, IDC_SYSTRAY_NOTIFY, FACEBOOK_KEY_SYSTRAY_NOTIFY); + StoreDBCheckState(proto, hwnd, IDC_NOTIFICATIONS_CHATROOM, FACEBOOK_KEY_NOTIFICATIONS_CHATROOM); + StoreDBCheckState(proto, hwnd, IDC_NOTIFICATIONS_ENABLE, FACEBOOK_KEY_EVENT_NOTIFICATIONS_ENABLE); StoreDBCheckState(proto, hwnd, IDC_FEEDS_ENABLE, FACEBOOK_KEY_EVENT_FEEDS_ENABLE); StoreDBCheckState(proto, hwnd, IDC_OTHER_ENABLE, FACEBOOK_KEY_EVENT_OTHER_ENABLE); diff --git a/protocols/FacebookRM/src/entities.h b/protocols/FacebookRM/src/entities.h index 3636b3508c..d4e86bc652 100644 --- a/protocols/FacebookRM/src/entities.h +++ b/protocols/FacebookRM/src/entities.h @@ -148,13 +148,17 @@ struct facebook_notification std::string text; std::string link; std::string id; + time_t time; bool seen; + bool written; HWND hWndPopup; facebook_notification() { this->user_id = this->text = this->link = this->id = ""; + this->time = 0; this->seen = false; + this->written = false; this->hWndPopup = NULL; } }; diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp index 12a90a2020..e6654517c2 100644 --- a/protocols/FacebookRM/src/json.cpp +++ b/protocols/FacebookRM/src/json.cpp @@ -247,16 +247,19 @@ int facebook_json_parser::parse_notifications(void *data, std::map< std::string, return EXIT_FAILURE; } + // check if we should use use local_timestamp for unread messages and use it for notifications time too + bool local_timestamp = proto->getBool(FACEBOOK_KEY_LOCAL_TIMESTAMP_UNREAD, 0); + for (unsigned int i = 0; i < json_size(list); i++) { JSONNODE *it = json_at(list, i); const char *id = json_name(it); JSONNODE *markup = json_get(it, "markup"); JSONNODE *unread = json_get(it, "unread"); - //JSONNODE *time = json_get(it, "time"); + JSONNODE *time = json_get(it, "time"); // Ignore empty and old notifications - if (markup == NULL || unread == NULL || json_as_int(unread) == 0) + if (markup == NULL || unread == NULL || time == NULL) continue; std::string text = utils::text::html_entities_decode(utils::text::slashu_to_utf8(json_as_pstring(markup))); @@ -266,6 +269,8 @@ int facebook_json_parser::parse_notifications(void *data, std::map< std::string, notification->id = id; notification->link = utils::text::source_get_value(&text, 3, "<a ", "href=\"", "\""); notification->text = utils::text::remove_html(utils::text::source_get_value(&text, 1, "<abbr")); + notification->seen = (json_as_int(unread) == 0); + notification->time = local_timestamp ? ::time(NULL) : utils::time::fix_timestamp(json_as_float(time)); if (notifications->find(notification->id) == notifications->end()) notifications->insert(std::make_pair(notification->id, notification)); @@ -564,6 +569,9 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa // event notification JSONNODE *nodes = json_get(it, "nodes"); + // check if we should use use local_timestamp for unread messages and use it for notifications time too + bool local_timestamp = proto->getBool(FACEBOOK_KEY_LOCAL_TIMESTAMP_UNREAD, 0); + for (unsigned int j = 0; j < json_size(nodes); j++) { JSONNODE *itNodes = json_at(nodes, j); @@ -582,15 +590,16 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa if (time == NULL || text == NULL || url == NULL || alert_id == NULL) continue; - unsigned __int64 timestamp = json_as_float(time); + double timestamp = json_as_float(time); if (timestamp > proto->facy.last_notification_time_) { // Only new notifications proto->facy.last_notification_time_ = timestamp; 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) diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp index 579779e201..97340db7ca 100644 --- a/protocols/FacebookRM/src/process.cpp +++ b/protocols/FacebookRM/src/process.cpp @@ -463,6 +463,9 @@ void FacebookProto::LoadLastMessages(void *p) bool isChat = isChatRoom(hContact); + if (isSpecialChatRoom(hContact)) // e.g. nofitications + return; + if (isChat && !m_enableChat) return; @@ -868,15 +871,69 @@ exit: } void FacebookProto::ShowNotifications() { - if (!getByte(FACEBOOK_KEY_EVENT_NOTIFICATIONS_ENABLE, DEFAULT_EVENT_NOTIFICATIONS_ENABLE)) - return; - + ScopedLock s(facy.notifications_lock_); + + bool showPopups = getBool(FACEBOOK_KEY_EVENT_NOTIFICATIONS_ENABLE, DEFAULT_EVENT_NOTIFICATIONS_ENABLE); + bool useChatRoom = getBool(FACEBOOK_KEY_NOTIFICATIONS_CHATROOM, DEFAULT_NOTIFICATIONS_CHATROOM); + + char *notificationName = _T2A(TranslateT("Notification"), CP_UTF8); + + if (useChatRoom) { + // Prepare chatroom if not exists + TCHAR *gidT = _T(FACEBOOK_NOTIFICATIONS_CHATROOM); + + MCONTACT hNotificationsChatRoom = ChatIDToHContact(gidT); + if (hNotificationsChatRoom == NULL || getDword(hNotificationsChatRoom, "Status", ID_STATUS_OFFLINE) != ID_STATUS_ONLINE) { + TCHAR nameT[200]; + mir_sntprintf(nameT, SIZEOF(nameT), _T("%s: %s"), m_tszUserName, TranslateT("Notifications")); + + // Create the group chat session + GCSESSION gcw = { sizeof(gcw) }; + gcw.iType = GCW_PRIVMESS; + gcw.ptszID = gidT; + gcw.pszModule = m_szModuleName; + gcw.ptszName = nameT; + CallServiceSync(MS_GC_NEWSESSION, 0, (LPARAM)&gcw); + + // Send setting events + GCDEST gcd = { m_szModuleName, gidT, GC_EVENT_CONTROL }; + GCEVENT gce = { sizeof(gce), &gcd }; + gce.time = ::time(NULL); + + CallServiceSync(MS_GC_EVENT, WINDOW_HIDDEN, reinterpret_cast<LPARAM>(&gce)); + CallServiceSync(MS_GC_EVENT, SESSION_ONLINE, reinterpret_cast<LPARAM>(&gce)); + } + + hNotificationsChatRoom = ChatIDToHContact(gidT); + useChatRoom = (hNotificationsChatRoom != NULL && getDword(hNotificationsChatRoom, "Status", ID_STATUS_OFFLINE) == ID_STATUS_ONLINE); + } + + // Show popups for unseen notifications and/or write them to chatroom for (std::map<std::string, facebook_notification*>::iterator it = facy.notifications.begin(); it != facy.notifications.end(); ++it) { - if (it->second != NULL && !it->second->seen) { - debugLogA(" Got notification: %s", it->second->text.c_str()); - ptrT szText(mir_utf8decodeT(it->second->text.c_str())); - it->second->hWndPopup = NotifyEvent(m_tszUserName, szText, ContactIDToHContact(it->second->user_id), FACEBOOK_EVENT_NOTIFICATION, &it->second->link, &it->second->id); - it->second->seen = true; + if (it->second != NULL) { + if (useChatRoom && !it->second->written) { + it->second->written = true; + + std::stringstream text; + text << it->second->text << "\n\n" << it->second->link; + UpdateChat(_T(FACEBOOK_NOTIFICATIONS_CHATROOM), ""/*it->second->user_id.c_str()*/, notificationName, text.str().c_str(), it->second->time, it->second->seen); + } + + if (showPopups && !it->second->seen) { + it->second->seen = true; + + debugLogA(" Showing popup for notification: %s", it->second->text.c_str()); + ptrT szText(mir_utf8decodeT(it->second->text.c_str())); + it->second->hWndPopup = NotifyEvent(m_tszUserName, szText, ContactIDToHContact(it->second->user_id), FACEBOOK_EVENT_NOTIFICATION, &it->second->link, &it->second->id); + } + } + } + + // Remove old seen and processed (without hWndPopup handle) notifications from map + for (std::map<std::string, facebook_notification*>::iterator it = facy.notifications.begin(); it != facy.notifications.end();) { + if (it->second != NULL && it->second->seen && it->second->hWndPopup == NULL) { + delete it->second; + it = facy.notifications.erase(it); } } } diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp index 2abb8323ee..a3d0564ec9 100644 --- a/protocols/FacebookRM/src/proto.cpp +++ b/protocols/FacebookRM/src/proto.cpp @@ -34,10 +34,10 @@ FacebookProto::FacebookProto(const char* proto_name,const TCHAR* username) : facy.buddies_lock_ = CreateMutex(NULL, FALSE, NULL); facy.send_message_lock_ = CreateMutex(NULL, FALSE, NULL); facy.fcb_conn_lock_ = CreateMutex(NULL, FALSE, NULL); + facy.notifications_lock_ = CreateMutex(NULL, FALSE, NULL); m_invisible = false; m_signingOut = false; - m_enableChat = getBool(FACEBOOK_KEY_ENABLE_CHAT, true); // Load custom locale, if set ptrA locale( getStringA(FACEBOOK_KEY_LOCALE)); @@ -51,10 +51,8 @@ FacebookProto::FacebookProto(const char* proto_name,const TCHAR* username) : CreateProtoService(PS_GETAVATARCAPS, &FacebookProto::GetAvatarCaps); CreateProtoService(PS_GETUNREADEMAILCOUNT, &FacebookProto::GetNotificationsCount); - if (m_enableChat) { - 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); @@ -119,6 +117,7 @@ FacebookProto::~FacebookProto() WaitForSingleObject(log_lock_, IGNORE); WaitForSingleObject(facy.buddies_lock_, IGNORE); WaitForSingleObject(facy.send_message_lock_, IGNORE); + WaitForSingleObject(facy.notifications_lock_, IGNORE); CloseHandle(signon_lock_); CloseHandle(avatar_lock_); @@ -127,6 +126,7 @@ FacebookProto::~FacebookProto() CloseHandle(facy.buddies_lock_); CloseHandle(facy.send_message_lock_); CloseHandle(facy.fcb_conn_lock_); + CloseHandle(facy.notifications_lock_); } ////////////////////////////////////////////////////////////////////////////// @@ -137,7 +137,7 @@ DWORD_PTR FacebookProto::GetCaps(int type, MCONTACT hContact) { case PFLAGNUM_1: { - DWORD_PTR flags = PF1_IM | (m_enableChat ? PF1_CHAT : 0) | PF1_SERVERCLIST | PF1_AUTHREQ | /*PF1_ADDED |*/ PF1_BASICSEARCH | PF1_SEARCHBYEMAIL | PF1_SEARCHBYNAME | PF1_ADDSEARCHRES; // | PF1_VISLIST | PF1_INVISLIST; + 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; if (getByte(FACEBOOK_KEY_SET_MIRANDA_STATUS, 0)) return flags |= PF1_MODEMSG; @@ -437,16 +437,14 @@ INT_PTR FacebookProto::SvcCreateAccMgrUI(WPARAM wParam, LPARAM lParam) int FacebookProto::OnModulesLoaded(WPARAM wParam, LPARAM lParam) { // Register group chat - if (m_enableChat) { - 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)); - } + 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; } @@ -663,7 +661,17 @@ INT_PTR FacebookProto::VisitConversation(WPARAM wParam, LPARAM lParam) INT_PTR FacebookProto::VisitNotifications(WPARAM wParam, LPARAM lParam) { - OpenUrl(FACEBOOK_URL_NOTIFICATIONS); + /*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)); + } + else {*/ + OpenUrl(FACEBOOK_URL_NOTIFICATIONS); + /*}*/ + return 0; } diff --git a/protocols/FacebookRM/src/proto.h b/protocols/FacebookRM/src/proto.h index 45e70fc114..78f30c2563 100644 --- a/protocols/FacebookRM/src/proto.h +++ b/protocols/FacebookRM/src/proto.h @@ -212,7 +212,7 @@ public: // Chats handling void AddChat(const TCHAR *id, const TCHAR *name); - void UpdateChat(const TCHAR *chat_id, const char *id, const char *name, const char *message, DWORD timestamp = 0); + void UpdateChat(const TCHAR *chat_id, const char *id, const char *name, const char *message, DWORD timestamp = 0, bool is_old = false); void RenameChat(const char *chat_id, const char *name); bool IsChatContact(const TCHAR *chat_id, const char *id); void AddChatContact(const TCHAR *chat_id, const char *id, const char *name); @@ -222,6 +222,7 @@ public: void ReceiveMessages(std::vector<facebook_message*> messages, bool local_timestamp, bool check_duplicates = false); void LoadChatInfo(facebook_chatroom* fbc); void LoadParticipantsNames(facebook_chatroom *fbc); + bool isSpecialChatRoom(MCONTACT hContact); // Connection client facebook_client facy; // TODO: Refactor to "client" and make dynamic diff --git a/protocols/FacebookRM/src/resource.h b/protocols/FacebookRM/src/resource.h index a16c1e325d..6c73fcf362 100644 --- a/protocols/FacebookRM/src/resource.h +++ b/protocols/FacebookRM/src/resource.h @@ -35,7 +35,6 @@ #define IDC_LOAD_PAGES 1036
#define IDC_KEEP_UNREAD 1037
#define IDC_INBOX_ONLY 1038
-#define IDC_INBOX_ONLY2 1039
#define IDC_MESSAGES_ON_OPEN 1039
#define IDC_HIDE_CHATS 1040
#define IDC_NOTIFICATIONS_ENABLE 1041
@@ -46,6 +45,7 @@ #define IDC_LOGIN_SYNC 1046
#define IDC_SYSTRAY_NOTIFY 1098
#define IDC_PREVIEW 1099
+#define IDC_NOTIFICATIONS_CHATROOM 1100
#define IDC_SET_STATUS 1126
#define IDC_FEED_TYPE 1201
#define IDC_URL_SERVER 1202
@@ -65,7 +65,6 @@ #define IDC_FRAME2 1216
#define IDC_SUBMIT 1217
-
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
diff --git a/protocols/FacebookRM/src/version.h b/protocols/FacebookRM/src/version.h index 470d5e5f2f..ca41904b5c 100644 --- a/protocols/FacebookRM/src/version.h +++ b/protocols/FacebookRM/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0
#define __MINOR_VERSION 2
#define __RELEASE_NUM 9
-#define __BUILD_NUM 5
+#define __BUILD_NUM 6
#include <stdver.h>
|