diff options
Diffstat (limited to 'utilities.cpp')
-rwxr-xr-x | utilities.cpp | 231 |
1 files changed, 115 insertions, 116 deletions
diff --git a/utilities.cpp b/utilities.cpp index 26354ea..56f7ccb 100755 --- a/utilities.cpp +++ b/utilities.cpp @@ -716,7 +716,7 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void *pU return FALSE; } } - if(nodename) + if(bPrescenseSubscription && nodename) { if(_tcsstr(nodename, _T("status"))) { @@ -1663,121 +1663,120 @@ int ImportGpGKeys(WPARAM w, LPARAM l) break; } if(found) - {
- wstring cmd;
- TCHAR tmp2[MAX_PATH] = {0};
- TCHAR *ptmp;
- string output;
- DWORD exitcode;
- {
- HANDLE hcnt = hContact;
- ptmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", _T(""));
- _tcscpy(tmp2, ptmp);
- mir_free(ptmp);
- _tcscat(tmp2, _T("\\"));
- _tcscat(tmp2, _T("temporary_exported.asc"));
- DeleteFile(tmp2);
- wfstream f(tmp2, std::ios::out);
- f<<toUTF16(key).c_str();
- f.close();
- cmd += _T(" --batch ");
- cmd += _T(" --import \"");
- cmd += tmp2;
- cmd += _T("\"");
- }
- gpg_execution_params params;
- pxResult result;
- params.cmd = &cmd;
- params.useless = "";
- params.out = &output;
- params.code = &exitcode;
- params.result = &result;
- boost::thread gpg_thread(boost::bind(&pxEexcute_thread, ¶ms));
- if(!gpg_thread.timed_join(boost::posix_time::seconds(10)))
- {
- gpg_thread.~thread();
- TerminateProcess(params.hProcess, 1);
- params.hProcess = NULL;
- debuglog<<time_str()<<": GPG execution timed out, aborted\n";
- break;
- }
- if(result == pxNotFound)
- break;
- if(result == pxSuccess)
- processed_keys++;
- {
- TCHAR *tmp;
- if(output.find("already in secret keyring") != string::npos)
- {
- MessageBox(0, _T("Key already in scret key ring."), _T("Info"), MB_OK);
- DeleteFile(tmp2);
- break;
- }
- char *tmp2;
- string::size_type s = output.find("gpg: key ") + strlen("gpg: key ");
- string::size_type s2 = output.find(":", s);
- tmp2 = new char [output.substr(s,s2-s).length()+1];
- strcpy(tmp2, output.substr(s,s2-s).c_str());
- mir_utf8decode(tmp2, 0);
- DBWriteContactSettingString(hContact, szGPGModuleName, "KeyID", tmp2);
- mir_free(tmp2);
- s = output.find("“", s2);
- if(s == string::npos)
- {
- s = output.find("\"", s2);
- s += 1;
- }
- else
- s += 3;
- if((s2 = output.find("(", s)) == string::npos)
- s2 = output.find("<", s);
- else if(s2 > output.find("<", s))
- s2 = output.find("<", s);
- if(s2 != string::npos)
- {
- tmp2 = new char [output.substr(s,s2-s-1).length()+1];
- strcpy(tmp2, output.substr(s,s2-s-1).c_str());
- mir_utf8decode(tmp2, 0);
- if(hContact)
- {
- DBWriteContactSettingString(hContact, szGPGModuleName, "KeyMainName", output.substr(s,s2-s-1).c_str());
- }
- mir_free(tmp2);
- if((s = output.find(")", s2)) == string::npos)
- s = output.find(">", s2);
- else if(s > output.find(">", s2))
- s = output.find(">", s2);
- s2++;
- if(output[s] == ')')
- {
- tmp2 = new char [output.substr(s2,s-s2).length()+1];
- strcpy(tmp2, output.substr(s2,s-s2).c_str());
- mir_utf8decode(tmp2, 0);
- if(hContact)
- DBWriteContactSettingString(hContact, szGPGModuleName, "KeyComment", output.substr(s2,s-s2).c_str());
- mir_free(tmp2);
- s+=3;
- s2 = output.find(">", s);
- tmp2 = new char [output.substr(s,s2-s).length()+1];
- strcpy(tmp2, output.substr(s,s2-s).c_str());
- mir_utf8decode(tmp2, 0);
- if(hContact)
- DBWriteContactSettingString(hContact, szGPGModuleName, "KeyMainEmail", output.substr(s,s2-s).c_str());
- mir_free(tmp2);
- }
- else
- {
- tmp2 = new char [output.substr(s2,s-s2).length()+1];
- strcpy(tmp2, output.substr(s2,s-s2).c_str());
- mir_utf8decode(tmp2, 0);
- if(hContact)
- DBWriteContactSettingString(hContact, szGPGModuleName, "KeyMainEmail", output.substr(s2,s-s2).c_str());
- mir_free(tmp2);
- }
- }
- DBWriteContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", 1);
- DBWriteContactSettingTString(hContact, szGPGModuleName, "GPGPubKey", toUTF16(key).c_str());
- }
+ { + wstring cmd; + TCHAR tmp2[MAX_PATH] = {0}; + TCHAR *ptmp; + string output; + DWORD exitcode; + { + HANDLE hcnt = hContact; + ptmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", _T("")); + _tcscpy(tmp2, ptmp); + mir_free(ptmp); + _tcscat(tmp2, _T("\\")); + _tcscat(tmp2, _T("temporary_exported.asc")); + DeleteFile(tmp2); + wfstream f(tmp2, std::ios::out); + f<<toUTF16(key).c_str(); + f.close(); + cmd += _T(" --batch "); + cmd += _T(" --import \""); + cmd += tmp2; + cmd += _T("\""); + } + gpg_execution_params params; + pxResult result; + params.cmd = &cmd; + params.useless = ""; + params.out = &output; + params.code = &exitcode; + params.result = &result; + boost::thread gpg_thread(boost::bind(&pxEexcute_thread, ¶ms)); + if(!gpg_thread.timed_join(boost::posix_time::seconds(10))) + { + gpg_thread.~thread(); + TerminateProcess(params.hProcess, 1); + params.hProcess = NULL; + debuglog<<time_str()<<": GPG execution timed out, aborted\n"; + break; + } + if(result == pxNotFound) + break; + if(result == pxSuccess) + processed_keys++; + { + if(output.find("already in secret keyring") != string::npos) + { + MessageBox(0, _T("Key already in scret key ring."), _T("Info"), MB_OK); + DeleteFile(tmp2); + break; + } + char *tmp2; + string::size_type s = output.find("gpg: key ") + strlen("gpg: key "); + string::size_type s2 = output.find(":", s); + tmp2 = new char [output.substr(s,s2-s).length()+1]; + strcpy(tmp2, output.substr(s,s2-s).c_str()); + mir_utf8decode(tmp2, 0); + DBWriteContactSettingString(hContact, szGPGModuleName, "KeyID", tmp2); + mir_free(tmp2); + s = output.find("“", s2); + if(s == string::npos) + { + s = output.find("\"", s2); + s += 1; + } + else + s += 3; + if((s2 = output.find("(", s)) == string::npos) + s2 = output.find("<", s); + else if(s2 > output.find("<", s)) + s2 = output.find("<", s); + if(s2 != string::npos) + { + tmp2 = new char [output.substr(s,s2-s-1).length()+1]; + strcpy(tmp2, output.substr(s,s2-s-1).c_str()); + mir_utf8decode(tmp2, 0); + if(hContact) + { + DBWriteContactSettingString(hContact, szGPGModuleName, "KeyMainName", output.substr(s,s2-s-1).c_str()); + } + mir_free(tmp2); + if((s = output.find(")", s2)) == string::npos) + s = output.find(">", s2); + else if(s > output.find(">", s2)) + s = output.find(">", s2); + s2++; + if(output[s] == ')') + { + tmp2 = new char [output.substr(s2,s-s2).length()+1]; + strcpy(tmp2, output.substr(s2,s-s2).c_str()); + mir_utf8decode(tmp2, 0); + if(hContact) + DBWriteContactSettingString(hContact, szGPGModuleName, "KeyComment", output.substr(s2,s-s2).c_str()); + mir_free(tmp2); + s+=3; + s2 = output.find(">", s); + tmp2 = new char [output.substr(s,s2-s).length()+1]; + strcpy(tmp2, output.substr(s,s2-s).c_str()); + mir_utf8decode(tmp2, 0); + if(hContact) + DBWriteContactSettingString(hContact, szGPGModuleName, "KeyMainEmail", output.substr(s,s2-s).c_str()); + mir_free(tmp2); + } + else + { + tmp2 = new char [output.substr(s2,s-s2).length()+1]; + strcpy(tmp2, output.substr(s2,s-s2).c_str()); + mir_utf8decode(tmp2, 0); + if(hContact) + DBWriteContactSettingString(hContact, szGPGModuleName, "KeyMainEmail", output.substr(s2,s-s2).c_str()); + mir_free(tmp2); + } + } + DBWriteContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", 1); + DBWriteContactSettingTString(hContact, szGPGModuleName, "GPGPubKey", toUTF16(key).c_str()); + } DeleteFile(tmp2); break; } |