summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xplugins/New_GPG/src/init.cpp3
-rwxr-xr-xplugins/New_GPG/src/messages.cpp36
-rwxr-xr-xplugins/New_GPG/src/stdafx.h2
-rwxr-xr-xplugins/New_GPG/src/utilities.cpp14
-rwxr-xr-xplugins/New_GPG/src/utilities.h2
5 files changed, 23 insertions, 34 deletions
diff --git a/plugins/New_GPG/src/init.cpp b/plugins/New_GPG/src/init.cpp
index 142603b7fe..0eb491947b 100755
--- a/plugins/New_GPG/src/init.cpp
+++ b/plugins/New_GPG/src/init.cpp
@@ -60,7 +60,8 @@ CMPlugin::CMPlugin() :
bSameAction(MODULENAME, "bSameAction", false),
bAutoExchange(MODULENAME, "bAutoExchange", false),
bFileTransfers(MODULENAME, "bFileTransfers", false),
- bPresenceSigning(MODULENAME, "bPresenceSigning", false)
+ bPresenceSigning(MODULENAME, "bPresenceSigning", false),
+ bSendErrorMessages(MODULENAME, "bSendErrorMessages", false)
{
}
diff --git a/plugins/New_GPG/src/messages.cpp b/plugins/New_GPG/src/messages.cpp
index 1eb4f942eb..cbf7c397b1 100755
--- a/plugins/New_GPG/src/messages.cpp
+++ b/plugins/New_GPG/src/messages.cpp
@@ -155,11 +155,7 @@ static void RecvMsgSvc_func(RecvParams *param)
boost::filesystem::remove(path, e);
}
HistoryLog(hContact, db_event(param->msg, param->timestamp, 0, dbflags));
- 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));
- g_plugin.setByte(hContact, "GPGEncryption", enc);
+ SendErrorMessage(hContact);
delete param;
return;
}
@@ -182,11 +178,7 @@ static void RecvMsgSvc_func(RecvParams *param)
if (globals.debuglog)
globals.debuglog << "info: failed to decrypt messaage from " + szScreenName + " password needed, trying to get one";
if (globals._terminate) {
- 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));
- g_plugin.setByte(hContact, "GPGEncryption", enc);
+ SendErrorMessage(hContact);
break;
}
{ //save inkey id
@@ -216,11 +208,7 @@ static void RecvMsgSvc_func(RecvParams *param)
}
HistoryLog(hContact, db_event(param->msg, param->timestamp, 0, dbflags));
- 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));
- g_plugin.setByte(hContact, "GPGEncryption", enc);
+ SendErrorMessage(hContact);
delete param;
return;
}
@@ -243,11 +231,7 @@ static void RecvMsgSvc_func(RecvParams *param)
}
HistoryLog(hContact, db_event(param->msg, param->timestamp, 0, dbflags));
- 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));
- g_plugin.setByte(hContact, "GPGEncryption", enc);
+ SendErrorMessage(hContact);
delete param;
return;
}
@@ -275,11 +259,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));
- 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));
- g_plugin.setByte(hContact, "GPGEncryption", enc);
+ SendErrorMessage(hContact);
delete param;
return;
}
@@ -315,11 +295,7 @@ static void RecvMsgSvc_func(RecvParams *param)
globals.debuglog << "info: Failed to decrypt GPG encrypted message.";
HistoryLog(hContact, db_event(param->msg, param->timestamp, 0, dbflags));
- 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));
- g_plugin.setByte(hContact, "GPGEncryption", enc);
+ SendErrorMessage(hContact);
delete param;
return;
}
diff --git a/plugins/New_GPG/src/stdafx.h b/plugins/New_GPG/src/stdafx.h
index 9e35ea7e49..79c0a01826 100755
--- a/plugins/New_GPG/src/stdafx.h
+++ b/plugins/New_GPG/src/stdafx.h
@@ -73,7 +73,7 @@ using std::fstream;
struct CMPlugin : public PLUGIN<CMPlugin>
{
- CMOption<bool> bJabberAPI, bPresenceSigning, bFileTransfers, bAutoExchange, bSameAction, bAppendTags, bStripTags, bDebugLog;
+ CMOption<bool> bJabberAPI, bPresenceSigning, bFileTransfers, bAutoExchange, bSameAction, bAppendTags, bStripTags, bDebugLog, bSendErrorMessages;
CMPlugin();
diff --git a/plugins/New_GPG/src/utilities.cpp b/plugins/New_GPG/src/utilities.cpp
index cd1ade4688..ed1268c154 100755
--- a/plugins/New_GPG/src/utilities.cpp
+++ b/plugins/New_GPG/src/utilities.cpp
@@ -474,7 +474,6 @@ INT_PTR onSendFile(WPARAM w, LPARAM l)
return Proto_ChainSend(w, ccs);
}
-
void HistoryLog(MCONTACT hContact, db_event evt)
{
DBEVENTINFO Event = {};
@@ -505,7 +504,6 @@ int ComboBoxAddStringUtf(HWND hCombo, const wchar_t *szString, DWORD data)
return item;
}
-
static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, TiXmlElement *node, void*)
{
TiXmlDocument *pDoc = node->GetDocument();
@@ -1222,6 +1220,18 @@ INT_PTR ImportGpGKeys(WPARAM, LPARAM)
return 0;
}
+void SendErrorMessage(MCONTACT hContact)
+{
+ if (!g_plugin.bSendErrorMessages)
+ return;
+
+ 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));
+ g_plugin.setByte(hContact, "GPGEncryption", enc);
+}
+
void fix_line_term(std::string &s)
{
if (s.empty())
diff --git a/plugins/New_GPG/src/utilities.h b/plugins/New_GPG/src/utilities.h
index 8107076040..6761947bc5 100755
--- a/plugins/New_GPG/src/utilities.h
+++ b/plugins/New_GPG/src/utilities.h
@@ -35,6 +35,8 @@ bool isGPGValid();
void ExportGpGKeysFunc(int type);
void ImportKey(MCONTACT hContact, std::wstring new_key);
+void SendErrorMessage(MCONTACT hContact);
+
const bool StriStr(const char *str, const char *substr);
string toUTF8(wstring str);
wstring toUTF16(string str);