summaryrefslogtreecommitdiff
path: root/plugins/New_GPG/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-01-30 20:49:03 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-01-30 20:49:03 +0300
commite08b24a95a58cfeb390aae331b068b956f62722d (patch)
treee4536b10bdd59393476c7611e71eddee1543a1ac /plugins/New_GPG/src
parent1711817c7eb305f6465f46d0a35acf78ab448357 (diff)
m_icq.h removed
Diffstat (limited to 'plugins/New_GPG/src')
-rwxr-xr-xplugins/New_GPG/src/main.cpp22
-rwxr-xr-xplugins/New_GPG/src/messages.cpp115
-rwxr-xr-xplugins/New_GPG/src/stdafx.h1
-rwxr-xr-xplugins/New_GPG/src/utilities.cpp45
4 files changed, 57 insertions, 126 deletions
diff --git a/plugins/New_GPG/src/main.cpp b/plugins/New_GPG/src/main.cpp
index 13018fd698..218aa936f4 100755
--- a/plugins/New_GPG/src/main.cpp
+++ b/plugins/New_GPG/src/main.cpp
@@ -243,28 +243,6 @@ void InitCheck()
}
mir_free(path);
}
- if (globals.bAutoExchange) {
- ICQ_CUSTOMCAP cap;
- cap.cbSize = sizeof(ICQ_CUSTOMCAP);
- cap.hIcon = nullptr;
- strncpy(cap.name, "GPG Key AutoExchange", MAX_CAPNAME);
- strncpy(cap.caps, "GPGAutoExchange", sizeof(cap.caps));
-
- for (auto &pa : Accounts())
- if (ProtoServiceExists(pa->szProtoName, PS_ICQ_ADDCAPABILITY))
- CallProtoService(pa->szProtoName, PS_ICQ_ADDCAPABILITY, 0, (LPARAM)&cap);
- }
- if (globals.bFileTransfers) {
- ICQ_CUSTOMCAP cap;
- cap.cbSize = sizeof(ICQ_CUSTOMCAP);
- cap.hIcon = nullptr;
- strncpy(cap.name, "GPG Encrypted FileTransfers", MAX_CAPNAME);
- strncpy(cap.caps, "GPGFileTransfer", sizeof(cap.caps));
-
- for (auto &pa : Accounts())
- if (ProtoServiceExists(pa->szProtoName, PS_ICQ_ADDCAPABILITY))
- CallProtoService(pa->szProtoName, PS_ICQ_ADDCAPABILITY, 0, (LPARAM)&cap);
- }
}
void ImportKey(MCONTACT hContact, std::wstring new_key)
diff --git a/plugins/New_GPG/src/messages.cpp b/plugins/New_GPG/src/messages.cpp
index fa5ebc3e63..f512e57b11 100755
--- a/plugins/New_GPG/src/messages.cpp
+++ b/plugins/New_GPG/src/messages.cpp
@@ -557,41 +557,29 @@ INT_PTR RecvMsgSvc(WPARAM w, LPARAM l)
}
else if (!isContactHaveKey(ccs->hContact) && globals.bAutoExchange && globals.gpg_valid && globals.gpg_keyexist) {
char *proto = GetContactProto(ccs->hContact);
- DWORD uin = db_get_dw(ccs->hContact, proto, "UIN", 0);
- if (uin) {
- if (ProtoServiceExists(proto, PS_ICQ_CHECKCAPABILITY)) {
- ICQ_CUSTOMCAP cap = { 0 };
- strncpy(cap.caps, "GPGAutoExchange", sizeof(cap.caps));
- if (CallProtoService(proto, PS_ICQ_CHECKCAPABILITY, (WPARAM)ccs->hContact, (LPARAM)&cap)) {
- ProtoChainSend(ccs->hContact, PSS_MESSAGE, 0, (LPARAM)"-----PGP KEY REQUEST-----");
- return 0;
- }
- }
- }
- else {
- wchar_t *jid = db_get_wsa(ccs->hContact, proto, "jid", L"");
- if (jid[0]) {
- for (auto p : globals.Accounts) {
- wchar_t *caps = p->getJabberInterface()->GetResourceFeatures(jid);
- if (caps) {
- wstring str1;
- for (int i = 0;; i++) {
- str1.push_back(caps[i]);
- if (caps[i] == '\0')
- if (caps[i + 1] == '\0')
- break;
- }
- mir_free(caps);
- if (str1.find(L"GPG_Key_Auto_Exchange:0") != string::npos) {
- ProtoChainSend(ccs->hContact, PSS_MESSAGE, 0, (LPARAM)"-----PGP KEY REQUEST-----");
- return 0;
- }
+ wchar_t *jid = db_get_wsa(ccs->hContact, proto, "jid", L"");
+ if (jid[0]) {
+ for (auto p : globals.Accounts) {
+ wchar_t *caps = p->getJabberInterface()->GetResourceFeatures(jid);
+ if (caps) {
+ wstring str1;
+ for (int i = 0;; i++) {
+ str1.push_back(caps[i]);
+ if (caps[i] == '\0')
+ if (caps[i + 1] == '\0')
+ break;
+ }
+ mir_free(caps);
+ if (str1.find(L"GPG_Key_Auto_Exchange:0") != string::npos) {
+ ProtoChainSend(ccs->hContact, PSS_MESSAGE, 0, (LPARAM)"-----PGP KEY REQUEST-----");
+ return 0;
}
}
}
- mir_free(jid);
}
+ mir_free(jid);
}
+
if (!strstr(msg, "-----BEGIN PGP MESSAGE-----"))
return Proto_ChainRecv(w, ccs);
@@ -857,56 +845,33 @@ int HookSendMsg(WPARAM w, LPARAM l)
globals.debuglog << std::string(time_str() + ": info: checking for autoexchange possibility, name: " + toUTF8(Clist_GetContactDisplayName(hContact)));
LPSTR proto = GetContactProto(hContact);
- DWORD uin = db_get_dw(hContact, proto, "UIN", 0);
- if (uin) {
+ wchar_t *jid = db_get_wsa(hContact, proto, "jid", L"");
+ if (jid[0]) {
if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info(autoexchange): protocol looks like icq, name: " + toUTF8(Clist_GetContactDisplayName(hContact)));
-
- char *proto2 = GetContactProto(hContact);
- if (ProtoServiceExists(proto2, PS_ICQ_CHECKCAPABILITY)) {
- if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info(autoexchange, icq): checking for autoexchange icq capability, name: " + toUTF8(Clist_GetContactDisplayName(hContact)));
- ICQ_CUSTOMCAP cap = { 0 };
- strncpy(cap.caps, "GPGAutoExchange", sizeof(cap.caps));
- if (CallProtoService(proto2, PS_ICQ_CHECKCAPABILITY, hContact, (LPARAM)&cap)) {
- if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info(autoexchange, icq): sending key requiest, name: " + toUTF8(Clist_GetContactDisplayName(hContact)));
- ProtoChainSend(hContact, PSS_MESSAGE, 0, (LPARAM)"-----PGP KEY REQUEST-----");
- globals.hcontact_data[hContact].msgs_to_send.push_back((char*)dbei->pBlob);
- mir_forkthread(send_encrypted_msgs_thread, (void*)hContact);
- return 0;
- }
- }
- }
- else {
- wchar_t *jid = db_get_wsa(hContact, proto, "jid", L"");
- if (jid[0]) {
- if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info(autoexchange): protocol looks like jabber, name: " + toUTF8(Clist_GetContactDisplayName(hContact)));
- for (auto p : globals.Accounts) {
- wchar_t *caps = p->getJabberInterface()->GetResourceFeatures(jid);
- if (caps) {
- wstring str;
- for (int i = 0;; i++) {
- str.push_back(caps[i]);
- if (caps[i] == '\0')
- if (caps[i + 1] == '\0')
- break;
- }
- mir_free(caps);
- if (str.find(L"GPG_Key_Auto_Exchange:0") != string::npos) {
- if (globals.bDebugLog)
- globals.debuglog << std::string(time_str() + ": info(autoexchange, jabber): autoexchange capability found, sending key request, name: " + toUTF8(Clist_GetContactDisplayName(hContact)));
- ProtoChainSend(hContact, PSS_MESSAGE, 0, (LPARAM)"-----PGP KEY REQUEST-----");
- globals.hcontact_data[hContact].msgs_to_send.push_back((char*)dbei->pBlob);
- mir_forkthread(send_encrypted_msgs_thread, (void*)hContact);
- return 0;
- }
+ globals.debuglog << std::string(time_str() + ": info(autoexchange): protocol looks like jabber, name: " + toUTF8(Clist_GetContactDisplayName(hContact)));
+ for (auto p : globals.Accounts) {
+ wchar_t *caps = p->getJabberInterface()->GetResourceFeatures(jid);
+ if (caps) {
+ wstring str;
+ for (int i = 0;; i++) {
+ str.push_back(caps[i]);
+ if (caps[i] == '\0')
+ if (caps[i + 1] == '\0')
+ break;
+ }
+ mir_free(caps);
+ if (str.find(L"GPG_Key_Auto_Exchange:0") != string::npos) {
+ if (globals.bDebugLog)
+ globals.debuglog << std::string(time_str() + ": info(autoexchange, jabber): autoexchange capability found, sending key request, name: " + toUTF8(Clist_GetContactDisplayName(hContact)));
+ ProtoChainSend(hContact, PSS_MESSAGE, 0, (LPARAM)"-----PGP KEY REQUEST-----");
+ globals.hcontact_data[hContact].msgs_to_send.push_back((char*)dbei->pBlob);
+ mir_forkthread(send_encrypted_msgs_thread, (void*)hContact);
+ return 0;
}
}
}
- mir_free(jid);
}
+ mir_free(jid);
}
else return 0;
}
diff --git a/plugins/New_GPG/src/stdafx.h b/plugins/New_GPG/src/stdafx.h
index 9a39ad4ea5..927f2610d0 100755
--- a/plugins/New_GPG/src/stdafx.h
+++ b/plugins/New_GPG/src/stdafx.h
@@ -56,7 +56,6 @@ using std::fstream;
#include <m_langpack.h>
#include <m_skin.h>
#include <m_jabber.h>
-#include <m_icq.h>
#include <m_message.h>
#include <m_clist.h>
#include <m_cluiframes.h>
diff --git a/plugins/New_GPG/src/utilities.cpp b/plugins/New_GPG/src/utilities.cpp
index 5baf42a2e8..1854cb4d4a 100755
--- a/plugins/New_GPG/src/utilities.cpp
+++ b/plugins/New_GPG/src/utilities.cpp
@@ -453,39 +453,28 @@ INT_PTR onSendFile(WPARAM w, LPARAM l)
if (isContactSecured(ccs->hContact)) {
char *proto = GetContactProto(ccs->hContact);
- DWORD uin = db_get_dw(ccs->hContact, proto, "UIN", 0);
bool cap_found = false, supported_proto = false;
- if (uin) {
- if (ProtoServiceExists(proto, PS_ICQ_CHECKCAPABILITY)) {
- supported_proto = true;
- ICQ_CUSTOMCAP cap = { 0 };
- strncpy(cap.caps, "GPGFileTransfer", sizeof(cap.caps));
- if (CallProtoService(proto, PS_ICQ_CHECKCAPABILITY, (WPARAM)ccs->hContact, (LPARAM)&cap))
- cap_found = true;
- }
- }
- else {
- wchar_t *jid = db_get_wsa(ccs->hContact, proto, "jid", L"");
- if (jid[0]) {
- for (auto p : globals.Accounts) {
- wchar_t *caps = p->getJabberInterface()->GetResourceFeatures(jid);
- if (caps) {
- supported_proto = true;
- wstring str;
- for (int i = 0;; i++) {
- str.push_back(caps[i]);
- if (caps[i] == '\0')
- if (caps[i + 1] == '\0')
- break;
- }
- mir_free(caps);
- if (str.find(L"GPG_Encrypted_FileTransfers:0") != string::npos)
- cap_found = true;
+ wchar_t *jid = db_get_wsa(ccs->hContact, proto, "jid", L"");
+ if (jid[0]) {
+ for (auto p : globals.Accounts) {
+ wchar_t *caps = p->getJabberInterface()->GetResourceFeatures(jid);
+ if (caps) {
+ supported_proto = true;
+ wstring str;
+ for (int i = 0;; i++) {
+ str.push_back(caps[i]);
+ if (caps[i] == '\0')
+ if (caps[i + 1] == '\0')
+ break;
}
+ mir_free(caps);
+ if (str.find(L"GPG_Encrypted_FileTransfers:0") != string::npos)
+ cap_found = true;
}
}
- mir_free(jid);
}
+ mir_free(jid);
+
if (supported_proto && !cap_found) {
if (MessageBox(nullptr, TranslateT("Capability to decrypt file not found on other side.\nRecipient may be unable to decrypt file(s).\nDo you want to encrypt file(s) anyway?"), TranslateT("File transfer warning"), MB_YESNO) == IDNO)
return Proto_ChainSend(w, ccs);