diff options
author | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2013-01-25 01:17:50 +0200 |
---|---|---|
committer | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2013-01-25 01:17:50 +0200 |
commit | d1eec37b0ba6af269da5218edbdd1a74d8c0983b (patch) | |
tree | 3a6b078ec7cb1876b3defb6a07368f7213c8af8e /utilities.cpp | |
parent | 2f19853406b588d59a86f2b5974131185c74fd8f (diff) |
merged with miranda_ng main repo
implemented #64
Diffstat (limited to 'utilities.cpp')
-rwxr-xr-x | utilities.cpp | 62 |
1 files changed, 61 insertions, 1 deletions
diff --git a/utilities.cpp b/utilities.cpp index 15ea6dc..0a996e1 100755 --- a/utilities.cpp +++ b/utilities.cpp @@ -630,6 +630,61 @@ int onSendFile(WPARAM w, LPARAM l) CCSDATA *ccs=(CCSDATA*)l;
if(isContactSecured(ccs->hContact))
{
+ LPSTR proto = (LPSTR)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+ DWORD uin = DBGetContactSettingDword(ccs->hContact, proto, "UIN", 0); + bool cap_found = false, supported_proto = false; + if(uin) + { + char svc[64]; + strcpy(svc, proto); + strcat(svc, PS_ICQ_CHECKCAPABILITY); + if(ServiceExists(svc)) + { + supported_proto = true; + ICQ_CUSTOMCAP cap = {0}; + strcpy(cap.caps, "GPG FileTransfer"); + if(CallService(svc, (WPARAM)ccs->hContact, (LPARAM)&cap)) + cap_found = true; + } + } + else + { + TCHAR *jid = UniGetContactSettingUtf(ccs->hContact, proto, "jid", _T("")); + if(jid[0]) + { + extern list <JabberAccount*> Accounts; + list<JabberAccount*>::iterator end = Accounts.end(); + for(list<JabberAccount*>::iterator p = Accounts.begin(); p != end; p++) + { + TCHAR *caps = (*p)->getJabberInterface()->Net()->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(_T("GPG_Encrypted_FileTransfers:0")) != string::npos) + cap_found = true; + } + } + } + } + if(supported_proto && !cap_found) + { + if(MessageBox(0, 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("Filetransfer warning"), MB_YESNO) == IDNO) + return CallService(MS_PROTO_CHAINSEND, w, l); + } + if(!supported_proto) + { + if(MessageBox(0, 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 used on other side.\nDo you want to encrypt file(s) anyway?"), TranslateT("Filetransfer warning"), MB_YESNO) == IDNO) + return CallService(MS_PROTO_CHAINSEND, w, l); + } HistoryLog(ccs->hContact, db_event(Translate("encrypting file for transfer"), 0, 0, DBEF_SENT));
DWORD flags = (DWORD)ccs->wParam; //check for PFTS_UNICODE here
int i;
@@ -1140,9 +1195,14 @@ void AddHandlers() // (*p)->setMessageHandler((*p)->getJabberInterface()->Net()->AddMessageHandler((JABBER_HANDLER_FUNC)MessageHandler, JABBER_MESSAGE_TYPE_ANY ,NULL,NULL));
if(bAutoExchange)
{
- (*p)->getJabberInterface()->Net()->RegisterFeature(_T("GPG_Key_Auto_Exchange:0"), _T("Indicates that gpg installed and configured to public key auto exchange (currently implemented in new_gpg Miranda IM plugin)"));
+ (*p)->getJabberInterface()->Net()->RegisterFeature(_T("GPG_Key_Auto_Exchange:0"), _T("Indicates that gpg installed and configured to public key auto exchange (currently implemented in new_gpg plugin for Miranda IM and Miranda NG)"));
(*p)->getJabberInterface()->Net()->AddFeatures(_T("GPG_Key_Auto_Exchange:0\0\0"));
}
+ if(bFileTransfers)
+ {
+ (*p)->getJabberInterface()->Net()->RegisterFeature(_T("GPG_Encrypted_FileTransfers:0"), _T("Indicates that gpg installed and configured to encrypt files (currently implemented in new_gpg plugin for Miranda IM and Miranda NG)"));
+ (*p)->getJabberInterface()->Net()->AddFeatures(_T("GPG_Encrypted_FileTransfers:0\0\0"));
+ }
}
}
|