summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGluzskiy Alexandr <sss@sss.chaoslab.ru>2013-01-25 01:17:50 +0200
committerGluzskiy Alexandr <sss@sss.chaoslab.ru>2013-01-25 01:17:50 +0200
commitd1eec37b0ba6af269da5218edbdd1a74d8c0983b (patch)
tree3a6b078ec7cb1876b3defb6a07368f7213c8af8e
parent2f19853406b588d59a86f2b5974131185c74fd8f (diff)
merged with miranda_ng main repo
implemented #64
-rwxr-xr-xinit.cpp4
-rwxr-xr-xmain.cpp20
-rwxr-xr-xutilities.cpp62
3 files changed, 83 insertions, 3 deletions
diff --git a/init.cpp b/init.cpp
index 391167e..2840ecf 100755
--- a/init.cpp
+++ b/init.cpp
@@ -164,7 +164,7 @@ extern "C" int __declspec(dllexport) Load(PLUGINLINK *link)
mi.position=-0x7FFFFFFF;
mi.flags=0;
mi.hIcon=LoadSkinnedIcon(SKINICON_OTHER_MIRANDA);
- mi.pszName="Export GPG Public keys from all users";
+ mi.pszName="Export GPG Public keys";
mi.pszService="/ExportGPGKeys";
hExportGpgKeys = (HANDLE)CallService(MS_CLIST_ADDMAINMENUITEM,0,(LPARAM)&mi);
ZeroMemory(&mi,sizeof(mi));
@@ -172,7 +172,7 @@ extern "C" int __declspec(dllexport) Load(PLUGINLINK *link)
mi.position=-0x7FFFFFFF;
mi.flags=0;
mi.hIcon=LoadSkinnedIcon(SKINICON_OTHER_MIRANDA);
- mi.pszName="Import GPG Public keys from all users";
+ mi.pszName="Import GPG Public keys";
mi.pszService="/ImportGPGKeys";
hImportGpgKeys = (HANDLE)CallService(MS_CLIST_ADDMAINMENUITEM,0,(LPARAM)&mi);
diff --git a/main.cpp b/main.cpp
index 8da4c08..87edd03 100755
--- a/main.cpp
+++ b/main.cpp
@@ -2304,6 +2304,26 @@ void InitCheck()
CallService(svc, 0, (LPARAM)&cap);
}
}
+ if(bFileTransfers)
+ {
+ int count = 0;
+ PROTOACCOUNT **accounts;
+ ProtoEnumAccounts(&count, &accounts);
+ ICQ_CUSTOMCAP cap;
+ cap.cbSize = sizeof(ICQ_CUSTOMCAP);
+ cap.hIcon = 0;
+ strcpy(cap.name, "GPG Encrypted FileTransfers");
+ strcpy(cap.caps, "GPG FileTransfer");
+
+ for(int i = 0; i < count; i++)
+ {
+ char svc[64];
+ strcpy(svc, accounts[i]->szProtoName);
+ strcat(svc, PS_ICQ_ADDCAPABILITY);
+ if(ServiceExists(svc))
+ CallService(svc, 0, (LPARAM)&cap);
+ }
+ }
}
void ImportKey()
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"));
+ }
}
}