summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/m_srmm_int.h28
-rw-r--r--libs/win32/mir_app.libbin253056 -> 254674 bytes
-rw-r--r--libs/win64/mir_app.libbin250386 -> 252256 bytes
-rw-r--r--src/mir_app/src/mir_app.def16
-rw-r--r--src/mir_app/src/mir_app64.def16
-rw-r--r--src/mir_app/src/srmm_log_rtf.cpp26
-rw-r--r--src/mir_app/src/srmm_util.cpp34
7 files changed, 78 insertions, 42 deletions
diff --git a/include/m_srmm_int.h b/include/m_srmm_int.h
index ba7b5aa886..283e9f69b7 100644
--- a/include/m_srmm_int.h
+++ b/include/m_srmm_int.h
@@ -72,13 +72,13 @@ struct CustomButtonData : public MZeroedObject
};
// gets the required button or NULL, if i is out of boundaries
-EXTERN_C MIR_APP_DLL(CustomButtonData*) Srmm_GetNthButton(int i);
+MIR_APP_DLL(CustomButtonData*) Srmm_GetNthButton(int i);
// retrieves total number of toolbar buttons
-EXTERN_C MIR_APP_DLL(int) Srmm_GetButtonCount(void);
+MIR_APP_DLL(int) Srmm_GetButtonCount(void);
// emulates a click on a toolbar button
-EXTERN_C MIR_APP_DLL(void) Srmm_ClickToolbarIcon(MCONTACT hContact, int idFrom, HWND hwndFrom, BOOL code);
+MIR_APP_DLL(void) Srmm_ClickToolbarIcon(MCONTACT hContact, int idFrom, HWND hwndFrom, BOOL code);
// these messages are sent to the message windows if toolbar buttons are changed
#define WM_CBD_FIRST (WM_USER+0x600)
@@ -142,8 +142,8 @@ public:
typedef CSrmmLogWindow *(MIR_CDECL *pfnSrmmLogCreator)(CMsgDialog &pDlg);
-EXTERN_C MIR_APP_DLL(HANDLE) RegisterSrmmLog(CMPlugin *pPlugin, const char *pszShortName, const wchar_t *pwszScreenName, pfnSrmmLogCreator fnBuilder);
-EXTERN_C MIR_APP_DLL(void) UnregisterSrmmLog(HANDLE);
+MIR_APP_DLL(HANDLE) RegisterSrmmLog(CMPlugin *pPlugin, const char *pszShortName, const wchar_t *pwszScreenName, pfnSrmmLogCreator fnBuilder);
+MIR_APP_DLL(void) UnregisterSrmmLog(HANDLE);
/////////////////////////////////////////////////////////////////////////////////////////
// Standard built-in RTF logger class
@@ -338,17 +338,27 @@ MIR_APP_DLL(void) Srmm_AddEvent(MCONTACT hContact, MEVENT hDbEvent);
/////////////////////////////////////////////////////////////////////////////////////////
// sends a message to all SRMM windows
-EXTERN_C MIR_APP_DLL(void) Srmm_Broadcast(UINT, WPARAM, LPARAM);
+MIR_APP_DLL(void) Srmm_Broadcast(UINT, WPARAM, LPARAM);
/////////////////////////////////////////////////////////////////////////////////////////
// creates plugin-specific hot key for sending messages
-EXTERN_C MIR_APP_DLL(void) Srmm_CreateHotkey(const char *pszSection, const char *pszDescription);
+MIR_APP_DLL(void) Srmm_CreateHotkey(const char *pszSection, const char *pszDescription);
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// downloads or launches offline file
+
+MIR_APP_DLL(void) Srmm_DownloadOfflineFile(MEVENT hDbEvent, bool bOpen);
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// retrieves offline file's name
+
+MIR_APP_DLL(CMStringW) Srmm_GetOfflineFileName(MCONTACT hContact);
/////////////////////////////////////////////////////////////////////////////////////////
// finds a SRMM window using hContact
-EXTERN_C MIR_APP_DLL(HWND) Srmm_FindWindow(MCONTACT hContact);
-EXTERN_C MIR_APP_DLL(CMsgDialog*) Srmm_FindDialog(MCONTACT hContact);
+MIR_APP_DLL(HWND) Srmm_FindWindow(MCONTACT hContact);
+MIR_APP_DLL(CMsgDialog*) Srmm_FindDialog(MCONTACT hContact);
#endif // M_MESSAGE_H__
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib
index bcf9ffa7e9..c5387ed734 100644
--- a/libs/win32/mir_app.lib
+++ b/libs/win32/mir_app.lib
Binary files differ
diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib
index 679e154364..fd8947ee81 100644
--- a/libs/win64/mir_app.lib
+++ b/libs/win64/mir_app.lib
Binary files differ
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def
index 2af6fdb061..fc9f882c9f 100644
--- a/src/mir_app/src/mir_app.def
+++ b/src/mir_app/src/mir_app.def
@@ -243,9 +243,11 @@ Srmm_ResetToolbar @335
Srmm_SetButtonState @336
Srmm_UpdateToolbarIcons @337
Srmm_RedrawToolbarIcons @338
-Srmm_GetNthButton @339
-Srmm_GetButtonCount @340
-Srmm_ClickToolbarIcon @341
+?Srmm_GetNthButton@@YGPAUCustomButtonData@@H@Z @339 NONAME
+?Srmm_GetButtonCount@@YGHXZ @340 NONAME
+?Srmm_ClickToolbarIcon@@YGXIHPAUHWND__@@H@Z @341 NONAME
+?Srmm_DownloadOfflineFile@@YGXI_N@Z @342 NONAME
+?Srmm_GetOfflineFileName@@YG?AV?$CMStringT@_WV?$ChTraitsCRT@_W@@@@I@Z @343 NONAME
Miranda_OkToExit @344
Miranda_GetVersion @345
Miranda_GetFileVersion @346
@@ -347,8 +349,8 @@ _stubNicklistProc@16 @448 NONAME
Chat_GetTextPixelSize @449 NONAME
?NotifyEvent@CSrmmBaseDialog@@IAEHH@Z @450 NONAME
Srmm_GetWindowData @451
-Srmm_FindWindow @452
-Srmm_Broadcast @453
+?Srmm_FindWindow@@YGPAUHWND__@@I@Z @452 NONAME
+?Srmm_Broadcast@@YGXIIJ@Z @453 NONAME
Hotkey_Register @454
Hotkey_Subclass @455
Hotkey_Unregister @456
@@ -686,8 +688,8 @@ UnregisterHppLogger @786
?ScrollToBottom@CRtfLogWindow@@UAEXXZ @802 NONAME
?UpdateOptions@CSrmmLogWindow@@UAEXXZ @803 NONAME
?WndProc@CRtfLogWindow@@UAEHIIJ@Z @804 NONAME
-_RegisterSrmmLog@16 @805 NONAME
-_UnregisterSrmmLog@4 @806 NONAME
+?RegisterSrmmLog@@YGPAXPAUCMPlugin@@PBDPB_WP6APAVCSrmmLogWindow@@AAVCMsgDialog@@@Z@Z @805 NONAME
+?UnregisterSrmmLog@@YGXPAX@Z @806 NONAME
?GetType@CRtfLogWindow@@UAEHXZ @807 NONAME
_WebSocket_InitHeader@12 @809 NONAME
_WebSocket_Connect@12 @810 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def
index 33cd79d291..091462dd8c 100644
--- a/src/mir_app/src/mir_app64.def
+++ b/src/mir_app/src/mir_app64.def
@@ -243,9 +243,11 @@ Srmm_ResetToolbar @335
Srmm_SetButtonState @336
Srmm_UpdateToolbarIcons @337
Srmm_RedrawToolbarIcons @338
-Srmm_GetNthButton @339
-Srmm_GetButtonCount @340
-Srmm_ClickToolbarIcon @341
+?Srmm_GetNthButton@@YAPEAUCustomButtonData@@H@Z @339 NONAME
+?Srmm_GetButtonCount@@YAHXZ @340 NONAME
+?Srmm_ClickToolbarIcon@@YAXIHPEAUHWND__@@H@Z @341 NONAME
+?Srmm_DownloadOfflineFile@@YAXI_N@Z @342 NONAME
+?Srmm_GetOfflineFileName@@YA?AV?$CMStringT@_WV?$ChTraitsCRT@_W@@@@I@Z @343 NONAME
Miranda_OkToExit @344
Miranda_GetVersion @345
Miranda_GetFileVersion @346
@@ -347,8 +349,8 @@ stubNicklistProc @448 NONAME
Chat_GetTextPixelSize @449 NONAME
?NotifyEvent@CSrmmBaseDialog@@IEAAHH@Z @450 NONAME
Srmm_GetWindowData @451
-Srmm_FindWindow @452
-Srmm_Broadcast @453
+?Srmm_FindWindow@@YAPEAUHWND__@@I@Z @452 NONAME
+?Srmm_Broadcast@@YAXI_K_J@Z @453 NONAME
Hotkey_Register @454
Hotkey_Subclass @455
Hotkey_Unregister @456
@@ -686,8 +688,8 @@ UnregisterHppLogger @786
?ScrollToBottom@CRtfLogWindow@@UEAAXXZ @802 NONAME
?UpdateOptions@CSrmmLogWindow@@UEAAXXZ @803 NONAME
?WndProc@CRtfLogWindow@@UEAA_JI_K_J@Z @804 NONAME
-RegisterSrmmLog @805 NONAME
-UnregisterSrmmLog @806 NONAME
+?RegisterSrmmLog@@YAPEAXPEAUCMPlugin@@PEBDPEB_WP6APEAVCSrmmLogWindow@@AEAVCMsgDialog@@@Z@Z @805 NONAME
+?UnregisterSrmmLog@@YAXPEAX@Z @806 NONAME
?GetType@CRtfLogWindow@@UEAAHXZ @807 NONAME
WebSocket_InitHeader @809 NONAME
WebSocket_Connect @810 NONAME
diff --git a/src/mir_app/src/srmm_log_rtf.cpp b/src/mir_app/src/srmm_log_rtf.cpp
index 7f7a390241..ccd1480ba3 100644
--- a/src/mir_app/src/srmm_log_rtf.cpp
+++ b/src/mir_app/src/srmm_log_rtf.cpp
@@ -136,7 +136,7 @@ void CRtfLogWindow::InsertFileLink(CMStringA &buf, MEVENT hEvent, const DB::FILE
buf.Append("{\\field{\\*\\fldinst HYPERLINK \"");
buf.AppendFormat("ofile:%ul", hEvent);
buf.Append("\"}{\\fldrslt{\\ul ");
- AppendUnicodeString(buf, blob.getName());
+ AppendUnicodeString(buf, blob.getName() ? blob.getName() : TranslateT("Unnamed"));
buf.Append("}}}");
if (auto *pwszDescr = blob.getDescr()) {
@@ -195,16 +195,17 @@ INT_PTR CRtfLogWindow::Notify(WPARAM, LPARAM lParam)
if (swscanf(tr.lpstrText, L"ofile:%u", &hDbEvent) == 1) {
DB::EventInfo dbei(hDbEvent);
if (!dbei)
- return false;
+ return FALSE;
DB::FILE_BLOB blob(dbei);
int nCmd = 2;
if (pLink->msg == WM_RBUTTONDOWN) {
HMENU hMenu = CreatePopupMenu();
- AppendMenu(hMenu, MF_STRING | MF_GRAYED, (UINT_PTR)1, TranslateT("Get size"));
- AppendMenu(hMenu, MF_STRING, (UINT_PTR)3, TranslateT("Download"));
+ // AppendMenu(hMenu, MF_STRING | MF_GRAYED, 1, TranslateT("Get size"));
+ AppendMenu(hMenu, MF_STRING, 3, TranslateT("Download"));
if (blob.getUrl() != nullptr)
- AppendMenu(hMenu, MF_STRING, (UINT_PTR)4, TranslateT("Copy URL"));
+ AppendMenu(hMenu, MF_STRING, 4, TranslateT("Copy URL"));
+
POINT pt = { GET_X_LPARAM(pLink->lParam), GET_Y_LPARAM(pLink->lParam) };
ClientToScreen(((NMHDR *)lParam)->hwndFrom, &pt);
nCmd = TrackPopupMenu(hMenu, TPM_RETURNCMD, pt.x, pt.y, 0, m_pDlg.m_hwnd, nullptr);
@@ -217,20 +218,7 @@ INT_PTR CRtfLogWindow::Notify(WPARAM, LPARAM lParam)
}
}
- CMStringW tszFilePath(FORMAT, VARSW(L"%miranda_userdata%\\dlFiles\\%u\\"), m_pDlg.m_hContact);
- CreateDirectoryTreeW(tszFilePath);
- tszFilePath.Append(blob.getName());
-
- struct _stat st = {};
- _wstat(tszFilePath, &st);
- if (nCmd == 2 && st.st_size && st.st_size == blob.getSize() && st.st_size == blob.getTransferred())
- ShellExecute(nullptr, L"open", tszFilePath.c_str(), nullptr, nullptr, SW_SHOWDEFAULT);
- else {
- // TODO implement metadata getting when path == nullptr
- OFDTHREAD *dt = new OFDTHREAD(hDbEvent, nCmd == 1 ? CMStringW() : tszFilePath, nCmd == 2);
- CallProtoService(dbei.szModule, PS_OFFLINEFILE, (WPARAM)dt, 0);
- }
-
+ Srmm_DownloadOfflineFile(hDbEvent, nCmd == 2);
return TRUE;
}
diff --git a/src/mir_app/src/srmm_util.cpp b/src/mir_app/src/srmm_util.cpp
index b4480fafc0..32e247aa68 100644
--- a/src/mir_app/src/srmm_util.cpp
+++ b/src/mir_app/src/srmm_util.cpp
@@ -104,6 +104,40 @@ MIR_APP_DLL(void) Srmm_AddEvent(MCONTACT hContact, MEVENT hDbEvent)
}
/////////////////////////////////////////////////////////////////////////////////////////
+// downloads or launches offline file
+
+MIR_APP_DLL(void) Srmm_DownloadOfflineFile(MEVENT hDbEvent, bool bOpen)
+{
+ DB::EventInfo dbei(hDbEvent);
+ if (!dbei)
+ return;
+
+ DB::FILE_BLOB blob(dbei);
+ if (!blob.isOffline())
+ return;
+
+ CMStringW tszFilePath(Srmm_GetOfflineFileName(db_event_getContact(hDbEvent)));
+ CreateDirectoryTreeW(tszFilePath);
+ tszFilePath.Append(blob.getName());
+
+ struct _stat st = {};
+ _wstat(tszFilePath, &st);
+ if (st.st_size && st.st_size == blob.getSize() && blob.isCompleted()) {
+ if (bOpen)
+ ShellExecuteW(nullptr, L"open", tszFilePath.c_str(), nullptr, nullptr, SW_SHOWDEFAULT);
+ }
+ else {
+ OFDTHREAD *dt = new OFDTHREAD(hDbEvent, tszFilePath, bOpen);
+ CallProtoService(dbei.szModule, PS_OFFLINEFILE, (WPARAM)dt, 0);
+ }
+}
+
+MIR_APP_DLL(CMStringW) Srmm_GetOfflineFileName(MCONTACT hContact)
+{
+ return CMStringW(FORMAT, VARSW(L"%miranda_userdata%\\dlFiles\\%u\\"), hContact);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
// serializes all thread-unsafe operation to the first thread
struct SSTParam