summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/ExternalAPI/m_NewStory.h21
-rw-r--r--plugins/NewStory/NewStory.vcxproj1
-rw-r--r--plugins/NewStory/NewStory.vcxproj.filters3
-rw-r--r--plugins/NewStory/src/history.cpp6
-rw-r--r--plugins/NewStory/src/history_svc.cpp41
-rw-r--r--plugins/NewStory/src/main.cpp1
-rw-r--r--plugins/NewStory/src/stdafx.h2
-rw-r--r--protocols/Telegram/Telegram.vcxproj1
-rw-r--r--protocols/Telegram/Telegram.vcxproj.filters3
-rw-r--r--protocols/Telegram/res/forward.icobin0 -> 4286 bytes
-rw-r--r--protocols/Telegram/res/resource.rc21
-rw-r--r--protocols/Telegram/src/main.cpp1
-rw-r--r--protocols/Telegram/src/menus.cpp127
-rw-r--r--protocols/Telegram/src/proto.cpp3
-rw-r--r--protocols/Telegram/src/proto.h9
-rw-r--r--protocols/Telegram/src/resource.h3
-rw-r--r--protocols/Telegram/src/stdafx.h1
17 files changed, 237 insertions, 7 deletions
diff --git a/plugins/ExternalAPI/m_NewStory.h b/plugins/ExternalAPI/m_NewStory.h
index 8f8baff12c..309ac45d60 100644
--- a/plugins/ExternalAPI/m_NewStory.h
+++ b/plugins/ExternalAPI/m_NewStory.h
@@ -1,5 +1,22 @@
#pragma once
+#include <vector>
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// NS get selection
+
+#define MS_NEWSTORY_GETSELECTION "NewStory/GetSelection"
+
+__forceinline std::vector<MEVENT> NS_GetSelection(HANDLE hwnd)
+{
+ std::vector<MEVENT> ret;
+ CallService(MS_NEWSTORY_GETSELECTION, WPARAM(hwnd), LPARAM(&ret));
+ return ret;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// NS menu item
+
struct NSMenuExecParam
{
char *szServiceName;
@@ -11,7 +28,9 @@ __forceinline HGENMENU Menu_AddNewStoryMenuItem(TMO_MenuItem *pmi, int param)
return (HGENMENU)CallService("NSMenu/AddService", (WPARAM)pmi, param);
}
+/////////////////////////////////////////////////////////////////////////////////////////
// event for changing NewStory menu items
// wparam = (MCONTACT)hContact - contact id
// lparam = (DB::EventInfo*)dbei - event
-#define ME_NS_PREBUILDMENU "NewStory/PreBuildMenu"
+
+#define ME_NS_PREBUILDMENU "NewStory/PreBuildMenu"
diff --git a/plugins/NewStory/NewStory.vcxproj b/plugins/NewStory/NewStory.vcxproj
index d7c64a5402..4e626a5301 100644
--- a/plugins/NewStory/NewStory.vcxproj
+++ b/plugins/NewStory/NewStory.vcxproj
@@ -38,6 +38,7 @@
<ClCompile Include="src\history_control.cpp" />
<ClCompile Include="src\history_log.cpp" />
<ClCompile Include="src\history_menus.cpp" />
+ <ClCompile Include="src\history_svc.cpp" />
<ClCompile Include="src\main.cpp" />
<ClCompile Include="src\options.cpp" />
<ClCompile Include="src\stdafx.cxx">
diff --git a/plugins/NewStory/NewStory.vcxproj.filters b/plugins/NewStory/NewStory.vcxproj.filters
index 45b40c8e4b..3dd5b85af9 100644
--- a/plugins/NewStory/NewStory.vcxproj.filters
+++ b/plugins/NewStory/NewStory.vcxproj.filters
@@ -38,6 +38,9 @@
<ClCompile Include="src\history_menus.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="src\history_svc.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="src\calendartool.h">
diff --git a/plugins/NewStory/src/history.cpp b/plugins/NewStory/src/history.cpp
index 54fd1092e7..8ad2386fc7 100644
--- a/plugins/NewStory/src/history.cpp
+++ b/plugins/NewStory/src/history.cpp
@@ -1013,12 +1013,6 @@ public:
PostMessage(m_hwnd, WM_USER + 0x600, mktime(&tm_sel), 0);
}
}
-
- // case UM_REBUILDLIST:
- // if (showFlags & HIST_TIMETREE)
- // ShowWindow(GetDlgItem(m_hwnd, IDC_TIMETREE), SW_SHOW);
- // ShowWindow(GetDlgItem(m_hwnd, IDC_HISTORYCONTROL), SW_SHOW);
- // ShowWindow(GetDlgItem(m_hwnd, IDC_SEARCHICON), SW_SHOW);
};
INT_PTR svcShowNewstory(WPARAM hContact, LPARAM)
diff --git a/plugins/NewStory/src/history_svc.cpp b/plugins/NewStory/src/history_svc.cpp
new file mode 100644
index 0000000000..ae3d2ddd4b
--- /dev/null
+++ b/plugins/NewStory/src/history_svc.cpp
@@ -0,0 +1,41 @@
+/*
+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"
+
+static INT_PTR SvcGetSelection(WPARAM wParam, LPARAM lParam)
+{
+ auto *pData = (NewstoryListData *)wParam;
+ auto *pRet = (std::vector<MEVENT>*)lParam;
+ if (pData && pRet) {
+ for (int i = pData->items.getCount(); i >= 0; i--) {
+ auto *p = pData->items.get(i);
+ if (p->bSelected)
+ pRet->push_back(p->hEvent);
+ }
+ }
+
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Module entry point
+
+void InitServices()
+{
+ CreateServiceFunction(MS_NEWSTORY_GETSELECTION, &SvcGetSelection);
+}
diff --git a/plugins/NewStory/src/main.cpp b/plugins/NewStory/src/main.cpp
index a1db102c88..5c69a9efb0 100644
--- a/plugins/NewStory/src/main.cpp
+++ b/plugins/NewStory/src/main.cpp
@@ -102,6 +102,7 @@ int CMPlugin::Load()
HookEvent(ME_SYSTEM_PRESHUTDOWN, evtPreShutdown);
InitMenus();
+ InitServices();
return 0;
}
diff --git a/plugins/NewStory/src/stdafx.h b/plugins/NewStory/src/stdafx.h
index 151d95e5a3..39f00c47af 100644
--- a/plugins/NewStory/src/stdafx.h
+++ b/plugins/NewStory/src/stdafx.h
@@ -76,6 +76,8 @@ Boston, MA 02111-1307, USA.
#include "history_control.h"
#include "templates.h"
+void InitServices();
+
int OptionsInitialize(WPARAM, LPARAM);
struct CMPlugin : public PLUGIN<CMPlugin>
diff --git a/protocols/Telegram/Telegram.vcxproj b/protocols/Telegram/Telegram.vcxproj
index e0fe0f08de..90e1e5e72d 100644
--- a/protocols/Telegram/Telegram.vcxproj
+++ b/protocols/Telegram/Telegram.vcxproj
@@ -31,6 +31,7 @@
<ClCompile Include="src\avatars.cpp" />
<ClCompile Include="src\groupchat.cpp" />
<ClCompile Include="src\main.cpp" />
+ <ClCompile Include="src\menus.cpp" />
<ClCompile Include="src\proto.cpp" />
<ClCompile Include="src\options.cpp" />
<ClCompile Include="src\server.cpp" />
diff --git a/protocols/Telegram/Telegram.vcxproj.filters b/protocols/Telegram/Telegram.vcxproj.filters
index ee6b78ba70..10ea2069d9 100644
--- a/protocols/Telegram/Telegram.vcxproj.filters
+++ b/protocols/Telegram/Telegram.vcxproj.filters
@@ -29,6 +29,9 @@
<ClCompile Include="src\add_phone.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="src\menus.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\stdafx.cxx">
diff --git a/protocols/Telegram/res/forward.ico b/protocols/Telegram/res/forward.ico
new file mode 100644
index 0000000000..0b6fa81f6c
--- /dev/null
+++ b/protocols/Telegram/res/forward.ico
Binary files differ
diff --git a/protocols/Telegram/res/resource.rc b/protocols/Telegram/res/resource.rc
index b27f08a877..0132cbc861 100644
--- a/protocols/Telegram/res/resource.rc
+++ b/protocols/Telegram/res/resource.rc
@@ -129,6 +129,16 @@ BEGIN
PUSHBUTTON "Cancel",IDCANCEL,284,85,50,14
END
+IDD_FORWARD DIALOGEX 0, 0, 215, 267
+STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
+CAPTION "Forward message"
+FONT 8, "MS Shell Dlg", 0, 0, 0x1
+BEGIN
+ CONTROL "",IDC_CLIST,"CListControl",WS_TABSTOP | 0x1,8,4,201,239,WS_EX_CLIENTEDGE
+ DEFPUSHBUTTON "Forward",IDOK,104,248,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,158,248,50,14
+END
+
/////////////////////////////////////////////////////////////////////////////
//
@@ -141,6 +151,7 @@ IDI_TELEGRAM ICON "telegram.ico"
IDI_PREMIUM ICON "premium.ico"
+IDI_FORWARD ICON "forward.ico"
/////////////////////////////////////////////////////////////////////////////
//
@@ -162,6 +173,11 @@ BEGIN
BEGIN
BOTTOMMARGIN, 84
END
+
+ IDD_FORWARD, DIALOG
+ BEGIN
+ BOTTOMMARGIN, 262
+ END
END
#endif // APSTUDIO_INVOKED
@@ -186,6 +202,11 @@ BEGIN
0
END
+IDD_FORWARD AFX_DIALOG_LAYOUT
+BEGIN
+ 0
+END
+
#endif // English (Neutral) resources
/////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/Telegram/src/main.cpp b/protocols/Telegram/src/main.cpp
index fc521880b9..190eeada7b 100644
--- a/protocols/Telegram/src/main.cpp
+++ b/protocols/Telegram/src/main.cpp
@@ -41,6 +41,7 @@ extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOC
static IconItem iconList[] =
{
{ LPGEN("Premium user"), "premuim", IDI_PREMIUM },
+ { LPGEN("Forward"), "forward", IDI_FORWARD },
};
int CMPlugin::Load()
diff --git a/protocols/Telegram/src/menus.cpp b/protocols/Telegram/src/menus.cpp
new file mode 100644
index 0000000000..12bcdd2afa
--- /dev/null
+++ b/protocols/Telegram/src/menus.cpp
@@ -0,0 +1,127 @@
+/*
+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 CTelegramProto::InitMenus()
+{
+ if (!ServiceExists(MS_NEWSTORY_GETSELECTION))
+ return;
+
+ CreateProtoService(MenuExecService, &CTelegramProto::SvcExecMenu);
+ HookProtoEvent(ME_NS_PREBUILDMENU, &CTelegramProto::OnPrebuildMenu);
+
+ CMStringA szServiceName(FORMAT, "%s%s", m_szModuleName, MenuExecService);
+ CMenuItem mi(&g_plugin);
+ mi.pszService = szServiceName;
+
+ mi.position = 1000000;
+ mi.hIcolibItem = g_plugin.getIconHandle(IDI_FORWARD);
+ mi.name.a = LPGEN("Forward");
+ hmiForward = Menu_AddNewStoryMenuItem(&mi, 1);
+}
+
+int CTelegramProto::OnPrebuildMenu(WPARAM hContact, LPARAM)
+{
+ Menu_ShowItem(hmiForward, Proto_IsProtoOnContact(hContact, m_szModuleName));
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+class CForwardDlg : public CTelegramDlgBase
+{
+ CCtrlClc m_clist;
+ std::vector<MEVENT> &m_ids;
+
+ void FilterList(CCtrlClc *)
+ {
+ for (auto &hContact : Contacts())
+ if (!Proto_IsProtoOnContact(hContact, m_proto->m_szModuleName))
+ if (HANDLE hItem = m_clist.FindContact(hContact))
+ m_clist.DeleteItem(hItem);
+ }
+
+ void ResetListOptions(CCtrlClc *)
+ {
+ m_clist.SetHideEmptyGroups(true);
+ m_clist.SetHideOfflineRoot(true);
+ }
+
+public:
+ CForwardDlg(CTelegramProto *ppro, std::vector<MEVENT> &ids) :
+ CTelegramDlgBase(ppro, IDD_FORWARD),
+ m_ids(ids),
+ m_clist(this, IDC_CLIST)
+ {
+ m_clist.OnNewContact =
+ m_clist.OnListRebuilt = Callback(this, &CForwardDlg::FilterList);
+ m_clist.OnOptionsChanged = Callback(this, &CForwardDlg::ResetListOptions);
+ }
+
+ bool OnInitDialog() override
+ {
+ SetWindowLongPtr(m_clist.GetHwnd(), GWL_STYLE,
+ GetWindowLongPtr(m_clist.GetHwnd(), GWL_STYLE) | CLS_SHOWHIDDEN | CLS_HIDEOFFLINE | CLS_CHECKBOXES | CLS_HIDEEMPTYGROUPS | CLS_USEGROUPS | CLS_GREYALTERNATE | CLS_GROUPCHECKBOXES);
+ m_clist.SendMsg(CLM_SETEXSTYLE, CLS_EX_DISABLEDRAGDROP | CLS_EX_TRACKSELECT, 0);
+ ResetListOptions(&m_clist);
+ FilterList(&m_clist);
+ return true;
+ }
+
+ bool OnApply() override
+ {
+ auto *pMe = m_proto->FindUser(m_proto->GetId(db_event_getContact(m_ids[0])));
+ if (pMe == nullptr)
+ return false;
+
+ TD::array<TD::int53> message_ids;
+ for (auto &it : m_ids) {
+ DB::EventInfo dbei(it, false);
+ if (dbei && dbei.szId)
+ message_ids.push_back(_atoi64(dbei.szId));
+ }
+
+ for (auto &hContact : m_proto->AccContacts()) {
+ if (HANDLE hItem = m_clist.FindContact(hContact)) {
+ if (!m_clist.GetCheck(hItem))
+ continue;
+
+ auto *pUser = m_proto->FindUser(m_proto->GetId(hContact));
+
+ TD::array<TD::int53> ids = message_ids;
+ m_proto->SendQuery(new TD::forwardMessages(pUser->chatId, 0, pMe->chatId, std::move(ids), 0, false, false, false));
+ }
+ }
+
+ return true;
+ }
+};
+
+INT_PTR CTelegramProto::SvcExecMenu(WPARAM iCommand, LPARAM pHandle)
+{
+ switch (iCommand) {
+ case 1:
+ std::vector<MEVENT> ids = NS_GetSelection(HANDLE(pHandle));
+ if (!ids.empty())
+ CForwardDlg(this, ids).DoModal();
+ break;
+ }
+ return 0;
+}
diff --git a/protocols/Telegram/src/proto.cpp b/protocols/Telegram/src/proto.cpp
index 2434df7979..5dab129be9 100644
--- a/protocols/Telegram/src/proto.cpp
+++ b/protocols/Telegram/src/proto.cpp
@@ -68,6 +68,9 @@ CTelegramProto::CTelegramProto(const char* protoName, const wchar_t* userName) :
// default contacts group
m_iBaseGroup = Clist_GroupCreate(0, m_wszDefaultGroup);
+ // menus
+ InitMenus();
+
// Offline file transfer
CreateProtoService(PS_OFFLINEFILE, &CTelegramProto::OfflineFile);
diff --git a/protocols/Telegram/src/proto.h b/protocols/Telegram/src/proto.h
index a656671e53..ce514a20d3 100644
--- a/protocols/Telegram/src/proto.h
+++ b/protocols/Telegram/src/proto.h
@@ -124,6 +124,7 @@ struct TG_BASIC_GROUP
class CTelegramProto : public PROTO<CTelegramProto>
{
+ friend class CForwardDlg;
friend class CAddPhoneContactDlg;
class CProtoImpl
@@ -272,6 +273,14 @@ class CTelegramProto : public PROTO<CTelegramProto>
int64_t GetId(MCONTACT);
void SetId(MCONTACT, int64_t id);
+ // Menus
+ HGENMENU hmiForward;
+
+ void InitMenus();
+
+ INT_PTR __cdecl SvcExecMenu(WPARAM, LPARAM);
+ int __cdecl OnPrebuildMenu(WPARAM, LPARAM);
+
// Popups
HANDLE m_hPopupClass;
diff --git a/protocols/Telegram/src/resource.h b/protocols/Telegram/src/resource.h
index ad609319ce..ed4b28ca4a 100644
--- a/protocols/Telegram/src/resource.h
+++ b/protocols/Telegram/src/resource.h
@@ -7,6 +7,8 @@
#define IDD_OPTIONS 102
#define IDI_PREMIUM 103
#define IDD_OPTIONS_ADV 104
+#define IDI_FORWARD 105
+#define IDD_FORWARD 106
#define IDD_ADD_PHONE 107
#define IDC_PHONE 1001
#define IDC_DEFGROUP 1002
@@ -24,6 +26,7 @@
#define IDC_CODE 1013
#define IDC_FIRST_NAME 1014
#define IDC_LAST_NAME 1015
+#define IDC_CLIST 1016
// Next default values for new objects
//
diff --git a/protocols/Telegram/src/stdafx.h b/protocols/Telegram/src/stdafx.h
index 41799575cc..dad748c7cd 100644
--- a/protocols/Telegram/src/stdafx.h
+++ b/protocols/Telegram/src/stdafx.h
@@ -25,6 +25,7 @@
#include <m_langpack.h>
#include <m_message.h>
#include <m_netlib.h>
+#include <m_NewStory.h>
#include <m_options.h>
#include <m_popup.h>
#include <m_skin.h>