diff options
author | Gluzskiy Alexandr <sss123next@list.ru> | 2010-10-12 22:51:38 +0300 |
---|---|---|
committer | Gluzskiy Alexandr <sss123next@list.ru> | 2010-10-12 22:51:38 +0300 |
commit | a8e58dc8f24d10dd4de16f19ace4740350d9b9cc (patch) | |
tree | b4dca0da2531767389d7edfed789387756c79da7 | |
parent | 62bc0ff49501348702f7e20ce2fe6524842390e3 (diff) |
fixed crash on filetransfers, fixed password saving
-rw-r--r-- | commonheaders.h | 2 | ||||
-rw-r--r-- | main.cpp | 13 | ||||
-rw-r--r-- | utilities.cpp | 18 |
3 files changed, 20 insertions, 13 deletions
diff --git a/commonheaders.h b/commonheaders.h index f3a16f7..1faf221 100644 --- a/commonheaders.h +++ b/commonheaders.h @@ -44,7 +44,7 @@ using std::fstream; //boost #include <boost/thread/thread.hpp> #include <boost/thread/mutex.hpp> -#include <boost/lexical_cast.hpp> +//#include <boost/lexical_cast.hpp> //miranda #include <newpluginapi.h> @@ -206,10 +206,15 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM DBWriteContactSettingTString(NULL, szGPGModuleName, "KeyID", fp); TCHAR passwd[64]; GetDlgItemText(hwndDlg, IDC_KEY_PASSWORD, passwd, 64); - if(_tcslen(passwd) > 0) - DBWriteContactSettingTString(NULL, szGPGModuleName, "szKeyPassword", passwd); - else - DBDeleteContactSetting(NULL, szGPGModuleName, "szKeyPassword"); + if(passwd[0]) + { + string dbsetting = "szKey_"; + char *keyid = mir_t2a(fp); + dbsetting += keyid; + mir_free(keyid); + dbsetting += "_Password"; + DBWriteContactSettingTString(NULL, szGPGModuleName, dbsetting.c_str(), passwd); + } DBWriteContactSettingByte(NULL, szGPGModuleName, "FirstRun", 0); { wstring keyinfo = _T("Current private key id: "); diff --git a/utilities.cpp b/utilities.cpp index b182f1f..70d59b9 100644 --- a/utilities.cpp +++ b/utilities.cpp @@ -295,7 +295,7 @@ int onProtoAck(WPARAM w, LPARAM l) case ACKRESULT_DENIED: case ACKRESULT_FAILED:
{
TCHAR *temp = _wgetenv(_T("TEMP"));
- if(_tcsstr(f->tszCurrentFile, temp))
+ if(f->tszCurrentFile && _tcsstr(f->tszCurrentFile, temp))
{
if(!transfers.empty())
{
@@ -311,7 +311,7 @@ int onProtoAck(WPARAM w, LPARAM l) case ACKRESULT_SUCCESS:
{
TCHAR *temp = _wgetenv(_T("TEMP"));
- if(_tcsstr(f->tszCurrentFile, temp))
+ if(f->tszCurrentFile && _tcsstr(f->tszCurrentFile, temp))
{
if(!transfers.empty())
{
@@ -322,7 +322,7 @@ int onProtoAck(WPARAM w, LPARAM l) }
return 0;
}
- else if(_tcsstr(f->tszCurrentFile, _T(".gpg"))) //decrypt it
+ else if(f->tszCurrentFile && _tcsstr(f->tszCurrentFile, _T(".gpg"))) //decrypt it
{ //process encrypted file
if(_waccess(f->tszCurrentFile, 0) == -1) { @@ -392,7 +392,9 @@ int onSendFile(WPARAM w, LPARAM l) pxResult result; char *keyid = UniGetContactSettingUtf(ccs->hContact, szGPGModuleName, "KeyID", ""); wstring cmd = _T("-r "); - cmd += boost::lexical_cast<std::wstring>(keyid); + TCHAR *szKeyid = mir_a2t(keyid); + cmd += szKeyid; + mir_free(szKeyid); mir_free(keyid); cmd += _T(" -o \""); TCHAR *temp = _wgetenv(_T("TEMP")); @@ -588,22 +590,22 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void *pU { char *inkeyid = UniGetContactSettingUtf(NULL, szGPGModuleName, "KeyID", ""); TCHAR *pass = NULL; - if(strlen(inkeyid) > 0) + if(inkeyid[0]) { string dbsetting = "szKey_"; dbsetting += inkeyid; dbsetting += "_Password"; pass = UniGetContactSettingUtf(NULL, szGPGModuleName, dbsetting.c_str(), _T("")); - if(_tcslen(pass) > 0) + if(pass[0]) debuglog<<"info: found password in database for key id: "<<inkeyid<<", trying to encrypt message from self with password\n"; } else { pass = UniGetContactSettingUtf(NULL, szGPGModuleName, "szKeyPassword", _T("")); - if(_tcslen(pass) > 0) + if(pass[0]) debuglog<<"info: found password for all keys in database, trying to encrypt message from self with password\n"; } - if(_tcslen(pass) > 0) + if(pass[0]) { cmd += _T("--passphrase \""); cmd += pass; |