summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2021-06-26 16:44:39 +0300
committerGeorge Hazan <ghazan@miranda.im>2021-06-26 16:44:39 +0300
commit6243cc7ff0fdea65144d30f998c184a189238848 (patch)
tree6f7089cea3bc3b25251b491d0bc85921812c67a1
parent0e743376ba4c30724b7d17181b0b98e0aa9a0c01 (diff)
for #2928 - atavism removed from IRC: scripting support
-rw-r--r--protocols/IRCG/IRC.vcxproj1
-rw-r--r--protocols/IRCG/IRC.vcxproj.filters3
-rw-r--r--protocols/IRCG/res/IRC.rc27
-rw-r--r--protocols/IRCG/src/irclib.cpp43
-rw-r--r--protocols/IRCG/src/ircproto.cpp5
-rw-r--r--protocols/IRCG/src/ircproto.h9
-rw-r--r--protocols/IRCG/src/options.cpp6
-rw-r--r--protocols/IRCG/src/resource.h1
-rw-r--r--protocols/IRCG/src/scripting.cpp176
-rw-r--r--protocols/IRCG/src/version.h2
10 files changed, 20 insertions, 253 deletions
diff --git a/protocols/IRCG/IRC.vcxproj b/protocols/IRCG/IRC.vcxproj
index 5fb0ac705f..48f0607e3f 100644
--- a/protocols/IRCG/IRC.vcxproj
+++ b/protocols/IRCG/IRC.vcxproj
@@ -34,7 +34,6 @@
<ClCompile Include="src\main.cpp" />
<ClCompile Include="src\options.cpp" />
<ClCompile Include="src\output.cpp" />
- <ClCompile Include="src\scripting.cpp" />
<ClCompile Include="src\services.cpp" />
<ClCompile Include="src\stdafx.cxx">
<PrecompiledHeader>Create</PrecompiledHeader>
diff --git a/protocols/IRCG/IRC.vcxproj.filters b/protocols/IRCG/IRC.vcxproj.filters
index 1e3539454b..6cd2ce5826 100644
--- a/protocols/IRCG/IRC.vcxproj.filters
+++ b/protocols/IRCG/IRC.vcxproj.filters
@@ -26,9 +26,6 @@
<ClCompile Include="src\output.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="src\scripting.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="src\services.cpp">
<Filter>Source Files</Filter>
</ClCompile>
diff --git a/protocols/IRCG/res/IRC.rc b/protocols/IRCG/res/IRC.rc
index 27dec7e55f..9d7317d906 100644
--- a/protocols/IRCG/res/IRC.rc
+++ b/protocols/IRCG/res/IRC.rc
@@ -187,11 +187,9 @@ BEGIN
EDITTEXT IDC_PERFORMEDIT,10,60,124,68,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN | WS_VSCROLL | WS_HSCROLL | WS_GROUP
CONTROL "&Set",IDC_ADD,"MButtonClass",WS_DISABLED | WS_TABSTOP,35,134,30,14,WS_EX_NOACTIVATE | 0x10000000L
CONTROL "&Del",IDC_DELETE,"MButtonClass",WS_DISABLED | WS_TABSTOP,84,134,30,14,WS_EX_NOACTIVATE | 0x10000000L
- GROUPBOX "Alias",IDC_STATIC,144,4,157,122
- EDITTEXT IDC_ALIASEDIT,152,18,145,102,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN | WS_VSCROLL | WS_HSCROLL
+ GROUPBOX "Alias",IDC_STATIC,144,4,157,152
+ EDITTEXT IDC_ALIASEDIT,150,15,145,136,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | ES_WANTRETURN | WS_VSCROLL | WS_HSCROLL
LTEXT "Perform on event:",IDC_STATIC,10,32,124,8,0,WS_EX_TRANSPARENT
- GROUPBOX "Scripting support",IDC_STATIC,145,128,156,28
- CONTROL "Enable",IDC_SCRIPT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,152,140,145,10
GROUPBOX "Other",IDC_STATIC,4,156,297,66
LTEXT "Quit message:",IDC_STATIC,10,166,287,8
EDITTEXT IDC_QUITMESSAGE,10,176,287,12,ES_AUTOHSCROLL
@@ -461,23 +459,7 @@ BEGIN
BEGIN
LEFTMARGIN, 2
RIGHTMARGIN, 301
- VERTGUIDE, 10
- VERTGUIDE, 134
- VERTGUIDE, 145
- VERTGUIDE, 152
- VERTGUIDE, 220
- VERTGUIDE, 262
- VERTGUIDE, 283
- VERTGUIDE, 297
BOTTOMMARGIN, 217
- HORZGUIDE, 6
- HORZGUIDE, 28
- HORZGUIDE, 49
- HORZGUIDE, 117
- HORZGUIDE, 124
- HORZGUIDE, 131
- HORZGUIDE, 145
- HORZGUIDE, 174
END
IDD_LIST, DIALOG
@@ -629,6 +611,11 @@ BEGIN
0
END
+IDD_PREFS_OTHER AFX_DIALOG_LAYOUT
+BEGIN
+ 0
+END
+
#endif // Neutral resources
/////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/IRCG/src/irclib.cpp b/protocols/IRCG/src/irclib.cpp
index 0fe6ed79ef..73629ae988 100644
--- a/protocols/IRCG/src/irclib.cpp
+++ b/protocols/IRCG/src/irclib.cpp
@@ -280,8 +280,10 @@ int CIrcProto::NLSend(const unsigned char* buf, int cbBuf)
{
if (!con || !buf)
return 0;
- if (m_scriptingEnabled && cbBuf == 0)
+
+ if (cbBuf == 0)
cbBuf = (int)mir_strlen((const char *)buf);
+
return Netlib_Send(con, (const char*)buf, cbBuf, MSG_DUMPASTEXT);
}
@@ -340,19 +342,6 @@ void CIrcProto::InsertIncomingEvent(wchar_t* pszRaw)
Notify(&msg);
}
-void CIrcProto::createMessageFromPchar(const char* p)
-{
- wchar_t *ptszMsg;
- if (codepage != CP_UTF8 && m_utfAutodetect) {
- if (mir_utf8decodecp(NEWSTR_ALLOCA(p), codepage, &ptszMsg) == nullptr)
- ptszMsg = mir_a2u_cp(p, codepage);
- }
- else ptszMsg = mir_a2u_cp(p, codepage);
- CIrcMessage msg(this, ptszMsg, codepage, true);
- Notify(&msg);
- mir_free(ptszMsg);
-}
-
void CIrcProto::DoReceive()
{
char chBuf[1024 * 4 + 1];
@@ -399,24 +388,14 @@ void CIrcProto::DoReceive()
// process single message by monitor objects
if (*pStart) {
- if (m_scriptingEnabled) {
- char* pszTemp = mir_strdup(pStart);
-
- if (pszTemp) {
- char* p1 = pszTemp;
- // replace end-of-line with NULLs
- while (*p1 != 0) {
- if (*p1 == '\r' || *p1 == '\n')
- *p1 = 0;
- p1++;
- }
-
- createMessageFromPchar(pszTemp);
- }
-
- mir_free(pszTemp);
- }
- else createMessageFromPchar(pStart);
+ ptrW ptszMsg;
+ if (codepage != CP_UTF8 && m_utfAutodetect && Utf8CheckString(pStart))
+ ptszMsg = mir_utf8decodeW(pStart);
+ else
+ ptszMsg = mir_a2u_cp(pStart, codepage);
+
+ CIrcMessage msg(this, ptszMsg, codepage, true);
+ Notify(&msg);
}
cbInBuf -= pEnd - pStart;
diff --git a/protocols/IRCG/src/ircproto.cpp b/protocols/IRCG/src/ircproto.cpp
index 6607277681..c6a4e86737 100644
--- a/protocols/IRCG/src/ircproto.cpp
+++ b/protocols/IRCG/src/ircproto.cpp
@@ -55,11 +55,6 @@ CIrcProto::CIrcProto(const char* szModuleName, const wchar_t* tszUserName) :
CreateProtoService(IRC_UM_IGNORE, &CIrcProto::OnMenuIgnore);
CreateProtoService("/DblClickEvent", &CIrcProto::OnDoubleclicked);
- CreateProtoService("/InsertRawIn", &CIrcProto::Scripting_InsertRawIn);
- CreateProtoService("/InsertRawOut", &CIrcProto::Scripting_InsertRawOut);
- CreateProtoService("/InsertGuiIn", &CIrcProto::Scripting_InsertGuiIn);
- CreateProtoService("/InsertGuiOut", &CIrcProto::Scripting_InsertGuiOut);
- CreateProtoService("/GetIrcData", &CIrcProto::Scripting_GetIrcData);
HookProtoEvent(ME_DB_CONTACT_SETTINGCHANGED, &CIrcProto::OnDbSettingChanged);
HookProtoEvent(ME_OPT_INITIALISE, &CIrcProto::OnInitOptionsPages);
diff --git a/protocols/IRCG/src/ircproto.h b/protocols/IRCG/src/ircproto.h
index 6f1a5d1ff1..1cd646d368 100644
--- a/protocols/IRCG/src/ircproto.h
+++ b/protocols/IRCG/src/ircproto.h
@@ -123,7 +123,6 @@ struct CIrcProto : public PROTO<CIrcProto>
int m_quickComboSelection;
int m_onlineNotificationTime;
int m_onlineNotificationLimit;
- BYTE m_scriptingEnabled;
BYTE m_IPFromServer;
BYTE m_showAddresses;
BYTE m_disconnectDCCChats;
@@ -255,13 +254,6 @@ struct CIrcProto : public PROTO<CIrcProto>
// output
BOOL ShowMessage(const CIrcMessage *pmsg);
- // scripting.cpp
- INT_PTR __cdecl Scripting_InsertRawIn(WPARAM wParam, LPARAM lParam);
- INT_PTR __cdecl Scripting_InsertRawOut(WPARAM wParam, LPARAM lParam);
- INT_PTR __cdecl Scripting_InsertGuiIn(WPARAM wParam, LPARAM lParam);
- INT_PTR __cdecl Scripting_InsertGuiOut(WPARAM wParam, LPARAM lParam);
- INT_PTR __cdecl Scripting_GetIrcData(WPARAM wparam, LPARAM lparam);
-
// services.cpp
void ConnectToServer(void);
void DisconnectFromServer(void);
@@ -336,7 +328,6 @@ protected:
private:
mir_cs m_dcc; // protect the dcc objects
- void createMessageFromPchar(const char* p);
void Notify(const CIrcMessage *pmsg);
void __cdecl ThreadProc(void *pparam);
diff --git a/protocols/IRCG/src/options.cpp b/protocols/IRCG/src/options.cpp
index f8bb7c8dab..aa5dc2c6cd 100644
--- a/protocols/IRCG/src/options.cpp
+++ b/protocols/IRCG/src/options.cpp
@@ -583,7 +583,6 @@ static TDbSetting OtherSettings[] =
{ FIELD_OFFSET(CIrcProto, m_codepage), "Codepage", DBVT_DWORD, 0, CP_ACP },
{ FIELD_OFFSET(CIrcProto, m_utfAutodetect), "UtfAutodetect", DBVT_BYTE },
{ FIELD_OFFSET(CIrcProto, m_perform), "Perform", DBVT_BYTE },
- { FIELD_OFFSET(CIrcProto, m_scriptingEnabled), "ScriptingEnabled", DBVT_BYTE }
};
static char* sttPerformEvents[] = {
@@ -628,7 +627,7 @@ class COtherPrefsDlg : public CIrcBaseDlg
CCtrlMButton m_add, m_delete;
CCtrlCombo m_performCombo, m_codepage;
CCtrlEdit m_pertormEdit, m_quitMessage, m_alias;
- CCtrlCheck m_perform, m_scripting, m_autodetect;
+ CCtrlCheck m_perform, m_autodetect;
public:
COtherPrefsDlg(CIrcProto *_pro) :
@@ -638,7 +637,6 @@ public:
m_codepage(this, IDC_CODEPAGE),
m_pertormEdit(this, IDC_PERFORMEDIT),
m_perform(this, IDC_PERFORM),
- m_scripting(this, IDC_SCRIPT),
m_autodetect(this, IDC_UTF_AUTODETECT),
m_quitMessage(this, IDC_QUITMESSAGE),
m_alias(this, IDC_ALIASEDIT),
@@ -663,7 +661,6 @@ public:
m_alias.SetText(m_proto->m_alias);
m_quitMessage.SetText(m_proto->m_quitMessage);
m_perform.SetState(m_proto->m_perform);
- m_scripting.SetState(m_proto->m_scriptingEnabled);
m_performCombo.Enable(m_proto->m_perform);
m_pertormEdit.Enable(m_proto->m_perform);
m_add.Enable(m_proto->m_perform);
@@ -710,7 +707,6 @@ public:
m_proto->m_utfAutodetect = m_autodetect.GetState();
m_proto->m_perform = m_perform.GetState();
- m_proto->m_scriptingEnabled = m_scripting.GetState();
if (m_add.Enabled())
OnAdd(nullptr);
diff --git a/protocols/IRCG/src/resource.h b/protocols/IRCG/src/resource.h
index a57abd37e5..cc7a8a0371 100644
--- a/protocols/IRCG/src/resource.h
+++ b/protocols/IRCG/src/resource.h
@@ -135,7 +135,6 @@
#define IDC_COMBO 1196
#define IDC_DISC 1197
#define IDC_FROMSERVER 1201
-#define IDC_SCRIPT 1202
#define IDC_MASK 1204
#define IDC_Q 1205
#define IDC_M 1206
diff --git a/protocols/IRCG/src/scripting.cpp b/protocols/IRCG/src/scripting.cpp
deleted file mode 100644
index 8d15cc6da4..0000000000
--- a/protocols/IRCG/src/scripting.cpp
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
-IRC plugin for Miranda IM
-
-Copyright (C) 2003-05 Jurgen Persson
-Copyright (C) 2007-09 George Hazan
-
-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; either version 2
-of the License, or (at your option) any later version.
-
-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, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#include "stdafx.h"
-
-INT_PTR __cdecl CIrcProto::Scripting_InsertRawIn(WPARAM, LPARAM lParam)
-{
- char* pszRaw = (char*)lParam;
-
- if (m_scriptingEnabled && pszRaw && IsConnected()) {
- wchar_t* p = mir_a2u(pszRaw);
- InsertIncomingEvent(p);
- mir_free(p);
- return 0;
- }
-
- return 1;
-}
-
-INT_PTR __cdecl CIrcProto::Scripting_InsertRawOut( WPARAM, LPARAM lParam )
-{
- char* pszRaw = (char*)lParam;
- if (m_scriptingEnabled && pszRaw && IsConnected()) {
- CMStringA S = pszRaw;
- S.Replace("%", "%%%%");
- NLSendNoScript((const unsigned char *)S.c_str(), (int)mir_strlen(S.c_str()));
- return 0;
- }
-
- return 1;
-}
-
-INT_PTR __cdecl CIrcProto::Scripting_InsertGuiIn(WPARAM, LPARAM)
-{
- return 1;
-}
-
-//helper functions
-static void __stdcall OnHook(void * pi)
-{
- GCHOOK* gch = (GCHOOK*)pi;
- free(gch->ptszUID);
- free(gch->ptszText);
- delete gch;
-}
-
-static void __cdecl GuiOutThread(GCHOOK *gch)
-{
- Thread_SetName("IRC: GuiOutThread");
- CallFunctionAsync(OnHook, gch);
-}
-
-INT_PTR __cdecl CIrcProto::Scripting_InsertGuiOut(WPARAM, LPARAM lParam)
-{
- GCHOOK* gch = (GCHOOK*)lParam;
-
- if (m_scriptingEnabled && gch) {
- GCHOOK* gchook = new GCHOOK;
- gchook->dwData = gch->dwData;
- gchook->iType = gch->iType;
- if (gch->ptszText)
- gchook->ptszText = wcsdup(gch->ptszText);
- else
- gchook->ptszText = nullptr;
-
- if (gch->ptszUID)
- gchook->ptszUID = wcsdup(gch->ptszUID);
- else
- gchook->ptszUID = nullptr;
-
- mir_forkThread<GCHOOK>(GuiOutThread, gchook);
- return 0;
- }
-
- return 1;
-}
-
-INT_PTR __cdecl CIrcProto::Scripting_GetIrcData(WPARAM, LPARAM lparam)
-{
- if (m_scriptingEnabled && lparam) {
- CMStringA sString = (char*)lparam, sRequest;
- CMStringW sOutput, sChannel;
-
- int i = sString.Find("|");
- if (i != -1) {
- sRequest = sString.Mid(0, i);
- wchar_t* p = mir_a2u(sString.Mid(i + 1));
- sChannel = p;
- mir_free(p);
- }
- else sRequest = sString;
-
- sRequest.MakeLower();
-
- if (sRequest == "ownnick" && IsConnected())
- sOutput = m_info.sNick;
-
- else if (sRequest == "primarynick")
- sOutput = m_nick;
-
- else if (sRequest == "secondarynick")
- sOutput = m_alternativeNick;
-
- else if (sRequest == "myip")
- return (INT_PTR)mir_strdup(m_manualHost ? m_mySpecifiedHostIP :
- (m_IPFromServer) ? m_myHost : m_myLocalHost);
-
- else if (sRequest == "usercount" && !sChannel.IsEmpty()) {
- GC_INFO gci = { 0 };
- gci.Flags = GCF_BYID | GCF_COUNT;
- gci.pszModule = m_szModuleName;
- gci.pszID = sChannel.c_str();
- if (!Chat_GetInfo(&gci)) {
- wchar_t szTemp[40];
- mir_snwprintf(szTemp, L"%u", gci.iCount);
- sOutput = szTemp;
- }
- }
- else if (sRequest == "userlist" && !sChannel.IsEmpty()) {
- GC_INFO gci = { 0 };
- gci.Flags = GCF_BYID | GCF_USERS;
- gci.pszModule = m_szModuleName;
- gci.pszID = sChannel.c_str();
- if (!Chat_GetInfo(&gci))
- return (INT_PTR)mir_strdup(gci.pszUsers);
- }
- else if (sRequest == "channellist") {
- CMStringW S = L"";
- int n = g_chatApi.SM_GetCount(m_szModuleName);
- if (n >= 0) {
- int j = 0;
- while (j < n) {
- GC_INFO gci = { 0 };
- gci.Flags = GCF_BYINDEX | GCF_ID;
- gci.pszModule = m_szModuleName;
- gci.iItem = j;
- if (!Chat_GetInfo(&gci)) {
- if (mir_wstrcmpi(gci.pszID, SERVERWINDOW)) {
- CMStringW S1 = gci.pszID;
- int k = S1.Find(L" ");
- if (k != -1)
- S1 = S1.Mid(0, k);
- S += S1 + L" ";
- }
- }
- j++;
- }
- }
-
- if (!S.IsEmpty())
- sOutput = (wchar_t*)S.c_str();
- }
- // send it to mbot
- if (!sOutput.IsEmpty())
- return (INT_PTR)mir_u2a(sOutput.c_str());
- }
- return 0;
-}
diff --git a/protocols/IRCG/src/version.h b/protocols/IRCG/src/version.h
index 0e67ee5bb7..9d4eeed3ac 100644
--- a/protocols/IRCG/src/version.h
+++ b/protocols/IRCG/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 96
#define __RELEASE_NUM 1
-#define __BUILD_NUM 1
+#define __BUILD_NUM 2
#include <stdver.h>