diff options
author | Robert Pösel <robyer@seznam.cz> | 2014-12-23 15:30:02 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2014-12-23 15:30:02 +0000 |
commit | 2cd071fd8de860655b981d22ecac139cd6e4411b (patch) | |
tree | c6a498931e92b126076ad98af0205543c108af62 /protocols | |
parent | 716eea6998bf896c6180d1ef42bbc7ef9406729d (diff) |
Facebook: Remove support for "use local timestamp for messages"
It's not needed anymore because we correctly set server time for sent messages, so everything will be consistent (in server time)
git-svn-id: http://svn.miranda-ng.org/main/trunk@11598 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/FacebookRM/res/facebook.rc | 29 | ||||
-rw-r--r-- | protocols/FacebookRM/src/communication.cpp | 3 | ||||
-rw-r--r-- | protocols/FacebookRM/src/connection.cpp | 1 | ||||
-rw-r--r-- | protocols/FacebookRM/src/constants.h | 1 | ||||
-rw-r--r-- | protocols/FacebookRM/src/contacts.cpp | 2 | ||||
-rw-r--r-- | protocols/FacebookRM/src/db.h | 2 | ||||
-rw-r--r-- | protocols/FacebookRM/src/dialogs.cpp | 2 | ||||
-rw-r--r-- | protocols/FacebookRM/src/json.cpp | 17 | ||||
-rw-r--r-- | protocols/FacebookRM/src/process.cpp | 24 | ||||
-rw-r--r-- | protocols/FacebookRM/src/proto.h | 2 | ||||
-rw-r--r-- | protocols/FacebookRM/src/resource.h | 1 | ||||
-rw-r--r-- | protocols/FacebookRM/src/utils.cpp | 4 |
12 files changed, 29 insertions, 59 deletions
diff --git a/protocols/FacebookRM/res/facebook.rc b/protocols/FacebookRM/res/facebook.rc index 7ca22fce7c..6a55a18f9e 100644 --- a/protocols/FacebookRM/res/facebook.rc +++ b/protocols/FacebookRM/res/facebook.rc @@ -184,28 +184,26 @@ STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD EXSTYLE WS_EX_CONTROLPARENT
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
- GROUPBOX "Messages",IDC_STATIC,7,7,294,70
+ GROUPBOX "Messages",IDC_STATIC,7,7,294,57
CONTROL "Receive messages from ""inbox"" folder only",IDC_INBOX_ONLY,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,19,281,10
- CONTROL "Use local time for received messages",IDC_USE_LOCAL_TIME,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,33,281,10
CONTROL "Keep messages as unread on server (don't send ""seen"" info)",IDC_KEEP_UNREAD,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,47,281,10
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,33,281,10
CONTROL "Show stickers as custom smileys (EXPERIMENTAL)",IDC_CUSTOM_SMILEYS,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,61,281,10
- GROUPBOX "Multi user chats",IDC_STATIC,7,83,294,43
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,48,281,10
+ GROUPBOX "Multi user chats",IDC_STATIC,7,70,294,43
CONTROL "Enable multi user chats support",IDC_ENABLE_CHATS,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,96,281,10
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,83,281,10
CONTROL "Do not open chat windows on creation",IDC_HIDE_CHATS,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,110,281,10
- GROUPBOX "History synchronization",IDC_STATIC,7,134,294,59
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,97,281,10
+ GROUPBOX "History synchronization",IDC_STATIC,7,121,294,59
CONTROL "Load last messages (24 hours old) on login (EXPERIMENTAL)",IDC_LOGIN_SYNC,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,148,281,10
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,135,281,10
CONTROL "Load last messages on opening message window (EXPERIMENTAL)",IDC_MESSAGES_ON_OPEN,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,162,281,10
- RTEXT "Number of messages to load:",IDC_STATIC,13,176,231,8
- EDITTEXT IDC_MESSAGES_COUNT,249,173,34,14,ES_AUTOHSCROLL
- CONTROL "",IDC_MESSAGES_COUNT_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,283,173,11,14
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,149,281,10
+ RTEXT "Number of messages to load:",IDC_STATIC,13,163,231,8
+ EDITTEXT IDC_MESSAGES_COUNT,249,160,34,14,ES_AUTOHSCROLL
+ CONTROL "",IDC_MESSAGES_COUNT_SPIN,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,283,160,11,14
END
@@ -308,8 +306,7 @@ END //
// Generated from the TEXTINCLUDE 3 resource.
//
-
-
+
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp index e1518f4f8e..2150ff6ab5 100644 --- a/protocols/FacebookRM/src/communication.cpp +++ b/protocols/FacebookRM/src/communication.cpp @@ -1340,8 +1340,7 @@ int facebook_client::send_message(int seqid, MCONTACT hContact, const std::strin parent->setString(FACEBOOK_KEY_LAST_ACTION_TIMESTAMP, timestamp.c_str()); // For classic conversation we try to remember and then replace timestamp of added event in OnPreCreateEvent() - bool localTimestamp = parent->getBool(FACEBOOK_KEY_LOCAL_TIMESTAMP, DEFAULT_LOCAL_TIME); - if (seqid > 0 && !localTimestamp) { + if (seqid > 0) { long long time = _atoi64(timestamp.c_str()); if (time > 100000000000) time /= 1000; diff --git a/protocols/FacebookRM/src/connection.cpp b/protocols/FacebookRM/src/connection.cpp index 9dce31dae5..bb056eb711 100644 --- a/protocols/FacebookRM/src/connection.cpp +++ b/protocols/FacebookRM/src/connection.cpp @@ -52,7 +52,6 @@ void FacebookProto::ChangeStatus(void*) OnLeaveChat(NULL, NULL); SetAllContactStatuses(ID_STATUS_OFFLINE); ToggleStatusMenuItems(false); - // setString(FACEBOOK_KEY_LAST_ACTION_TIMESTAMP, utils::time::mili_timestamp().c_str()); // TODO RM: this should't be here because of different local/server time delSetting(FACEBOOK_KEY_LOGON_TS); facy.clear_cookies(); diff --git a/protocols/FacebookRM/src/constants.h b/protocols/FacebookRM/src/constants.h index 4ffcf4a848..a3e8311a2d 100644 --- a/protocols/FacebookRM/src/constants.h +++ b/protocols/FacebookRM/src/constants.h @@ -78,7 +78,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define DEFAULT_DISCONNECT_CHAT 0
#define DEFAULT_MAP_STATUSES 0
#define DEFAULT_CUSTOM_SMILEYS 0
-#define DEFAULT_LOCAL_TIME 1
#define DEFAULT_LOAD_PAGES 0
#define DEFAULT_KEEP_UNREAD 0
#define DEFAULT_INBOX_ONLY 0
diff --git a/protocols/FacebookRM/src/contacts.cpp b/protocols/FacebookRM/src/contacts.cpp index 69db741249..e36b120c4e 100644 --- a/protocols/FacebookRM/src/contacts.cpp +++ b/protocols/FacebookRM/src/contacts.cpp @@ -308,7 +308,7 @@ void FacebookProto::LoadChatInfo(facebook_chatroom *fbc) fbc->chat_name = fbc->thread_id; // TODO: is this needed? Isn't it showed automatically as id if there is no name? } - //ReceiveMessages(messages, local_timestamp, true); // don't let it fall into infinite cycle, solve it somehow... + //ReceiveMessages(messages, true); // don't let it fall into infinite cycle, solve it somehow... debugLogA("***** Chat thread info processed"); diff --git a/protocols/FacebookRM/src/db.h b/protocols/FacebookRM/src/db.h index 1798ce1cea..1205f3b763 100644 --- a/protocols/FacebookRM/src/db.h +++ b/protocols/FacebookRM/src/db.h @@ -54,7 +54,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define FACEBOOK_KEY_MAP_STATUSES "MapStatuses"
#define FACEBOOK_KEY_CUSTOM_SMILEYS "CustomSmileys"
#define FACEBOOK_KEY_SERVER_TYPE "ServerType"
-#define FACEBOOK_KEY_LOCAL_TIMESTAMP "UseLocalTimestamp"
#define FACEBOOK_KEY_PRIVACY_TYPE "PrivacyType"
#define FACEBOOK_KEY_PLACE "Place"
#define FACEBOOK_KEY_LAST_WALL "LastWall"
@@ -81,7 +80,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define FACEBOOK_KEY_POLL_RATE "PollRate" // [HIDDEN] - (byte)
#define FACEBOOK_KEY_TIMEOUTS_LIMIT "TimeoutsLimit" // [HIDDEN] - (byte)
#define FACEBOOK_KEY_LOCALE "Locale" // [HIDDEN] - (string) en_US, cs_CZ, etc. (requires restart to apply)
-#define FACEBOOK_KEY_LOCAL_TIMESTAMP_UNREAD "UseLocalTimestampUnread" // [HIDDEN] - (byte) 1 = use local timestamp for offline messages
#define FACEBOOK_KEY_NASEEMS_SPAM_MODE "NaseemsSpamMode" // [HIDDEN] - (byte) 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] - (byte) 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
diff --git a/protocols/FacebookRM/src/dialogs.cpp b/protocols/FacebookRM/src/dialogs.cpp index 36774e2ca5..7ac8aa1337 100644 --- a/protocols/FacebookRM/src/dialogs.cpp +++ b/protocols/FacebookRM/src/dialogs.cpp @@ -589,7 +589,6 @@ INT_PTR CALLBACK FBOptionsMessagingProc(HWND hwnd, UINT message, WPARAM wparam, SetWindowLongPtr(hwnd, GWLP_USERDATA, lparam); LoadDBCheckState(proto, hwnd, IDC_CUSTOM_SMILEYS, FACEBOOK_KEY_CUSTOM_SMILEYS, DEFAULT_CUSTOM_SMILEYS); - LoadDBCheckState(proto, hwnd, IDC_USE_LOCAL_TIME, FACEBOOK_KEY_LOCAL_TIMESTAMP, DEFAULT_LOCAL_TIME); LoadDBCheckState(proto, hwnd, IDC_INBOX_ONLY, FACEBOOK_KEY_INBOX_ONLY, DEFAULT_INBOX_ONLY); 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); @@ -624,7 +623,6 @@ INT_PTR CALLBACK FBOptionsMessagingProc(HWND hwnd, UINT message, WPARAM wparam, if (reinterpret_cast<NMHDR*>(lparam)->code == PSN_APPLY) { StoreDBCheckState(proto, hwnd, IDC_CUSTOM_SMILEYS, FACEBOOK_KEY_CUSTOM_SMILEYS); - StoreDBCheckState(proto, hwnd, IDC_USE_LOCAL_TIME, FACEBOOK_KEY_LOCAL_TIMESTAMP); StoreDBCheckState(proto, hwnd, IDC_INBOX_ONLY, FACEBOOK_KEY_INBOX_ONLY); StoreDBCheckState(proto, hwnd, IDC_KEEP_UNREAD, FACEBOOK_KEY_KEEP_UNREAD); StoreDBCheckState(proto, hwnd, IDC_LOGIN_SYNC, FACEBOOK_KEY_LOGIN_SYNC); diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp index 369f94c31f..701b88f633 100644 --- a/protocols/FacebookRM/src/json.cpp +++ b/protocols/FacebookRM/src/json.cpp @@ -240,9 +240,6 @@ int facebook_json_parser::parse_notifications(std::string *data, std::map< std:: 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); - // Create notifications chatroom (if it doesn't exists), because we will be writing to it new notifications here proto->PrepareNotificationsChatRoom(); @@ -265,7 +262,7 @@ int facebook_json_parser::parse_notifications(std::string *data, std::map< std:: 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->time = local_timestamp ? ::time(NULL) : utils::time::fix_timestamp(json_as_float(time)); + notification->time = utils::time::fix_timestamp(json_as_float(time)); // Write notification to chatroom proto->UpdateNotificationsChatRoom(notification); @@ -445,12 +442,7 @@ int facebook_json_parser::parse_messages(std::string *data, std::vector< faceboo if (reader == NULL || time == NULL) continue; - // check if we should use use local_timestamp for incoming messages and use it for read time too - /*bool local_timestamp = proto->getBool(FACEBOOK_KEY_LOCAL_TIMESTAMP, DEFAULT_LOCAL_TIME); - time_t timestamp = local_timestamp ? ::time(NULL) : utils::time::fix_timestamp(json_as_float(time));*/ - - // we can always use NOW for read time, because that's the time of receiving this event (+-) - time_t timestamp = ::time(NULL); + time_t timestamp = utils::time::fix_timestamp(json_as_float(time)); JSONNODE *threadid = json_get(it, "tid"); if (threadid != NULL) { // multi user chat @@ -576,9 +568,6 @@ int facebook_json_parser::parse_messages(std::string *data, std::vector< faceboo // 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); - // Create notifications chatroom (if it doesn't exists), because we will be writing to it new notifications here proto->PrepareNotificationsChatRoom(); @@ -609,7 +598,7 @@ int facebook_json_parser::parse_messages(std::string *data, std::vector< faceboo notification->text = utils::text::slashu_to_utf8(json_as_pstring(text)); notification->link = json_as_pstring(url); notification->id = json_as_pstring(alert_id); - notification->time = local_timestamp ? ::time(NULL) : utils::time::fix_timestamp(timestamp); + notification->time = 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 4af8154cdd..bfe0f458eb 100644 --- a/protocols/FacebookRM/src/process.cpp +++ b/protocols/FacebookRM/src/process.cpp @@ -355,8 +355,6 @@ void FacebookProto::ProcessUnreadMessage(void *data) int offset = 0; int limit = 21; - bool local_timestamp = getBool(FACEBOOK_KEY_LOCAL_TIMESTAMP_UNREAD, 0); - // receive messages from all folders by default, use hidden setting to receive only inbox messages bool inboxOnly = getBool(FACEBOOK_KEY_INBOX_ONLY, 0); @@ -424,7 +422,7 @@ void FacebookProto::ProcessUnreadMessage(void *data) } chatrooms.clear(); - ReceiveMessages(messages, local_timestamp, true); + ReceiveMessages(messages, true); debugLogA("***** Unread messages processed"); @@ -544,8 +542,7 @@ void FacebookProto::LoadLastMessages(void *p) } chatrooms.clear();*/ - bool local_timestamp = getBool(FACEBOOK_KEY_LOCAL_TIMESTAMP_UNREAD, 0); - ReceiveMessages(messages, local_timestamp, true); + ReceiveMessages(messages, true); debugLogA("***** Thread messages processed"); @@ -626,8 +623,7 @@ void FacebookProto::SyncThreads(void*) delete p; - bool local_timestamp = getBool(FACEBOOK_KEY_LOCAL_TIMESTAMP_UNREAD, 0); - ReceiveMessages(messages, local_timestamp, true); + ReceiveMessages(messages, true); debugLogA("***** Thread messages processed"); @@ -642,7 +638,7 @@ void FacebookProto::SyncThreads(void*) } -void FacebookProto::ReceiveMessages(std::vector<facebook_message*> messages, bool local_timestamp, bool check_duplicates) +void FacebookProto::ReceiveMessages(std::vector<facebook_message*> messages, bool check_duplicates) { bool naseemsSpamMode = getBool(FACEBOOK_KEY_NASEEMS_SPAM_MODE, false); @@ -687,8 +683,6 @@ 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++) { - DWORD timestamp = local_timestamp || !messages[i]->time ? ::time(NULL) : messages[i]->time; - if (messages[i]->isChat) { if (!m_enableChat) { delete messages[i]; @@ -760,7 +754,7 @@ void FacebookProto::ReceiveMessages(std::vector<facebook_message*> messages, boo // TODO: support also system messages (rename chat, user quit, etc.)! (here? or it is somewhere else? // ... we must add some new "type" field into facebook_message structure and use it also for Pokes and similar) - UpdateChat(tthread_id.c_str(), messages[i]->user_id.c_str(), messages[i]->sender_name.c_str(), messages[i]->message_text.c_str(), timestamp); + UpdateChat(tthread_id.c_str(), messages[i]->user_id.c_str(), messages[i]->sender_name.c_str(), messages[i]->message_text.c_str(), messages[i]->time); // Automatically mark message as read because chatroom doesn't support onRead event (yet) hChatContacts->insert(hChatContact); // std::set checks duplicates at insert automatically @@ -806,7 +800,7 @@ void FacebookProto::ReceiveMessages(std::vector<facebook_message*> messages, boo PROTORECVEVENT recv = { 0 }; recv.flags = PREF_UTF; recv.szMessage = const_cast<char*>(messages[i]->message_text.c_str()); - recv.timestamp = timestamp; + recv.timestamp = messages[i]->time; ProtoChainRecvMsg(hContact, &recv); } else { @@ -827,7 +821,7 @@ void FacebookProto::ReceiveMessages(std::vector<facebook_message*> messages, boo dbei.flags |= DBEF_READ; dbei.szModule = m_szModuleName; - dbei.timestamp = timestamp; + dbei.timestamp = messages[i]->time; dbei.cbBlob = (DWORD)messages[i]->message_text.length() + 1; dbei.pBlob = (PBYTE)messages[i]->message_text.c_str(); db_event_add(hContact, &dbei); @@ -870,9 +864,7 @@ void FacebookProto::ProcessMessages(void* data) p->parse_messages(resp, &messages, &facy.notifications, inboxOnly); delete p; - bool local_timestamp = getBool(FACEBOOK_KEY_LOCAL_TIMESTAMP, DEFAULT_LOCAL_TIME); - - ReceiveMessages(messages, local_timestamp); + ReceiveMessages(messages); ShowNotifications(); diff --git a/protocols/FacebookRM/src/proto.h b/protocols/FacebookRM/src/proto.h index ad89a44211..f5d697e749 100644 --- a/protocols/FacebookRM/src/proto.h +++ b/protocols/FacebookRM/src/proto.h @@ -219,7 +219,7 @@ public: void AddChatContact(const TCHAR *chat_id, const char *id, const char *name); void RemoveChatContact(const TCHAR *chat_id, const char *id, const char *name); char *GetChatUsers(const TCHAR *chat_id); - void ReceiveMessages(std::vector<facebook_message*> messages, bool local_timestamp, bool check_duplicates = false); + void ReceiveMessages(std::vector<facebook_message*> messages, bool check_duplicates = false); void LoadChatInfo(facebook_chatroom* fbc); void LoadParticipantsNames(facebook_chatroom *fbc); diff --git a/protocols/FacebookRM/src/resource.h b/protocols/FacebookRM/src/resource.h index ee6cad34da..fb273bd5e5 100644 --- a/protocols/FacebookRM/src/resource.h +++ b/protocols/FacebookRM/src/resource.h @@ -32,7 +32,6 @@ #define IDC_BIGGER_AVATARS 1030
#define IDC_MAP_STATUSES 1032
#define IDC_CUSTOM_SMILEYS 1034
-#define IDC_USE_LOCAL_TIME 1035
#define IDC_LOAD_PAGES 1036
#define IDC_KEEP_UNREAD 1037
#define IDC_INBOX_ONLY 1038
diff --git a/protocols/FacebookRM/src/utils.cpp b/protocols/FacebookRM/src/utils.cpp index 48f15876e9..bceae044cf 100644 --- a/protocols/FacebookRM/src/utils.cpp +++ b/protocols/FacebookRM/src/utils.cpp @@ -57,9 +57,9 @@ std::string utils::time::mili_timestamp() DWORD utils::time::fix_timestamp(unsigned __int64 mili_timestamp)
{
// If it is really mili_timestamp
- if (mili_timestamp > 100000000000) {
+ if (mili_timestamp > 100000000000)
mili_timestamp /= 1000;
- }
+
return (DWORD)mili_timestamp;
}
|