summaryrefslogtreecommitdiff
path: root/plugins/New_GPG/src/utilities.cpp
diff options
context:
space:
mode:
authorAlexander Gluzsky <sss123next@list.ru>2013-03-02 19:39:56 +0000
committerAlexander Gluzsky <sss123next@list.ru>2013-03-02 19:39:56 +0000
commit260ec979bf45846e404d6c1ba4792894f34ec521 (patch)
tree54ea12de752ab72cc4e428f64ff39f692fe984fe /plugins/New_GPG/src/utilities.cpp
parent55f3f8ff12e1a7388706b8ccdae139ca946742dc (diff)
modified: plugins/New_GPG/src/gpg_wrapper.cpp
modified: plugins/New_GPG/src/utilities.cpp git-svn-id: http://svn.miranda-ng.org/main/trunk@3853 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/New_GPG/src/utilities.cpp')
-rwxr-xr-xplugins/New_GPG/src/utilities.cpp152
1 files changed, 81 insertions, 71 deletions
diff --git a/plugins/New_GPG/src/utilities.cpp b/plugins/New_GPG/src/utilities.cpp
index b6e7cc8fc4..c0ef7ab162 100755
--- a/plugins/New_GPG/src/utilities.cpp
+++ b/plugins/New_GPG/src/utilities.cpp
@@ -541,60 +541,60 @@ int onSendFile(WPARAM w, LPARAM l)
if(isContactSecured(ccs->hContact))
{
char *proto = GetContactProto(ccs->hContact);
- 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);
- }
+ 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;
@@ -1925,28 +1925,38 @@ INT_PTR ImportGpGKeys(WPARAM w, LPARAM l)
void fix_line_term(std::string &s)
{
+ if(s.empty())
+ return;
boost::algorithm::erase_all(s, "\r\r");
}
void fix_line_term(std::wstring &s)
{
+ if(s.empty())
+ return;
boost::algorithm::erase_all(s, _T("\r\r"));
}
void strip_line_term(std::wstring &s)
{
+ if(s.empty())
+ return;
boost::algorithm::erase_all(s, _T("\r"));
boost::algorithm::erase_all(s, _T("\n"));
}
void strip_line_term(std::string &s)
{
+ if(s.empty())
+ return;
boost::algorithm::erase_all(s, "\r");
boost::algorithm::erase_all(s, "\n");
}
void strip_tags(std::wstring &str)
{
+ if(str.empty())
+ return;
boost::algorithm::erase_all(str, inopentag);
boost::algorithm::erase_all(str, inclosetag);
boost::algorithm::erase_all(str, outopentag);
@@ -2118,17 +2128,17 @@ static INT_PTR CALLBACK DlgProcChangePasswd(HWND hwndDlg, UINT msg, WPARAM wPara
old_pass_match = true;
mir_free(pass);
if(!old_pass_match)
- {
- if(key_id_global[0])
- {
- string dbsetting = "szKey_";
- dbsetting += toUTF8(key_id_global);
- dbsetting += "_Password";
- pass = UniGetContactSettingUtf(NULL, szGPGModuleName, dbsetting.c_str(), _T(""));
- if(!_tcscmp(pass,buf))
- old_pass_match = true;
- mir_free(pass);
- }
+ {
+ if(key_id_global[0])
+ {
+ string dbsetting = "szKey_";
+ dbsetting += toUTF8(key_id_global);
+ dbsetting += "_Password";
+ pass = UniGetContactSettingUtf(NULL, szGPGModuleName, dbsetting.c_str(), _T(""));
+ if(!_tcscmp(pass,buf))
+ old_pass_match = true;
+ mir_free(pass);
+ }
}
if(!old_pass_match)
{
@@ -2205,12 +2215,12 @@ void ShowChangePasswdDlg()
void clean_temp_dir()
{
- using namespace boost::filesystem;
- char *mir_path = new char [MAX_PATH];
- PathToAbsolute("\\", mir_path);
- wstring path = toUTF16(mir_path);
- SetCurrentDirectoryA(mir_path);
- delete [] mir_path;
+ using namespace boost::filesystem;
+ char *mir_path = new char [MAX_PATH];
+ PathToAbsolute("\\", mir_path);
+ wstring path = toUTF16(mir_path);
+ SetCurrentDirectoryA(mir_path);
+ delete [] mir_path;
TCHAR *tmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", _T(""));
path += tmp;
mir_free(tmp);