diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2013-07-03 18:16:59 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2013-07-03 18:16:59 +0000 |
commit | 8ec882fcf4a57256daa439d85d29fcbf3a1d06af (patch) | |
tree | 22e0e9d947fbd61477e741e985cb5e406f6e97e1 | |
parent | e06c4679faf776715b47e2c158490d7337ded27a (diff) |
Skype: fixed and improved history synchronization
git-svn-id: http://svn.miranda-ng.org/main/trunk@5222 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | protocols/Skype/src/skype_blocked.cpp | 4 | ||||
-rw-r--r-- | protocols/Skype/src/skype_events.cpp | 5 | ||||
-rw-r--r-- | protocols/Skype/src/skype_menus.cpp | 32 | ||||
-rw-r--r-- | protocols/Skype/src/skype_messages.cpp | 88 | ||||
-rw-r--r-- | protocols/Skype/src/skype_proto.h | 4 | ||||
-rw-r--r-- | protocols/Skype/src/skype_utils.cpp | 7 |
6 files changed, 68 insertions, 72 deletions
diff --git a/protocols/Skype/src/skype_blocked.cpp b/protocols/Skype/src/skype_blocked.cpp index 8bd24954d4..bf4212e9ef 100644 --- a/protocols/Skype/src/skype_blocked.cpp +++ b/protocols/Skype/src/skype_blocked.cpp @@ -44,12 +44,14 @@ int CSkypeProto::BlockCommand(WPARAM wParam, LPARAM lParam) INT_PTR CSkypeProto::OpenBlockedListCommand(WPARAM, LPARAM)
{
+ char *title = ::mir_t2a(this->m_tszUserName);
OPENOPTIONSDIALOG ood;
ood.cbSize = sizeof(OPENOPTIONSDIALOG);
ood.pszGroup = "Network";
- ood.pszPage = ::mir_t2a(this->m_tszUserName);
+ ood.pszPage = title;
ood.pszTab = "Blocked contacts";
return ::Options_Open(&ood);
+ ::mir_free(title);
}
INT_PTR CALLBACK CSkypeProto::SkypeBlockProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
diff --git a/protocols/Skype/src/skype_events.cpp b/protocols/Skype/src/skype_events.cpp index b75d98b0f1..3a9f8a3a99 100644 --- a/protocols/Skype/src/skype_events.cpp +++ b/protocols/Skype/src/skype_events.cpp @@ -99,10 +99,12 @@ INT_PTR __cdecl CSkypeProto::OnAccountManagerInit(WPARAM wParam, LPARAM lParam) int __cdecl CSkypeProto::OnOptionsInit(WPARAM wParam, LPARAM lParam)
{
+ char *title = ::mir_t2a(this->m_tszUserName);
+
OPTIONSDIALOGPAGE odp = {0};
odp.cbSize = sizeof(odp);
odp.hInstance = g_hInstance;
- odp.pszTitle = ::mir_t2a(this->m_tszUserName);
+ odp.pszTitle = title;
odp.dwInitParam = LPARAM(this);
odp.flags = ODPF_BOLDGROUPS;
odp.pszGroup = LPGEN("Network");
@@ -117,6 +119,7 @@ int __cdecl CSkypeProto::OnOptionsInit(WPARAM wParam, LPARAM lParam) odp.pfnDlgProc = CSkypeProto::SkypeBlockedOptionsProc;
::Options_AddPage(wParam, &odp);
+ ::mir_free(title);
return 0;
}
diff --git a/protocols/Skype/src/skype_menus.cpp b/protocols/Skype/src/skype_menus.cpp index f98ad39630..0a348a9013 100644 --- a/protocols/Skype/src/skype_menus.cpp +++ b/protocols/Skype/src/skype_menus.cpp @@ -171,17 +171,15 @@ void CSkypeProto::InitMenus() mi.flags |= CMIF_CHILDPOPUP;
mi.position = -200001000 + CMI_HISTORY + 1;
mi.hParentMenu = CSkypeProto::contactMenuItems[CMI_HISTORY];
- //mi.icolibItem = CSkypeProto::GetSkinIconHandle("block");
- /*CSkypeProto::contactMenuItems[CMI_HISTORY] = */::Menu_AddContactMenuItem(&mi);
- //::CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::BlockCommand>);
+ ::Menu_AddContactMenuItem(&mi);
+ ::CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::SyncLastDayHistoryCommand>);
mi.pszService = MODULE"/SyncHistoryWeek";
mi.ptszName = LPGENT("...by last week");
mi.flags |= CMIF_CHILDPOPUP;
mi.position = -200001000 + CMI_HISTORY + 2;
mi.hParentMenu = CSkypeProto::contactMenuItems[CMI_HISTORY];
- //mi.icolibItem = CSkypeProto::GetSkinIconHandle("block");
- /*CSkypeProto::contactMenuItems[CMI_HISTORY] = */::Menu_AddContactMenuItem(&mi);
+ ::Menu_AddContactMenuItem(&mi);
::CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::SyncLastWeekHistoryCommand>);
mi.pszService = MODULE"/SyncHistoryMonth";
@@ -189,18 +187,32 @@ void CSkypeProto::InitMenus() mi.flags |= CMIF_CHILDPOPUP;
mi.position = -200001000 + CMI_HISTORY + 3;
mi.hParentMenu = CSkypeProto::contactMenuItems[CMI_HISTORY];
- //mi.icolibItem = CSkypeProto::GetSkinIconHandle("block");
- /*CSkypeProto::contactMenuItems[CMI_HISTORY] = */::Menu_AddContactMenuItem(&mi);
- //::CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::BlockCommand>);
+ ::Menu_AddContactMenuItem(&mi);
+ ::CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::SyncLastMonthHistoryCommand>);
mi.pszService = MODULE"/SyncHistory3Month";
mi.ptszName = LPGENT("...by last 3 month");
mi.flags |= CMIF_CHILDPOPUP;
mi.position = -200001000 + CMI_HISTORY + 4;
mi.hParentMenu = CSkypeProto::contactMenuItems[CMI_HISTORY];
- //mi.icolibItem = CSkypeProto::GetSkinIconHandle("block");
- /*CSkypeProto::contactMenuItems[CMI_HISTORY] = */::Menu_AddContactMenuItem(&mi);
+ ::Menu_AddContactMenuItem(&mi);
::CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::SyncLast3MonthHistoryCommand>);
+
+ mi.pszService = MODULE"/SyncHistoryYear";
+ mi.ptszName = LPGENT("...by last year");
+ mi.flags |= CMIF_CHILDPOPUP;
+ mi.position = -200001000 + CMI_HISTORY + 5;
+ mi.hParentMenu = CSkypeProto::contactMenuItems[CMI_HISTORY];
+ ::Menu_AddContactMenuItem(&mi);
+ ::CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::SyncLastYearHistoryCommand>);
+
+ mi.pszService = MODULE"/SyncHistoryAllTime";
+ mi.ptszName = LPGENT("...by all time");
+ mi.flags |= CMIF_CHILDPOPUP;
+ mi.position = -200001000 + CMI_HISTORY + 6;
+ mi.hParentMenu = CSkypeProto::contactMenuItems[CMI_HISTORY];
+ ::Menu_AddContactMenuItem(&mi);
+ ::CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::SyncAllTimeHistoryCommand>);
}
void CSkypeProto::UninitMenus()
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;
diff --git a/protocols/Skype/src/skype_proto.h b/protocols/Skype/src/skype_proto.h index 6fc0d128e7..ccaa983a8a 100644 --- a/protocols/Skype/src/skype_proto.h +++ b/protocols/Skype/src/skype_proto.h @@ -296,11 +296,13 @@ protected: void OnMessageReceived(const ConversationRef &conversation, const MessageRef &message);
void SyncMessageHystory(const ConversationRef &conversation, const time_t timestamp);
-
+ void SyncHistoryCommand(HANDLE hContact, time_t timestamp);
int __cdecl SyncLastDayHistoryCommand(WPARAM wParam, LPARAM lParam);
int __cdecl SyncLastWeekHistoryCommand(WPARAM wParam, LPARAM lParam);
int __cdecl SyncLastMonthHistoryCommand(WPARAM wParam, LPARAM lParam);
int __cdecl SyncLast3MonthHistoryCommand(WPARAM wParam, LPARAM lParam);
+ int __cdecl SyncLastYearHistoryCommand(WPARAM wParam, LPARAM lParam);
+ int __cdecl SyncAllTimeHistoryCommand(WPARAM wParam, LPARAM lParam);
// contacts
void OnContactsEvent(const ConversationRef &conversation, const MessageRef &message);
diff --git a/protocols/Skype/src/skype_utils.cpp b/protocols/Skype/src/skype_utils.cpp index 8828504333..a84804ba59 100644 --- a/protocols/Skype/src/skype_utils.cpp +++ b/protocols/Skype/src/skype_utils.cpp @@ -349,14 +349,11 @@ void CSkypeProto::ShowNotification(const wchar_t *caption, const wchar_t *messag {
POPUPDATAW ppd = {0};
ppd.lchContact = hContact;
- if ( !hContact)
- {
- ::wcsncpy(ppd.lpwzContactName, caption, MAX_CONTACTNAME);
- }
+ ::wcsncpy(ppd.lpwzContactName, caption, MAX_CONTACTNAME);
::wcsncpy(ppd.lpwzText, message, MAX_SECONDLINE);
ppd.lchIcon = ::Skin_GetIcon("Skype_main");
- if ( !PUAddPopupW(&ppd))
+ if ( !::PUAddPopupW(&ppd))
return;
}
|