summaryrefslogtreecommitdiff
path: root/plugins/New_GPG
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2020-06-23 13:23:22 +0300
committerGeorge Hazan <ghazan@miranda.im>2020-06-23 13:23:22 +0300
commit324885a4d935f29c22cd641c586b7a179b5690e5 (patch)
treed7f14d9330ea9de1d11038fed0270c32e6283b46 /plugins/New_GPG
parent79ac2b9aa18914e0394562144171581c5bbf42d7 (diff)
New_GPG:
- massive code cleaning; - obsolete extra icon management code removed; - added code to visualize service events correctly; - version bump
Diffstat (limited to 'plugins/New_GPG')
-rw-r--r--plugins/New_GPG/new_gpg.vcxproj1
-rw-r--r--plugins/New_GPG/new_gpg.vcxproj.filters3
-rw-r--r--plugins/New_GPG/src/clist.cpp31
-rwxr-xr-xplugins/New_GPG/src/icons.cpp21
-rwxr-xr-xplugins/New_GPG/src/init.cpp32
-rwxr-xr-xplugins/New_GPG/src/messages.cpp48
-rwxr-xr-xplugins/New_GPG/src/options.cpp8
-rwxr-xr-xplugins/New_GPG/src/srmm.cpp3
-rwxr-xr-xplugins/New_GPG/src/ui.cpp3
-rwxr-xr-xplugins/New_GPG/src/utilities.cpp35
-rwxr-xr-xplugins/New_GPG/src/utilities.h62
-rwxr-xr-xplugins/New_GPG/src/version.h2
12 files changed, 67 insertions, 182 deletions
diff --git a/plugins/New_GPG/new_gpg.vcxproj b/plugins/New_GPG/new_gpg.vcxproj
index 89b32a5a34..e920bfe3b0 100644
--- a/plugins/New_GPG/new_gpg.vcxproj
+++ b/plugins/New_GPG/new_gpg.vcxproj
@@ -26,7 +26,6 @@
<Import Project="$(ProjectDir)..\..\build\vc.common\plugin.props" />
</ImportGroup>
<ItemGroup>
- <ClCompile Include="src\clist.cpp" />
<ClCompile Include="src\gpg_wrapper.cpp" />
<ClCompile Include="src\icons.cpp" />
<ClCompile Include="src\init.cpp" />
diff --git a/plugins/New_GPG/new_gpg.vcxproj.filters b/plugins/New_GPG/new_gpg.vcxproj.filters
index 677ee988a4..f0c56b7a7c 100644
--- a/plugins/New_GPG/new_gpg.vcxproj.filters
+++ b/plugins/New_GPG/new_gpg.vcxproj.filters
@@ -2,9 +2,6 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(ProjectDir)..\..\build\vc.common\common.filters" />
<ItemGroup>
- <ClCompile Include="src\clist.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="src\gpg_wrapper.cpp">
<Filter>Source Files</Filter>
</ClCompile>
diff --git a/plugins/New_GPG/src/clist.cpp b/plugins/New_GPG/src/clist.cpp
deleted file mode 100644
index 06554cd7b5..0000000000
--- a/plugins/New_GPG/src/clist.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright © 2010-20 SecureIM developers (baloo and others), sss
-//
-// 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"
-
-void RefreshContactListIcons(void);
-
-int onExtraImageListRebuilding(WPARAM, LPARAM)
-{
- RefreshContactListIcons();
- return 0;
-}
-
-int onExtraImageApplying(WPARAM wParam, LPARAM)
-{
- setClistIcon(wParam);
- return 0;
-}
diff --git a/plugins/New_GPG/src/icons.cpp b/plugins/New_GPG/src/icons.cpp
index 7dc7a9677b..70271a654f 100755
--- a/plugins/New_GPG/src/icons.cpp
+++ b/plugins/New_GPG/src/icons.cpp
@@ -32,16 +32,6 @@ HANDLE IconLibHookIconsChanged(MIRANDAHOOK hook)
return HookEvent(ME_SKIN_ICONSCHANGED, hook);
}
-void setClistIcon(MCONTACT hContact)
-{
- bool enabled = isContactSecured(hContact);
- MCONTACT hMC = db_mc_tryMeta(hContact);
- const char *szIconId = (enabled) ? "secured" : nullptr;
- ExtraIcon_SetIconByName(globals.g_hCLIcon, hContact, szIconId);
- if (hMC != hContact)
- ExtraIcon_SetIconByName(globals.g_hCLIcon, hMC, szIconId);
-}
-
void setSrmmIcon(MCONTACT h)
{
MCONTACT hContact = db_mc_isMeta(h) ? metaGetMostOnline(h) : h;
@@ -57,12 +47,9 @@ void setSrmmIcon(MCONTACT h)
Srmm_SetIconFlags(hContact, MODULENAME, 2, flags);
if (hMC != hContact)
Srmm_SetIconFlags(hMC, MODULENAME, 2, flags);
-}
-
-void RefreshContactListIcons()
-{
- for (auto &hContact : Contacts())
- setClistIcon(hContact);
- Clist_EndRebuild();
+ const char *szIconId = (enabled) ? "secured" : nullptr;
+ ExtraIcon_SetIconByName(globals.g_hCLIcon, hContact, szIconId);
+ if (hMC != hContact)
+ ExtraIcon_SetIconByName(globals.g_hCLIcon, hMC, szIconId);
}
diff --git a/plugins/New_GPG/src/init.cpp b/plugins/New_GPG/src/init.cpp
index 0eb491947b..46b405bad0 100755
--- a/plugins/New_GPG/src/init.cpp
+++ b/plugins/New_GPG/src/init.cpp
@@ -73,9 +73,6 @@ INT_PTR ExportGpGKeys(WPARAM, LPARAM);
INT_PTR ImportGpGKeys(WPARAM, LPARAM);
INT_PTR ToggleEncryption(WPARAM, LPARAM);
-int onExtraImageApplying(WPARAM, LPARAM);
-int onExtraImageListRebuilding(WPARAM, LPARAM);
-
void InitIconLib();
void init_vars()
@@ -132,8 +129,31 @@ static int OnShutdown(WPARAM, LPARAM)
return 0;
}
+static INT_PTR EventGetIcon(WPARAM flags, LPARAM)
+{
+ HICON hIcon = g_plugin.getIcon(IDI_SECURED);
+ return (INT_PTR)((flags & LR_SHARED) ? hIcon : CopyIcon(hIcon));
+}
+
+static INT_PTR GetEventText(WPARAM pEvent, LPARAM datatype)
+{
+ DBEVENTINFO *dbei = (DBEVENTINFO *)pEvent;
+ ptrW wszText(mir_utf8decodeW((char *)dbei->pBlob));
+ return (datatype != DBVT_WCHAR) ? (INT_PTR)mir_u2a(wszText) : (INT_PTR)wszText.detach();
+}
+
int CMPlugin::Load()
{
+ DBEVENTTYPEDESCR dbEventType = {};
+ dbEventType.module = MODULENAME;
+ dbEventType.descr = "GPG service event";
+ dbEventType.iconService = MODULENAME "/GetEventIcon";
+ dbEventType.textService = MODULENAME "/GetEventText";
+ DbEvent_RegisterType(&dbEventType);
+
+ CreateServiceFunction(dbEventType.iconService, &EventGetIcon);
+ CreateServiceFunction(dbEventType.textService, &GetEventText);
+
HookEvent(ME_CLIST_PREBUILDCONTACTMENU, OnPreBuildContactMenu);
HookEvent(ME_DB_EVENT_FILTER_ADD, HookSendMsg);
HookEvent(ME_OPT_INITIALISE, GpgOptInit);
@@ -194,13 +214,17 @@ int CMPlugin::Load()
Menu_AddMainMenuItem(&mi);
CreateServiceFunction(mi.pszService, ImportGpGKeys);
- globals.g_hCLIcon = ExtraIcon_RegisterCallback(MODULENAME, Translate("GPG encryption status"), "secured", onExtraImageListRebuilding, onExtraImageApplying);
+ ////////////////////////////////////////////////////////////////////////////////////////
+ // Extra icon
+
+ globals.g_hCLIcon = ExtraIcon_RegisterIcolib(MODULENAME, Translate("GPG encryption status"), "secured");
return 0;
}
/////////////////////////////////////////////////////////////////////////////////////////
extern list<wstring> transfers;
+
int CMPlugin::Unload()
{
for (auto p : transfers)
diff --git a/plugins/New_GPG/src/messages.cpp b/plugins/New_GPG/src/messages.cpp
index cbf7c397b1..f5deedd289 100755
--- a/plugins/New_GPG/src/messages.cpp
+++ b/plugins/New_GPG/src/messages.cpp
@@ -20,7 +20,7 @@ std::list<HANDLE> sent_msgs;
struct RecvParams
{
- RecvParams(MCONTACT _p1, std::wstring _p2, char *_p3, DWORD _p4) :
+ RecvParams(MCONTACT _p1, std::wstring _p2, const char *_p3, DWORD _p4) :
hContact(_p1),
str(_p2),
msg(_p3),
@@ -29,13 +29,12 @@ struct RecvParams
MCONTACT hContact;
std::wstring str;
- char *msg;
+ std::string msg;
DWORD timestamp;
};
static void RecvMsgSvc_func(RecvParams *param)
{
- DWORD dbflags = DBEF_UTF;
MCONTACT hContact = param->hContact;
std::string szScreenName(toUTF8(Clist_GetContactDisplayName(hContact)));
{
@@ -52,17 +51,15 @@ static void RecvMsgSvc_func(RecvParams *param)
else {
g_plugin.setByte(db_mc_isMeta(hContact) ? metaGetMostOnline(hContact) : hContact, "GPGEncryption", 1);
setSrmmIcon(hContact);
- setClistIcon(hContact);
}
if (isContactHaveKey(hContact)) {
g_plugin.setByte(db_mc_isMeta(hContact) ? metaGetMostOnline(hContact) : hContact, "GPGEncryption", 1);
setSrmmIcon(hContact);
- setClistIcon(hContact);
}
}
else if (MessageBox(nullptr, TranslateT("Do you want to try to decrypt encrypted message?"), TranslateT("Warning"), MB_YESNO) == IDNO) {
- HistoryLog(hContact, db_event(param->msg, param->timestamp, 0, dbflags));
+ HistoryLog(hContact, param->msg.c_str(), param->timestamp);
delete param;
return;
}
@@ -93,7 +90,6 @@ static void RecvMsgSvc_func(RecvParams *param)
if (count >= timeout) {
g_plugin.setByte(hContact, "GPGEncryption", 0);
setSrmmIcon(hContact);
- setClistIcon(hContact);
globals.debuglog << "info: failed to create temporary file for decryption, disabling gpg for contact to avoid deadlock";
delete param;
return;
@@ -154,7 +150,7 @@ static void RecvMsgSvc_func(RecvParams *param)
boost::system::error_code e;
boost::filesystem::remove(path, e);
}
- HistoryLog(hContact, db_event(param->msg, param->timestamp, 0, dbflags));
+ HistoryLog(hContact, param->msg.c_str(), param->timestamp);
SendErrorMessage(hContact);
delete param;
return;
@@ -165,7 +161,7 @@ static void RecvMsgSvc_func(RecvParams *param)
boost::filesystem::remove(path, e);
}
- HistoryLog(hContact, db_event(param->msg, param->timestamp, 0, dbflags));
+ HistoryLog(hContact, param->msg.c_str(), param->timestamp);
delete param;
return;
}
@@ -207,7 +203,7 @@ static void RecvMsgSvc_func(RecvParams *param)
boost::filesystem::remove(path, e);
}
- HistoryLog(hContact, db_event(param->msg, param->timestamp, 0, dbflags));
+ HistoryLog(hContact, param->msg.c_str(), param->timestamp);
SendErrorMessage(hContact);
delete param;
return;
@@ -218,7 +214,7 @@ static void RecvMsgSvc_func(RecvParams *param)
boost::filesystem::remove(path, e);
}
- HistoryLog(hContact, db_event(param->msg, param->timestamp, 0, dbflags));
+ HistoryLog(hContact, param->msg.c_str(), param->timestamp);
delete param;
return;
}
@@ -230,7 +226,7 @@ static void RecvMsgSvc_func(RecvParams *param)
boost::filesystem::remove(path, e);
}
- HistoryLog(hContact, db_event(param->msg, param->timestamp, 0, dbflags));
+ HistoryLog(hContact, param->msg.c_str(), param->timestamp);
SendErrorMessage(hContact);
delete param;
return;
@@ -242,7 +238,7 @@ static void RecvMsgSvc_func(RecvParams *param)
boost::filesystem::remove(path, e);
}
- HistoryLog(hContact, db_event(param->msg, param->timestamp, 0, dbflags));
+ HistoryLog(hContact, param->msg.c_str(), param->timestamp);
}
if (!globals.debuglog) {
@@ -258,7 +254,7 @@ static void RecvMsgSvc_func(RecvParams *param)
ptrA tmp4((char*)mir_alloc(sizeof(char)*(str1.length() + 1)));
mir_strcpy(tmp4, str1.c_str());
- HistoryLog(hContact, db_event(param->msg, param->timestamp, 0, dbflags));
+ HistoryLog(hContact, param->msg.c_str(), param->timestamp);
SendErrorMessage(hContact);
delete param;
return;
@@ -294,7 +290,7 @@ static void RecvMsgSvc_func(RecvParams *param)
if (globals.debuglog)
globals.debuglog << "info: Failed to decrypt GPG encrypted message.";
- HistoryLog(hContact, db_event(param->msg, param->timestamp, 0, dbflags));
+ HistoryLog(hContact, param->msg.c_str(), param->timestamp);
SendErrorMessage(hContact);
delete param;
return;
@@ -307,7 +303,7 @@ static void RecvMsgSvc_func(RecvParams *param)
}
char *tmp = mir_strdup(toUTF8(param->str).c_str());
- HistoryLog(hContact, db_event(tmp, param->timestamp, 0, dbflags));
+ HistoryLog(hContact, tmp, param->timestamp);
mir_free(tmp);
delete param;
return;
@@ -316,12 +312,12 @@ static void RecvMsgSvc_func(RecvParams *param)
}
if (g_plugin.getByte(db_mc_isMeta(hContact) ? metaGetMostOnline(hContact) : hContact, "GPGEncryption")) {
- HistoryLog(hContact, db_event(param->msg, param->timestamp, 0, dbflags | DBEF_READ));
+ HistoryLog(hContact, param->msg.c_str(), param->timestamp, DBEF_READ);
delete param;
return;
}
- HistoryLog(hContact, db_event(param->msg, param->timestamp, 0, dbflags));
+ HistoryLog(hContact, param->msg.c_str(), param->timestamp);
delete param;
}
@@ -337,7 +333,6 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l)
if (!msg)
return Proto_ChainRecv(w, ccs);
- DWORD dbflags = DBEF_UTF;
if (db_mc_isMeta(ccs->hContact)) {
if (!strstr(msg, "-----BEGIN PGP MESSAGE-----"))
return Proto_ChainRecv(w, ccs);
@@ -380,7 +375,6 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l)
if (count >= timeout) {
g_plugin.setByte(ccs->hContact, "GPGEncryption", 0);
setSrmmIcon(ccs->hContact);
- setClistIcon(ccs->hContact);
globals.debuglog << "info: failed to create temporary file for decryption, disabling gpg for contact to avoid deadlock";
return 1;
}
@@ -455,11 +449,9 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l)
g_plugin.setByte(ccs->hContact, "GPGEncryption", 1);
g_plugin.setByte(ccs->hContact, "bAlwatsTrust", 1);
setSrmmIcon(ccs->hContact);
- setClistIcon(ccs->hContact);
- if (db_mc_isSub(ccs->hContact)) {
+ if (db_mc_isSub(ccs->hContact))
setSrmmIcon(db_mc_getMeta(ccs->hContact));
- setClistIcon(db_mc_getMeta(ccs->hContact));
- }
+
HistoryLog(ccs->hContact, "PGP Encryption turned on by key autoexchange feature");
}
return 1;
@@ -481,7 +473,7 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l)
s2 += mir_wstrlen(L"-----END PGP PRIVATE KEY BLOCK-----");
CDlgNewKey *d = new CDlgNewKey(ccs->hContact, str.substr(s1, s2 - s1));
d->Show();
- HistoryLog(ccs->hContact, db_event(msg, 0, 0, dbflags));
+ HistoryLog(ccs->hContact, msg);
return 0;
}
@@ -549,7 +541,7 @@ LBL_Relaunch:
{
CMStringA tmp(g_plugin.getMStringA(hContact, "KeyID"));
if (tmp.IsEmpty()) {
- HistoryLog(hContact, db_event("Failed to encrypt message with GPG (not found key for encryption in db)", 0, 0, DBEF_SENT));
+ HistoryLog(hContact, "Failed to encrypt message with GPG (not found key for encryption in db", DBEF_SENT);
ProtoChainSend(hContact, PSS_MESSAGE, flags, (LPARAM)msg);
return;
}
@@ -579,7 +571,6 @@ LBL_Relaunch:
if (count >= timeout) {
g_plugin.setByte(hContact, "GPGEncryption", 0); //disable encryption
setSrmmIcon(hContact);
- setClistIcon(hContact);
globals.debuglog << "info: failed to create temporary file for encryption, disabling encryption to avoid deadlock";
break;
}
@@ -637,7 +628,6 @@ LBL_Relaunch:
if (count >= timeout) {
g_plugin.setByte(hContact, "GPGEncryption", 0); //disable encryption
setSrmmIcon(hContact);
- setClistIcon(hContact);
globals.debuglog << "info: gpg failed to encrypt message, disabling encryption to avoid deadlock";
break;
}
@@ -660,7 +650,7 @@ LBL_Relaunch:
}
if (str.empty()) {
- HistoryLog(hContact, db_event("Failed to encrypt message with GPG", 0, 0, DBEF_SENT));
+ HistoryLog(hContact, "Failed to encrypt message with GPG", DBEF_SENT);
if (globals.debuglog)
globals.debuglog << "info: Failed to encrypt message with GPG";
ProtoChainSend(hContact, PSS_MESSAGE, flags, (LPARAM)msg);
diff --git a/plugins/New_GPG/src/options.cpp b/plugins/New_GPG/src/options.cpp
index c3ff7da01e..2f2b61d5ea 100755
--- a/plugins/New_GPG/src/options.cpp
+++ b/plugins/New_GPG/src/options.cpp
@@ -201,7 +201,6 @@ public:
g_plugin.delSetting(hcnt, "KeyType");
g_plugin.delSetting(hcnt, "KeyMainEmail");
g_plugin.delSetting(hcnt, "KeyComment");
- setClistIcon(hcnt);
setSrmmIcon(hcnt);
}
}
@@ -213,7 +212,6 @@ public:
g_plugin.delSetting(hContact, "KeyType");
g_plugin.delSetting(hContact, "KeyMainEmail");
g_plugin.delSetting(hContact, "KeyComment");
- setClistIcon(hContact);
setSrmmIcon(hContact);
}
}
@@ -224,7 +222,6 @@ public:
g_plugin.delSetting(hContact, "KeyType");
g_plugin.delSetting(hContact, "KeyMainEmail");
g_plugin.delSetting(hContact, "KeyComment");
- setClistIcon(hContact);
setSrmmIcon(hContact);
}
@@ -314,15 +311,11 @@ public:
if (hdr->iItem == -1)
return;
- void setClistIcon(MCONTACT hContact);
- void setSrmmIcon(MCONTACT hContact);
-
MCONTACT hContact = list_USERLIST.GetItemData(hdr->iItem);
if (list_USERLIST.GetCheckState(hdr->iItem))
g_plugin.setByte(hContact, "GPGEncryption", 1);
else
g_plugin.setByte(hContact, "GPGEncryption", 0);
- setClistIcon(hContact);
setSrmmIcon(hContact);
}
@@ -904,7 +897,6 @@ public:
if (hcnt) {
g_plugin.setByte(hcnt, "GPGEncryption", !isContactSecured(hcnt));
setSrmmIcon(hContact);
- setClistIcon(hContact);
}
}
}
diff --git a/plugins/New_GPG/src/srmm.cpp b/plugins/New_GPG/src/srmm.cpp
index 89993664b1..3a0e99da26 100755
--- a/plugins/New_GPG/src/srmm.cpp
+++ b/plugins/New_GPG/src/srmm.cpp
@@ -47,7 +47,6 @@ int __cdecl onIconPressed(WPARAM wParam, LPARAM lParam)
if (hMeta)
g_plugin.setByte(hMeta, "GPGEncryption", 0);
setSrmmIcon(hContact);
- setClistIcon(hContact);
}
else if (!enc) {
if (!isContactHaveKey(hContact))
@@ -57,7 +56,6 @@ int __cdecl onIconPressed(WPARAM wParam, LPARAM lParam)
if (hMeta)
g_plugin.setByte(hMeta, "GPGEncryption", 1);
setSrmmIcon(hContact);
- setClistIcon(hContact);
return 0;
}
@@ -66,7 +64,6 @@ int __cdecl onIconPressed(WPARAM wParam, LPARAM lParam)
if (hMeta)
g_plugin.setByte(hMeta, "GPGEncryption", 1);
setSrmmIcon(hContact);
- setClistIcon(hContact);
}
}
return 0;
diff --git a/plugins/New_GPG/src/ui.cpp b/plugins/New_GPG/src/ui.cpp
index cd0960f8b9..afd9c00def 100755
--- a/plugins/New_GPG/src/ui.cpp
+++ b/plugins/New_GPG/src/ui.cpp
@@ -837,10 +837,7 @@ void CDlgNewKey::onClick_IMPORT_AND_USE(CCtrlButton*)
{
ImportKey(hContact, new_key);
g_plugin.setByte(hContact, "GPGEncryption", 1);
- void setSrmmIcon(MCONTACT hContact);
- void setClistIcon(MCONTACT hContact);
setSrmmIcon(hContact);
- setClistIcon(hContact);
this->Close();
}
diff --git a/plugins/New_GPG/src/utilities.cpp b/plugins/New_GPG/src/utilities.cpp
index ed1268c154..3bbcbc2162 100755
--- a/plugins/New_GPG/src/utilities.cpp
+++ b/plugins/New_GPG/src/utilities.cpp
@@ -128,7 +128,7 @@ INT_PTR SendKey(WPARAM w, LPARAM)
msg += keyid;
msg += " sent";
- HistoryLog(hContact, db_event((char*)msg.c_str(), 0, 0, DBEF_SENT));
+ HistoryLog(hContact, msg.c_str(), DBEF_SENT);
g_plugin.setByte(hContact, "GPGEncryption", enc);
}
@@ -155,10 +155,7 @@ INT_PTR ToggleEncryption(WPARAM w, LPARAM)
enc = g_plugin.getByte(hContact, "GPGEncryption", 0);
g_plugin.setByte(hContact, "GPGEncryption", enc ? 0 : 1);
}
- void setSrmmIcon(MCONTACT hContact);
- void setClistIcon(MCONTACT hContact);
setSrmmIcon(hContact);
- setClistIcon(hContact);
Menu_ModifyItem(globals.hToggleEncryption, enc ? LPGENW("Turn off GPG encryption") : LPGENW("Turn on GPG encryption"));
return 0;
@@ -240,7 +237,7 @@ int onProtoAck(WPARAM, LPARAM l)
return 0;
if (!globals.bDecryptFiles)
return 0;
- HistoryLog(ack->hContact, db_event("Received encrypted file, trying to decrypt", 0, 0, 0));
+ HistoryLog(ack->hContact, "Received encrypted file, trying to decrypt");
if (!boost::filesystem::exists(f->szCurrentFile.w))
return 0;
@@ -337,7 +334,7 @@ int onProtoAck(WPARAM, LPARAM l)
if (ack->result == ACKRESULT_FAILED) {
std::list<HANDLE>::iterator it = std::find(sent_msgs.begin(), sent_msgs.end(), ack->hProcess);
if (it != sent_msgs.end())
- HistoryLog(ack->hContact, db_event("Failed to send encrypted message", 0, 0, 0));
+ HistoryLog(ack->hContact, "Failed to send encrypted message");
}
else if (ack->result == ACKRESULT_SUCCESS) {
std::list<HANDLE>::iterator it = std::find(sent_msgs.begin(), sent_msgs.end(), ack->hProcess);
@@ -439,7 +436,7 @@ INT_PTR onSendFile(WPARAM w, LPARAM l)
if (MessageBox(nullptr, TranslateT("Unable to check encryption support on other side.\nRecipient may be unable to decrypt file(s).\nCurrently capability check supported only for ICQ and Jabber protocols.\nIt will work for any other proto if Miranda with New_GPG is used on other side.\nDo you want to encrypt file(s) anyway?"), TranslateT("File transfer warning"), MB_YESNO) == IDNO)
return Proto_ChainSend(w, ccs);
}
- HistoryLog(ccs->hContact, db_event(Translate("encrypting file for transfer"), 0, 0, DBEF_SENT));
+ HistoryLog(ccs->hContact, TranslateU("encrypting file for transfer"), DBEF_SENT);
if (StriStr(ccs->szProtoService, "/sendfilew")) {
wchar_t **file = (wchar_t **)ccs->lParam;
for (int i = 0; file[i]; i++) {
@@ -474,19 +471,15 @@ INT_PTR onSendFile(WPARAM w, LPARAM l)
return Proto_ChainSend(w, ccs);
}
-void HistoryLog(MCONTACT hContact, db_event evt)
+void HistoryLog(MCONTACT hContact, const char *msg, DWORD _time, DWORD flags)
{
- DBEVENTINFO Event = {};
- Event.szModule = MODULENAME;
- Event.eventType = evt.eventType;
- Event.flags = evt.flags;
- if (!evt.timestamp)
- Event.timestamp = (DWORD)time(0);
- else
- Event.timestamp = evt.timestamp;
- Event.cbBlob = (DWORD)mir_strlen((char*)evt.pBlob) + 1;
- Event.pBlob = (PBYTE)_strdup((char*)evt.pBlob);
- db_event_add(hContact, &Event);
+ DBEVENTINFO dbei = {};
+ dbei.szModule = MODULENAME;
+ dbei.flags = DBEF_UTF | flags;
+ dbei.timestamp = (_time) ? _time : (DWORD)time(0);
+ dbei.cbBlob = (DWORD)mir_strlen(msg) + 1;
+ dbei.pBlob = (PBYTE)msg;
+ db_event_add(hContact, &dbei);
}
static int ControlAddStringUtf(HWND ctrl, DWORD msg, const wchar_t *szString)
@@ -949,7 +942,7 @@ void send_encrypted_msgs_thread(void *param)
extern std::list<HANDLE> sent_msgs;
for (list<string>::iterator p = globals.hcontact_data[hContact].msgs_to_send.begin(); p != end; ++p) {
sent_msgs.push_back((HANDLE)ProtoChainSend(hContact, PSS_MESSAGE, 0, (LPARAM)p->c_str()));
- HistoryLog(hContact, db_event((char*)p->c_str(), 0, 0, DBEF_SENT));
+ HistoryLog(hContact, p->c_str(), DBEF_SENT);
Sleep(1000);
}
globals.hcontact_data[hContact].msgs_to_send.clear();
@@ -1228,7 +1221,7 @@ void SendErrorMessage(MCONTACT hContact)
BYTE enc = g_plugin.getByte(hContact, "GPGEncryption", 0);
g_plugin.setByte(hContact, "GPGEncryption", 0);
ProtoChainSend(hContact, PSS_MESSAGE, 0, (LPARAM)"Unable to decrypt PGP encrypted message");
- HistoryLog(hContact, db_event("Error message sent", 0, 0, DBEF_SENT));
+ HistoryLog(hContact, "Error message sent", DBEF_SENT);
g_plugin.setByte(hContact, "GPGEncryption", enc);
}
diff --git a/plugins/New_GPG/src/utilities.h b/plugins/New_GPG/src/utilities.h
index 6761947bc5..61cf53ac30 100755
--- a/plugins/New_GPG/src/utilities.h
+++ b/plugins/New_GPG/src/utilities.h
@@ -22,7 +22,6 @@ wchar_t *GetFilePath(wchar_t *WindowTittle, wchar_t *szExt, wchar_t *szExtDesc,
void GetFolderPath(wchar_t *WindowTittle);
void setSrmmIcon(MCONTACT);
-void setClistIcon(MCONTACT);
void send_encrypted_msgs_thread(void*);
@@ -42,66 +41,7 @@ string toUTF8(wstring str);
wstring toUTF16(string str);
string get_random(int length);
-struct db_event : public DBEVENTINFO
-{
-public:
- db_event(char* msg)
- {
- eventType = EVENTTYPE_MESSAGE;
- flags = 0;
- timestamp = time(0);
- szModule = 0;
- cbBlob = DWORD(mir_strlen(msg)+1);
- pBlob = (PBYTE)msg;
- }
- db_event(char* msg, DWORD time)
- {
- cbBlob = DWORD(mir_strlen(msg)+1);
- pBlob = (PBYTE)msg;
- eventType = EVENTTYPE_MESSAGE;
- flags = 0;
- timestamp = time;
- szModule = 0;
- }
- db_event(char* msg, DWORD time, int type)
- {
- cbBlob = DWORD(mir_strlen(msg)+1);
- pBlob = (PBYTE)msg;
- if(type)
- eventType = type;
- else
- eventType = EVENTTYPE_MESSAGE;
- flags = 0;
- timestamp = time;
- szModule = 0;
- }
- db_event(char* msg, int type)
- {
- cbBlob = DWORD(mir_strlen(msg)+1);
- pBlob = (PBYTE)msg;
- flags = 0;
- if(type)
- eventType = type;
- else
- eventType = EVENTTYPE_MESSAGE;
- timestamp = time(0);
- szModule = 0;
- }
- db_event(char* msg, DWORD time, int type, DWORD _flags)
- {
- cbBlob = DWORD(mir_strlen(msg)+1);
- pBlob = (PBYTE)msg;
- if(type)
- eventType = type;
- else
- eventType = EVENTTYPE_MESSAGE;
- flags = _flags;
- timestamp = time;
- szModule = 0;
- }
-};
-
-void HistoryLog(MCONTACT, db_event);
+void HistoryLog(MCONTACT, const char *msg, DWORD _time = 0, DWORD _flags = 0);
void fix_line_term(std::string &s);
void fix_line_term(std::wstring &s);
void strip_line_term(std::wstring &s);
diff --git a/plugins/New_GPG/src/version.h b/plugins/New_GPG/src/version.h
index 03fdd0965d..c4b91472db 100755
--- a/plugins/New_GPG/src/version.h
+++ b/plugins/New_GPG/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 2
#define __RELEASE_NUM 0
-#define __BUILD_NUM 3
+#define __BUILD_NUM 4
#include <stdver.h>