From 8ec882fcf4a57256daa439d85d29fcbf3a1d06af Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Wed, 3 Jul 2013 18:16:59 +0000 Subject: Skype: fixed and improved history synchronization git-svn-id: http://svn.miranda-ng.org/main/trunk@5222 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Skype/src/skype_messages.cpp | 88 +++++++++++++--------------------- 1 file changed, 34 insertions(+), 54 deletions(-) (limited to 'protocols/Skype/src/skype_messages.cpp') diff --git a/protocols/Skype/src/skype_messages.cpp b/protocols/Skype/src/skype_messages.cpp index 16570e8081..5b5bcad1bf 100644 --- a/protocols/Skype/src/skype_messages.cpp +++ b/protocols/Skype/src/skype_messages.cpp @@ -224,9 +224,8 @@ void CSkypeProto::SyncMessageHystory(const ConversationRef &conversation, const } } -int CSkypeProto::SyncLastDayHistoryCommand(WPARAM wParam, LPARAM lParam) +void CSkypeProto::SyncHistoryCommand(HANDLE hContact, time_t timestamp) { - HANDLE hContact = (HANDLE)wParam; if (hContact) { ptrW sid = ::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_SID); @@ -243,72 +242,53 @@ int CSkypeProto::SyncLastDayHistoryCommand(WPARAM wParam, LPARAM lParam) if (conversation) { - time_t timestamp = time(NULL); - timestamp -= 60*60*24; - this->SyncMessageHystory(conversation, timestamp); - } + CSkypeProto::ShowNotification(TranslateT("history synchronization"), TranslateT("Done!"), MB_ICONINFORMATION, hContact); + } } +} + +int CSkypeProto::SyncLastDayHistoryCommand(WPARAM wParam, LPARAM lParam) +{ + time_t timestamp = time(NULL); + timestamp -= 60*60*24; + this->SyncHistoryCommand((HANDLE)wParam, timestamp); return 0; } int CSkypeProto::SyncLastWeekHistoryCommand(WPARAM wParam, LPARAM lParam) { - HANDLE hContact = (HANDLE)wParam; - if (hContact) - { - ptrW sid = ::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_SID); - - ConversationRef conversation; - if ( !this->IsChatRoom(hContact)) - { - SEStringList target; - target.append((char *)ptrA(::mir_utf8encodeW(sid))); - this->GetConversationByParticipants(target, conversation); - } - else - this->GetConversationByIdentity((char *)ptrA(::mir_utf8encodeW(sid)), conversation); - - if (conversation) - { - time_t timestamp = time(NULL); - timestamp -= 60*60*24*7; - - this->SyncMessageHystory(conversation, timestamp); - } - } + time_t timestamp = time(NULL); + timestamp -= 60*60*24*7; + this->SyncHistoryCommand((HANDLE)wParam, timestamp); return 0; } int CSkypeProto::SyncLastMonthHistoryCommand(WPARAM wParam, LPARAM lParam) { - HANDLE hContact = (HANDLE)wParam; - if (hContact) - { - ptrW sid = ::db_get_wsa(hContact, this->m_szModuleName, SKYPE_SETTINGS_SID); - - ConversationRef conversation; - if ( !this->IsChatRoom(hContact)) - { - SEStringList target; - target.append((char *)ptrA(::mir_utf8encodeW(sid))); - this->GetConversationByParticipants(target, conversation); - } - else - this->GetConversationByIdentity((char *)ptrA(::mir_utf8encodeW(sid)), conversation); + time_t timestamp = time(NULL); + timestamp -= 60*60*24*30; + this->SyncHistoryCommand((HANDLE)wParam, timestamp); + return 0; +} - if (conversation) - { - time_t timestamp = time(NULL); - timestamp -= 60*60*24*30; +int CSkypeProto::SyncLast3MonthHistoryCommand(WPARAM wParam, LPARAM lParam) +{ + time_t timestamp = time(NULL); + timestamp -= 60*60*24*90; + this->SyncHistoryCommand((HANDLE)wParam, timestamp); + return 0; +} - this->SyncMessageHystory(conversation, timestamp); - } - } +int CSkypeProto::SyncLastYearHistoryCommand(WPARAM wParam, LPARAM lParam) +{ + time_t timestamp = time(NULL); + timestamp -= 60*60*24*365; + this->SyncHistoryCommand((HANDLE)wParam, timestamp); return 0; } -int CSkypeProto::SyncLast3MonthHistoryCommand(WPARAM wParam, LPARAM lParam) +int CSkypeProto::SyncAllTimeHistoryCommand(WPARAM wParam, LPARAM lParam) { HANDLE hContact = (HANDLE)wParam; if (hContact) @@ -327,10 +307,10 @@ int CSkypeProto::SyncLast3MonthHistoryCommand(WPARAM wParam, LPARAM lParam) if (conversation) { - time_t timestamp = time(NULL); - timestamp -= 60*60*24*90; - + uint timestamp; + conversation->GetPropCreationTimestamp(timestamp); this->SyncMessageHystory(conversation, timestamp); + CSkypeProto::ShowNotification(TranslateT("history synchronization"), TranslateT("Done!"), MB_ICONINFORMATION, hContact); } } return 0; -- cgit v1.2.3