summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2023-11-16 18:22:43 +0300
committerGeorge Hazan <george.hazan@gmail.com>2023-11-16 18:22:43 +0300
commit2a181b5ec19c0008d497553a95272ff7d114eb72 (patch)
tree0fcfb0ccd18e724daaf6c887a52baab90937a1ec /protocols
parentea325162c0e04fbb95d101a744ac605bac47492d (diff)
fixes #3934 (ICQ: Онлайн файл может не преобразовываться в файл, а оставаться "левой ссылкой")
Diffstat (limited to 'protocols')
-rw-r--r--protocols/ICQ-WIM/ICQ-WIM.vcxproj1
-rw-r--r--protocols/ICQ-WIM/ICQ-WIM.vcxproj.filters3
-rw-r--r--protocols/ICQ-WIM/src/menus.cpp81
-rw-r--r--protocols/ICQ-WIM/src/proto.cpp1
-rw-r--r--protocols/ICQ-WIM/src/proto.h10
-rw-r--r--protocols/ICQ-WIM/src/stdafx.h1
6 files changed, 97 insertions, 0 deletions
diff --git a/protocols/ICQ-WIM/ICQ-WIM.vcxproj b/protocols/ICQ-WIM/ICQ-WIM.vcxproj
index 43a019b110..226af870db 100644
--- a/protocols/ICQ-WIM/ICQ-WIM.vcxproj
+++ b/protocols/ICQ-WIM/ICQ-WIM.vcxproj
@@ -33,6 +33,7 @@
<ClCompile Include="src\http.cpp" />
<ClCompile Include="src\ignore.cpp" />
<ClCompile Include="src\main.cpp" />
+ <ClCompile Include="src\menus.cpp" />
<ClCompile Include="src\mra.cpp" />
<ClCompile Include="src\options.cpp" />
<ClCompile Include="src\poll.cpp" />
diff --git a/protocols/ICQ-WIM/ICQ-WIM.vcxproj.filters b/protocols/ICQ-WIM/ICQ-WIM.vcxproj.filters
index 39587e6cee..c4f1468c1c 100644
--- a/protocols/ICQ-WIM/ICQ-WIM.vcxproj.filters
+++ b/protocols/ICQ-WIM/ICQ-WIM.vcxproj.filters
@@ -47,6 +47,9 @@
<ClCompile Include="src\avatars.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="src\menus.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\http.h">
diff --git a/protocols/ICQ-WIM/src/menus.cpp b/protocols/ICQ-WIM/src/menus.cpp
new file mode 100644
index 0000000000..591089e24a
--- /dev/null
+++ b/protocols/ICQ-WIM/src/menus.cpp
@@ -0,0 +1,81 @@
+/*
+Copyright (C) 2012-23 Miranda NG team (https://miranda-ng.org)
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation version 2
+of the License.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "stdafx.h"
+
+#define MenuExecService "/NSExecMenu"
+
+void CIcqProto::InitMenus()
+{
+ if (!ServiceExists(MS_NEWSTORY_GETSELECTION))
+ return;
+
+ CreateProtoService(MenuExecService, &CIcqProto::SvcExecMenu);
+ HookProtoEvent(ME_NS_PREBUILDMENU, &CIcqProto::OnPrebuildMenu);
+
+ CMStringA szServiceName(FORMAT, "%s%s", m_szModuleName, MenuExecService);
+ CMenuItem mi(&g_plugin);
+ mi.pszService = szServiceName;
+
+ mi.position = 1000000;
+ mi.hIcolibItem = Skin_GetIconHandle(SKINICON_EVENT_FILE);
+ mi.name.a = LPGEN("Convert a message into a file transfer");
+ hmiConvert = Menu_AddNewStoryMenuItem(&mi, 1);
+}
+
+INT_PTR CIcqProto::SvcExecMenu(WPARAM iCommand, LPARAM pHandle)
+{
+ // convert a message into a file transfer
+ if (iCommand == 1) {
+ if (MEVENT hEvent = NS_GetCurrent(HANDLE(pHandle))) {
+ DB::EventInfo dbei(hEvent);
+ if (!dbei)
+ return 0;
+
+ IcqFileInfo *pFileInfo = nullptr;
+ CMStringW wszText(ptrW(DbEvent_GetTextW(&dbei, CP_UTF8)));
+ if (CheckFile(db_event_getContact(hEvent), wszText, pFileInfo)) {
+ if (pFileInfo->bIsSticker) {
+ // sticker is a simple text message prcoessed by SmileyAdd
+ T2Utf szBody(wszText);
+ mir_free(dbei.pBlob);
+ dbei.pBlob = (uint8_t*)szBody.get();
+ dbei.cbBlob = (int)mir_strlen(szBody.get());
+ }
+ else {
+ // create the offline file event
+ dbei.eventType = EVENTTYPE_FILE;
+
+ DB::FILE_BLOB blob(pFileInfo->wszDescr, L"");
+ blob.setUrl(pFileInfo->szOrigUrl);
+ blob.setSize(pFileInfo->dwFileSize);
+ blob.write(dbei);
+ }
+ db_event_edit(hEvent, &dbei);
+ }
+ }
+ }
+ return 0;
+}
+
+int CIcqProto::OnPrebuildMenu(WPARAM, LPARAM lParam)
+{
+ auto *dbei = (DB::EventInfo *)lParam;
+ ptrW wszText(DbEvent_GetTextW(dbei, CP_UTF8));
+ Menu_ShowItem(hmiConvert, 0 == mir_wstrncmp(wszText, L"https://files.icq.net/get/", 26));
+ return 0;
+}
diff --git a/protocols/ICQ-WIM/src/proto.cpp b/protocols/ICQ-WIM/src/proto.cpp
index e3181190e4..9255001537 100644
--- a/protocols/ICQ-WIM/src/proto.cpp
+++ b/protocols/ICQ-WIM/src/proto.cpp
@@ -136,6 +136,7 @@ CIcqProto::~CIcqProto()
void CIcqProto::OnModulesLoaded()
{
InitContactCache();
+ InitMenus();
HookProtoEvent(ME_USERINFO_INITIALISE, &CIcqProto::OnUserInfoInit);
diff --git a/protocols/ICQ-WIM/src/proto.h b/protocols/ICQ-WIM/src/proto.h
index 05e8fca0f5..50abf91a31 100644
--- a/protocols/ICQ-WIM/src/proto.h
+++ b/protocols/ICQ-WIM/src/proto.h
@@ -360,6 +360,16 @@ class CIcqProto : public PROTO<CIcqProto>
void GetAvatarFileName(MCONTACT hContact, wchar_t *pszDest, size_t cbLen);
////////////////////////////////////////////////////////////////////////////////////////
+ // Menus
+
+ HGENMENU hmiConvert;
+
+ void InitMenus();
+
+ INT_PTR __cdecl SvcExecMenu(WPARAM, LPARAM);
+ int __cdecl OnPrebuildMenu(WPARAM, LPARAM);
+
+ ////////////////////////////////////////////////////////////////////////////////////////
// threads
HANDLE m_hWorkerThread;
diff --git a/protocols/ICQ-WIM/src/stdafx.h b/protocols/ICQ-WIM/src/stdafx.h
index e6b9d0020b..6a449f04d2 100644
--- a/protocols/ICQ-WIM/src/stdafx.h
+++ b/protocols/ICQ-WIM/src/stdafx.h
@@ -59,6 +59,7 @@
#include <m_message.h>
#include <m_messagestate.h>
#include <m_netlib.h>
+#include <m_NewStory.h>
#include <m_protocols.h>
#include <m_protosvc.h>
#include <m_options.h>