summaryrefslogtreecommitdiff
path: root/utilities.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'utilities.cpp')
-rw-r--r--utilities.cpp34
1 files changed, 29 insertions, 5 deletions
diff --git a/utilities.cpp b/utilities.cpp
index 03cb2c4..5f1ad0a 100644
--- a/utilities.cpp
+++ b/utilities.cpp
@@ -45,7 +45,8 @@ char* __stdcall UniGetContactSettingUtf(HANDLE hContact, const char *szModule,co
char *date()
{
- static char d[11];
+ setlocale( LC_ALL, "C" );
+ static char d[11];
char *tmp = __DATE__, m[4], mn[3] = "01";
m[0]=tmp[0];
m[1]=tmp[1];
@@ -402,6 +403,9 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void *pU
wstring path_out = path_c;
mir_free(path_c);
path_out += _T("\\prescense_text");
+ {
+ DeleteFile(path_out.c_str());
+ }
wfstream f(path_out.c_str(), std::ios::out);
char *tmp = mir_utf8encodeW(str);
f<<tmp;
@@ -413,20 +417,40 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void *pU
DWORD code;
wstring cmd;
{
- TCHAR *tmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "szKeyPassword", _T(""));
- if(_tcslen(tmp) > 0)
+ char *inkeyid = UniGetContactSettingUtf(NULL, szGPGModuleName, "KeyID", "");
+ TCHAR *pass = NULL;
+ if(strlen(inkeyid) > 0)
+ {
+ string dbsetting = "szKey_";
+ dbsetting += inkeyid;
+ dbsetting += "_Password";
+ pass = UniGetContactSettingUtf(NULL, szGPGModuleName, dbsetting.c_str(), _T(""));
+ if(_tcslen(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)
+ debuglog<<"info: found password for all keys in database, trying to encrypt message from self with password\n";
+ }
+ if(_tcslen(pass) > 0)
{
cmd += _T("--passphrase \"");
- cmd += tmp;
+ cmd += pass;
cmd += _T("\" ");
}
else if(password)
{
+ debuglog<<"info: found password in memory, trying to encrypt message from self with password\n";
cmd += _T("--passphrase \"");
cmd += password;
cmd += _T("\" ");
}
- mir_free(tmp);
+ else
+ debuglog<<"info: passwords not found in database or memory, trying to encrypt message from self with out password\n";
+ mir_free(pass);
+ mir_free(inkeyid);
}
cmd += _T("--default-key ");
path_c = UniGetContactSettingUtf(NULL, szGPGModuleName, "KeyID", _T(""));