diff options
-rw-r--r-- | main.cpp | 22 | ||||
-rw-r--r-- | messages.cpp | 54 | ||||
-rw-r--r-- | options.cpp | 6 | ||||
-rw-r--r-- | utilities.cpp | 7 | ||||
-rw-r--r-- | utilities.h | 2 |
5 files changed, 82 insertions, 9 deletions
@@ -25,19 +25,22 @@ void test() DWORD code;
TCHAR cmd[512];
_tcscpy(cmd, _T("--list-secret-keys"));
- pxExecute(cmd, "", &out, &code);
+// pxExecute(cmd, "", &out, &code);
// MessageBoxA(0, out.c_str(), "test", MB_OK);
}
HWND hwndFirstRun = NULL;
+int itemnum = 0;
+
static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam)
{
HWND hwndList=GetDlgItem(hwndDlg, IDC_KEY_LIST);
LVCOLUMN col = {0};
LVITEM item = {0};
NMLISTVIEW * hdr = (NMLISTVIEW *) lParam;
+ TCHAR fp[16] = {0};
switch (msg)
{
case WM_INITDIALOG:
@@ -143,6 +146,16 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM switch (LOWORD(wParam))
{
case ID_OK:
+ ListView_GetItemText(hwndList, itemnum, 0, fp, 16);
+ {
+ string out;
+ DWORD code;
+ TCHAR cmd[64];
+ _tcscpy(cmd, _T("--export -a "));
+ _tcscat(cmd, fp);
+ pxExecute(cmd, "", &out, &code);
+ DBWriteContactSettingString(NULL, szModuleName, "GPGPubKey", out.c_str());
+ }
DestroyWindow(hwndDlg);
break;
}
@@ -151,6 +164,13 @@ static BOOL CALLBACK DlgProcFirstRun(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM case WM_NOTIFY:
{
+ if(hdr && IsWindowVisible(hdr->hdr.hwndFrom) && hdr->iItem != (-1))
+ {
+ if(hdr->hdr.code == LVN_ITEMCHANGED)
+ {
+ itemnum = hdr->iItem;
+ }
+ }
switch (((LPNMHDR)lParam)->code)
{
diff --git a/messages.cpp b/messages.cpp index c4a890d..2b81167 100644 --- a/messages.cpp +++ b/messages.cpp @@ -37,12 +37,18 @@ int RecvMsgSvc(WPARAM w, LPARAM l) if(((s2 = str.find(_T("-----END PGP PUBLIC KEY BLOCK-----"))) != wstring::npos) && ((s1 = str.find(_T("-----BEGIN PGP PUBLIC KEY BLOCK-----"))) != wstring::npos))
{ //this is public key
+ if(!DBGetContactSettingByte(ccs->hContact, szModuleName, "GPGEncryption", 0))
+ ;//
}
else if(((s2 = str.find(_T("-/ENCRYPTED-"))) != wstring::npos) && ((s1 = str.find(_T("-ENCRYPTED-"))) != wstring::npos))
{ //this is generic encrypted data block
+ if(!DBGetContactSettingByte(ccs->hContact, szModuleName, "GPGEncryption", 0))
+ ;//
}
else if(((s1 = str.find(_T("<body>This message is encrypted.</body>"))) != wstring::npos))
{ //this is jabber encrypted data
+ if(!DBGetContactSettingByte(ccs->hContact, szModuleName, "GPGEncryption", 0))
+ ;//
}
char *utf = mir_utf8encodeW(str.c_str()); //for later usage
@@ -69,11 +75,55 @@ int SendMsgSvc(WPARAM w, LPARAM l) { //encrypt data here
wchar_t *tmp = mir_utf8decodeW(msg);
wstring str = tmp;
+ MessageBox(0, str.c_str(), _T(""), MB_OK);
mir_free(tmp);
wstring::size_type s1, s2;
+ { //not xmpp
+ string out;
+ DWORD code;
+ TCHAR cmd[128];
+ wstring path;
+ char *tmp = UniGetContactSettingUtf(ccs->hContact, szModuleName, "KeyFingerprint", "");
+ if(strlen(tmp) < 2)
+ {
+ mir_free(tmp);
+ return CallService(MS_PROTO_CHAINSEND, w, l);
+ }
+ _tcscpy(cmd, _T("--batch --yes -e -a -r "));
+ TCHAR *tmp2 = mir_a2t(tmp);
+ mir_free(tmp);
+ _tcscat(cmd, tmp2);
+ mir_free(tmp2);
+ _tcscat(cmd, _T("\""));
+ tmp2 = UniGetContactSettingUtf(NULL, szModuleName, "szHomePath", _T(""));
+ path.append(tmp2);
+ _tcscat(cmd, tmp2);
+ mir_free(tmp2);
+ _tcscat(cmd, _T("\\exported_data"));
+ path.append(_T("\\exported_data"));
+ _tcscat(cmd, _T("\""));
+ {
+ wfstream f(path.c_str(), std::ios_base::in);
+ f<<str;
+ f.close();
+ }
+ pxExecute(cmd, "", &out, &code);
+ DeleteFile(path.c_str());
+ path.append(_T(".asc"));
+ wfstream f(path.c_str(), std::ios_base::out);
+ str.clear();
+ while(!f.eof())
+ {
+ TCHAR tmp[128];
+ f.getline(tmp, 128);
+ str.append(tmp);
+ }
+ mir_free((void**)ccs->lParam);
+ char *utf = mir_utf8encodeW(str.c_str()); //for later usage
+ ccs->hContact = utf;
+ }
- char *utf = mir_utf8encodeW(str.c_str()); //for later usage
- mir_free(utf);
+
}
return CallService(MS_PROTO_CHAINSEND, w, l);
diff --git a/options.cpp b/options.cpp index 2afed94..4f2dbce 100644 --- a/options.cpp +++ b/options.cpp @@ -112,7 +112,7 @@ static BOOL CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA tmp = UniGetContactSettingUtf(hContact, szModuleName, "GPGPubKey", _T("not set"));
ListView_SetItemText(hwndList, iRow, 2, (_tcslen(tmp) > 1)?tmp:_T("not set"));
mir_free(tmp);
- tmp2 = GetContactSettingStringA(hContact, szModuleName, "KeyFingerprint", "");
+ tmp2 = UniGetContactSettingUtf(hContact, szModuleName, "KeyFingerprint", "");
tmp = mir_a2t(tmp2);
mir_free(tmp2);
ListView_SetItemText(hwndList, iRow, 1, (_tcslen(tmp) > 1)?tmp:_T("not set"));
@@ -144,12 +144,12 @@ static BOOL CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA TCHAR *ptmp;
char *tmp;
bool keep = false;
- tmp = GetContactSettingStringA(user_data[item_num+1], szModuleName, "KeyFingerprint", "");
+ tmp = UniGetContactSettingUtf(user_data[item_num+1], szModuleName, "KeyFingerprint", "");
for(HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); hContact != NULL; hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0))
{
if(hContact != user_data[item_num+1])
{
- char *tmp2 = GetContactSettingStringA(hContact, szModuleName, "KeyFingerprint", "");
+ char *tmp2 = UniGetContactSettingUtf(hContact, szModuleName, "KeyFingerprint", "");
if(!strcmp(tmp, tmp2))
{
mir_free(tmp2);
diff --git a/utilities.cpp b/utilities.cpp index 8fba235..8001d97 100644 --- a/utilities.cpp +++ b/utilities.cpp @@ -30,7 +30,7 @@ TCHAR* __stdcall UniGetContactSettingUtf(HANDLE hContact, const char *szModule,c return szRes;
}
-char* __stdcall GetContactSettingStringA(HANDLE hContact, const char *szModule,const char* szSetting, char* szDef)
+char* __stdcall UniGetContactSettingUtf(HANDLE hContact, const char *szModule,const char* szSetting, char* szDef)
{
DBVARIANT dbv = {DBVT_DELETED};
char* szRes;
@@ -192,7 +192,10 @@ int LoadKey(WPARAM w, LPARAM l) int SendKey(WPARAM w, LPARAM l)
{
HANDLE hContact = (HANDLE)w;
- //CallContactService(hContact, PSS_MESSAGE, (WPARAM)PREF_UTF, (LPARAM)szMessage);
+ char *szMessage = UniGetContactSettingUtf(NULL, szModuleName, "GPGPubKey", "");
+ if(strlen(szMessage) > 1)
+ CallContactService(hContact, PSS_MESSAGE, (WPARAM)PREF_UTF, (LPARAM)szMessage);
+ mir_free(szMessage);
return 0;
}
diff --git a/utilities.h b/utilities.h index 3f6cf4c..40582f7 100644 --- a/utilities.h +++ b/utilities.h @@ -17,7 +17,7 @@ #ifndef UTILITIES_H #define UTILITIES_H TCHAR* __stdcall UniGetContactSettingUtf(HANDLE hContact, const char *szModule,const char* szSetting, TCHAR* szDef); -char* __stdcall GetContactSettingStringA(HANDLE hContact, const char *szModule,const char* szSetting, char* szDef); +char* __stdcall UniGetContactSettingUtf(HANDLE hContact, const char *szModule,const char* szSetting, char* szDef); void GetFilePath(TCHAR *WindowTittle, char *szSetting, TCHAR *szExt, TCHAR *szExtDesc); TCHAR *GetFilePath(TCHAR *WindowTittle, TCHAR *szExt, TCHAR *szExtDesc, bool save_file = false); void GetFolderPath(TCHAR *WindowTittle, char *szSetting); |