diff options
-rw-r--r-- | Makefile | 14 | ||||
-rwxr-xr-x[-rw-r--r--] | clist.cpp | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | commonheaders.h | 3 | ||||
-rwxr-xr-x[-rw-r--r--] | globals.h | 4 | ||||
-rwxr-xr-x[-rw-r--r--] | gpg_wrapper.cpp | 4 | ||||
-rwxr-xr-x[-rw-r--r--] | gpg_wrapper.h | 81 | ||||
-rwxr-xr-x[-rw-r--r--] | icons.cpp | 6 | ||||
-rwxr-xr-x[-rw-r--r--] | init.cpp | 39 | ||||
-rwxr-xr-x[-rw-r--r--] | jabber_account.cpp | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | jabber_account.h | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | log.cpp | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | log.h | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | main.cpp | 3 | ||||
-rwxr-xr-x[-rw-r--r--] | main.h | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | messages.cpp | 56 | ||||
-rwxr-xr-x[-rw-r--r--] | metacontacts.cpp | 8 | ||||
-rwxr-xr-x[-rw-r--r--] | metacontacts.h | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | new_gpg.rc | 76 | ||||
-rwxr-xr-x[-rw-r--r--] | new_gpg.sln | 0 | ||||
-rwxr-xr-x[-rw-r--r--] | new_gpg.vcxproj | 40 | ||||
-rw-r--r-- | new_gpg_lang_ru.txt | 115 | ||||
-rwxr-xr-x[-rw-r--r--] | options.cpp | 150 | ||||
-rwxr-xr-x[-rw-r--r--] | resource.h | 181 | ||||
-rwxr-xr-x[-rw-r--r--] | srmm.cpp | 13 | ||||
-rwxr-xr-x[-rw-r--r--] | utilities.cpp | 942 | ||||
-rwxr-xr-x[-rw-r--r--] | utilities.h | 6 |
26 files changed, 1344 insertions, 411 deletions
@@ -1,21 +1,23 @@ -CFLAGS=-g -mdll -mwindows -I../miranda-im/miranda/include/ -I./ -D DEBUG -D _UNICODE -D UNICODE
+CFLAGS=-g -mdll -mwindows -I../miranda-im/miranda/include -I./ -I/home/sss/temp/windows/libs/utf8cpp/include -D DEBUG -D _UNICODE -D UNICODE -DBOOST_SYSTEM_STATIC_LINK=1 -DBOOST_THREAD_USE_LIB
CXXFLAGS=${CFLAGS}
-LDFLAGS=-static-libgcc -Wl,-O1 -shared
+LDFLAGS=-static-libgcc -Wl,-O1 -shared -s -Wl,--subsystem,windows,--kill-at -lshlwapi -lcomdlg32 -lboost_system-mt -lboost_thread_win32-mt -lboost_random-mt -lboost_date_time-mt
CPPFLAGS =
CC=i686-pc-mingw32-gcc
CXX=i686-pc-mingw32-g++
STRIP=i686-pc-mingw32-strip
LD=i686-pc-mingw32-ld
-LNK_COMMON=-lkernel32 -lgpgme -lgcrypt -lgpg-error -lksba -lassuan
-MAINOBJS=init.o utilities.o main.o options.o
+LNK_COMMON=-lkernel32
+ +MAINOBJS=jabber_account.o clist.o init.o options.o gpg_wrapper.o srmm.o messages.o utilities.o metacontacts.o main.o log.o icons.o + WINDRES=i686-pc-mingw32-windres
all: main
main: $(MAINOBJS)
$(WINDRES) -i new_gpg.rc -o resources.o
$(CXX) $(MAINOBJS) resources.o $(LNK_COMMON) $(LDFLAGS) -o new_gpg.dll
- #$(STRIP) new_gpg.dll
- #upx -9 new_gpg.dll
+ $(STRIP) new_gpg.dll
+ upx --best --compress-icons=0 new_gpg.dll
clean:
rm *.o
rm new_gpg.dll
diff --git a/clist.cpp b/clist.cpp index 25c5a24..c64fb17 100644..100755 --- a/clist.cpp +++ b/clist.cpp @@ -1,4 +1,4 @@ -// Copyright © 2010 SecureIM developers (baloo and others), sss
+// Copyright © 2010-2012 SecureIM developers (baloo and others), sss
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
diff --git a/commonheaders.h b/commonheaders.h index 1b7d8f1..459d76e 100644..100755 --- a/commonheaders.h +++ b/commonheaders.h @@ -1,4 +1,4 @@ -// Copyright © 2010 sss +// Copyright © 2010-2012 sss // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -22,6 +22,7 @@ #include <io.h> #include <uxtheme.h> #include <shlwapi.h> +#include <richedit.h> //c #include <locale.h> #include <errno.h> diff --git a/globals.h b/globals.h index cafedab..e84ae1e 100644..100755 --- a/globals.h +++ b/globals.h @@ -1,4 +1,4 @@ -// Copyright © 2010 sss
+// Copyright © 2010-2012 sss
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -16,7 +16,7 @@ #ifndef GLOBALS_H
#define GLOBALS_H
-extern bool bAppendTags, gpg_configured;
+extern bool bAppendTags, bPresenceSigning, bStripTags, gpg_valid, gpg_keyexist, tabsrmm_used;
extern TCHAR *inopentag, *inclosetag, *outopentag, *outclosetag;
extern logtofile debuglog;
#endif
diff --git a/gpg_wrapper.cpp b/gpg_wrapper.cpp index 0a50667..410a0d5 100644..100755 --- a/gpg_wrapper.cpp +++ b/gpg_wrapper.cpp @@ -1,4 +1,4 @@ -// Copyright © 2010 sss +// Copyright © 2010-2012 sss // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -24,7 +24,7 @@ pxResult pxExecute(wstring *acommandline, char *ainput, string *aoutput, LPDWORD aexitcode, pxResult *result, HANDLE hProcess, PROCESS_INFORMATION *pr) { // gpg_mutex.lock(); - if(!gpg_configured) + if(!gpg_valid) return pxNotConfigured; extern logtofile debuglog; BOOL success; diff --git a/gpg_wrapper.h b/gpg_wrapper.h index 77f84f8..5501297 100644..100755 --- a/gpg_wrapper.h +++ b/gpg_wrapper.h @@ -1,33 +1,50 @@ -#ifndef GPG_WRAPPER_H
-#define GPG_WRAPPER_H
-typedef enum {
- pxSuccess,
- pxSuccessExitCodeInvalid,
- pxCreatePipeFailed,
- pxDuplicateHandleFailed,
- pxCloseHandleFailed,
- pxCreateProcessFailed,
- pxThreadWaitFailed,
- pxReadFileFailed,
- pxBufferOverflow,
- pxNotFound,
- pxNotConfigured
-}
-pxResult;
-
-pxResult pxExecute(wstring *acommandline, char *ainput, string *aoutput, LPDWORD aexitcode, pxResult *result);
-
-struct gpg_execution_params
-{
- wstring *cmd;
- char *useless;
- string *out;
- LPDWORD code;
- pxResult *result;
- HANDLE hProcess;
- PROCESS_INFORMATION *proc;
-};
-
-void pxEexcute_thread(void *param);
-
+// Copyright © 2010-2012 sss +// +// This program is free software; you can redistribute it and/or +// modify it under the terms of the GNU General Public License +// as published by the Free Software Foundation; either version 2 +// of the License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + +#ifndef GPG_WRAPPER_H +#define GPG_WRAPPER_H +typedef enum { + pxSuccess, + pxSuccessExitCodeInvalid, + pxCreatePipeFailed, + pxDuplicateHandleFailed, + pxCloseHandleFailed, + pxCreateProcessFailed, + pxThreadWaitFailed, + pxReadFileFailed, + pxBufferOverflow, + pxNotFound, + pxNotConfigured +} +pxResult; + +pxResult pxExecute(wstring *acommandline, char *ainput, string *aoutput, LPDWORD aexitcode, pxResult *result); + +struct gpg_execution_params +{ + wstring *cmd; + char *useless; + string *out; + LPDWORD code; + pxResult *result; + HANDLE hProcess; + PROCESS_INFORMATION *proc; +}; + +void pxEexcute_thread(void *param); + #endif
\ No newline at end of file diff --git a/icons.cpp b/icons.cpp index 882f58b..58a24c9 100644..100755 --- a/icons.cpp +++ b/icons.cpp @@ -1,4 +1,4 @@ -// Copyright © 2010 SecureIM developers (baloo and others), sss
+// Copyright © 2010-2012 SecureIM developers (baloo and others), sss
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -104,9 +104,9 @@ void setClistIcon(HANDLE hContact) }
}
-void setSrmmIcon(HANDLE hContact)
+void setSrmmIcon(HANDLE h)
{
- hContact = metaGetMostOnline(hContact);
+ HANDLE hContact = metaIsProtoMetaContacts(h)?metaGetMostOnline(h):h;
bool enabled = isContactSecured(hContact);
HANDLE hMC = hContact;
if(metaIsSubcontact(hContact))
@@ -1,4 +1,4 @@ -// Copyright © 2010-2011 sss
+// Copyright © 2010-2012 sss
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -17,13 +17,13 @@ #include "commonheaders.h"
//global variables
-bool bAppendTags = false, bDebugLog = false, bJabberAPI = false, bIsMiranda09 = false, bMetaContacts = false, bFileTransfers = false, bAutoExchange = false;
+bool bAppendTags = false, bDebugLog = false, bJabberAPI = false, bPresenceSigning = false, bIsMiranda09 = false, bMetaContacts = false, bFileTransfers = false, bAutoExchange = false, bStripTags = false, tabsrmm_used = false;
TCHAR *inopentag = NULL, *inclosetag = NULL, *outopentag = NULL, *outclosetag = NULL, *password = NULL;
list <JabberAccount*> Accounts;
HINSTANCE hInst;
-HANDLE hLoadPubKey = NULL, hToggleEncryption = NULL, hOnPreBuildContactMenu = NULL, hSendKey = NULL, g_hCLIcon = NULL;
+HANDLE hLoadPubKey = NULL, hToggleEncryption = NULL, hOnPreBuildContactMenu = NULL, hSendKey = NULL, g_hCLIcon = NULL, hExportGpgKeys = NULL, hImportGpgKeys = NULL;
PLUGINLINK *pluginLink;
IconExtraColumn g_IEC = {0};
static int OnModulesLoaded(WPARAM wParam,LPARAM lParam);
@@ -33,7 +33,7 @@ UTF8_INTERFACE utfi = {0}; RECT key_from_keyserver_rect = {0}, firstrun_rect = {0}, new_key_rect = {0}, key_gen_rect = {0}, load_key_rect = {0}, import_key_rect = {0}, key_password_rect = {0}, load_existing_key_rect = {0};
XML_API xi = {0};
logtofile debuglog;
-bool gpg_configured = false;
+bool gpg_valid = false, gpg_keyexist = false;
std::map<HANDLE, contact_data> hcontact_data;
@@ -46,7 +46,7 @@ PLUGININFOEX pluginInfo={ "new GPG encryption support plugin, based on code from old gpg plugin and secureim",
"sss",
"sss123next@list.ru",
- "© 2010-2011 sss",
+ "© 2010-2012 sss",
"http://sss.chaoslab.ru/tracker/mim_plugs/",
1, //unicode
0, //doesn't replace anything built-in
@@ -81,19 +81,24 @@ extern "C" __declspec(dllexport) const MUUID* MirandaPluginInterfaces(void) int LoadKey(WPARAM w, LPARAM l);
int ToggleEncryption(WPARAM w, LPARAM l);
int SendKey(WPARAM w, LPARAM l);
+int ExportGpGKeys(WPARAM w, LPARAM l);
+int ImportGpGKeys(WPARAM w, LPARAM l);
void init_vars()
{
bAppendTags = DBGetContactSettingByte(NULL, szGPGModuleName, "bAppendTags", 0);
+ bStripTags = DBGetContactSettingByte(NULL, szGPGModuleName, "bStripTags", 0);
inopentag = UniGetContactSettingUtf(NULL, szGPGModuleName, "szInOpenTag", _T("<GPGdec>"));
inclosetag = UniGetContactSettingUtf(NULL, szGPGModuleName, "szInCloseTag", _T("</GPGdec>"));
outopentag = UniGetContactSettingUtf(NULL, szGPGModuleName, "szOutOpenTag", _T("<GPGenc>"));
outclosetag = UniGetContactSettingUtf(NULL, szGPGModuleName, "szOutCloseTag", _T("</GPGenc>"));
bDebugLog = DBGetContactSettingByte(NULL, szGPGModuleName, "bDebugLog", 0);
bAutoExchange = DBGetContactSettingByte(NULL, szGPGModuleName, "bAutoExchange", 0);
+ password = UniGetContactSettingUtf(NULL, szGPGModuleName, "szKeyPassword", _T(""));
debuglog.init();
bJabberAPI = DBGetContactSettingByte(NULL, szGPGModuleName, "bJabberAPI", bIsMiranda09?1:0);
- bFileTransfers = DBGetContactSettingByte(NULL, szGPGModuleName, "bFileTransfers", 1);
+ bPresenceSigning = DBGetContactSettingByte(NULL, szGPGModuleName, "bPresenceSigning", 0);
+ bFileTransfers = DBGetContactSettingByte(NULL, szGPGModuleName, "bFileTransfers", 0);
firstrun_rect.left = DBGetContactSettingDword(NULL, szGPGModuleName, "FirstrunWindowX", 0);
firstrun_rect.top = DBGetContactSettingDword(NULL, szGPGModuleName, "FirstrunWindowY", 0);
key_password_rect.left = DBGetContactSettingDword(NULL, szGPGModuleName, "PasswordWindowX", 0);
@@ -108,19 +113,22 @@ void init_vars() new_key_rect.top = DBGetContactSettingDword(NULL, szGPGModuleName, "NewKeyWindowY", 0);
load_existing_key_rect.left = DBGetContactSettingDword(NULL, szGPGModuleName, "LoadExistingKeyWindowX", 0);
load_existing_key_rect.top = DBGetContactSettingDword(NULL, szGPGModuleName, "LoadExistingKeyWindowY", 0);
+ tabsrmm_used = isTabsrmmUsed();
}
extern "C" int __declspec(dllexport) Load(PLUGINLINK *link)
{
pluginLink=link;
- init_vars();
HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
mir_getMMI(&mmi);
mir_getUTFI(&utfi);
mir_getXI(&xi); //TODO: check if we have access to api
+ init_vars();
CreateServiceFunction("/LoadPubKey",(MIRANDASERVICE)LoadKey);
CreateServiceFunction("/ToggleEncryption",(MIRANDASERVICE)ToggleEncryption);
CreateServiceFunction("/SendKey",(MIRANDASERVICE)SendKey);
+ CreateServiceFunction("/ExportGPGKeys",(MIRANDASERVICE)ExportGpGKeys);
+ CreateServiceFunction("/ImportGPGKeys",(MIRANDASERVICE)ImportGpGKeys);
CLISTMENUITEM mi = {0};
mi.cbSize=sizeof(mi);
mi.position=-0x7FFFFFFF;
@@ -145,6 +153,23 @@ extern "C" int __declspec(dllexport) Load(PLUGINLINK *link) mi.pszName="Send public key";
mi.pszService="/SendKey";
hSendKey = (HANDLE)CallService(MS_CLIST_ADDCONTACTMENUITEM,0,(LPARAM)&mi);
+ ZeroMemory(&mi,sizeof(mi));
+ mi.cbSize=sizeof(mi);
+ mi.position=-0x7FFFFFFF;
+ mi.flags=0;
+ mi.hIcon=LoadSkinnedIcon(SKINICON_OTHER_MIRANDA);
+ mi.pszName="Export GPG Public keys from all users";
+ mi.pszService="/ExportGPGKeys";
+ hExportGpgKeys = (HANDLE)CallService(MS_CLIST_ADDMAINMENUITEM,0,(LPARAM)&mi);
+ ZeroMemory(&mi,sizeof(mi));
+ mi.cbSize=sizeof(mi);
+ mi.position=-0x7FFFFFFF;
+ mi.flags=0;
+ mi.hIcon=LoadSkinnedIcon(SKINICON_OTHER_MIRANDA);
+ mi.pszName="Import GPG Public keys from all users";
+ mi.pszService="/ImportGPGKeys";
+ hImportGpgKeys = (HANDLE)CallService(MS_CLIST_ADDMAINMENUITEM,0,(LPARAM)&mi);
+
return 0;
}
diff --git a/jabber_account.cpp b/jabber_account.cpp index 9dedd56..6a264a4 100644..100755 --- a/jabber_account.cpp +++ b/jabber_account.cpp @@ -1,4 +1,4 @@ -// Copyright © 2010 sss
+// Copyright © 2010-2012 sss
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
diff --git a/jabber_account.h b/jabber_account.h index 766f571..b643ed1 100644..100755 --- a/jabber_account.h +++ b/jabber_account.h @@ -1,4 +1,4 @@ -// Copyright © 2010 sss
+// Copyright © 2010-2012 sss
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -1,4 +1,4 @@ -// Copyright © 2010 sss
+// Copyright © 2010-2012 sss
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -1,4 +1,4 @@ -// Copyright © 2010 sss +// Copyright © 2010-2012 sss // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -1,4 +1,4 @@ -// Copyright � 2010-2011 sss +// Copyright © 2010-2011 sss // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -630,7 +630,6 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP mir_free(tmp); if(gpg_exists && lang_exists && !bad_version) MessageBox(0, _T("You have supported version of gpg binary, and gpg language file in place!\ngpg plugin should work fine on your installation!\njust press ok in wollowing diallog."), _T("Info"), MB_OK); - CheckDlgButton(hwndDlg, IDC_AUTO_EXCHANGE, 1); extern bool bIsMiranda09; EnableWindow(GetDlgItem(hwndDlg, IDC_AUTO_EXCHANGE), bIsMiranda09); return TRUE; @@ -1,4 +1,4 @@ -// Copyright © 2010 sss
+// Copyright © 2010-2012 sss
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
diff --git a/messages.cpp b/messages.cpp index 8b339ab..4b4a686 100644..100755 --- a/messages.cpp +++ b/messages.cpp @@ -1,4 +1,4 @@ -// Copyright � 2010-2011 sss +// Copyright © 2010-2011 sss // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -39,31 +39,7 @@ int RecvMsgSvc_func(HANDLE hContact, std::wstring str, char *msg, DWORD flags, D if(!isContactSecured(hContact)) { debuglog<<time_str()<<": info: "<<"received message from: "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, GCDNF_TCHAR)<<" with turned off encryption\n"; - if(bAutoExchange) - { - if(!isContactHaveKey(hContact)) - { - void ShowLoadPublicKeyDialog(); - extern map<int, HANDLE> user_data; - extern int item_num; - item_num = 0; //black magic here - user_data[1] = hContact; - ShowLoadPublicKeyDialog(); - } - else - { - DBWriteContactSettingByte(metaGetMostOnline(hContact), szGPGModuleName, "GPGEncryption", 1); - setSrmmIcon(hContact); - setClistIcon(hContact); - } - if(isContactHaveKey(hContact)) - { - DBWriteContactSettingByte(metaGetMostOnline(hContact), szGPGModuleName, "GPGEncryption", 1); - setSrmmIcon(hContact); - setClistIcon(hContact); - } - } - else if(MessageBox(0, _T("We received encrypted message from contact with encryption turned off.\nDo you want turn on encryption for this contact ?"), _T("Warning"), MB_YESNO) == IDYES) + if(MessageBox(0, _T("We received encrypted message from contact with encryption turned off.\nDo you want turn on encryption for this contact ?"), _T("Warning"), MB_YESNO) == IDYES) { if(!isContactHaveKey(hContact)) { @@ -686,33 +662,7 @@ int SendMsgSvc_func(HANDLE hContact, char *msg, DWORD flags) if(out.find("There is no assurance this key belongs to the named user") != string::npos) { out.clear(); - if(bAutoExchange) - { - DBWriteContactSettingByte(hContact, szGPGModuleName, "bAlwaysTrust", 1); - cmd.insert(0, _T("--trust-model always ")); - gpg_execution_params params; - pxResult result; - params.cmd = &cmd; - params.useless = ""; - params.out = &out; - params.code = &code; - 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); - debuglog<<time_str()<<": GPG execution timed out, aborted\n"; - mir_free(msg); - return CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg); - } - if(result == pxNotFound) - { - mir_free(msg); - return CallContactService(hContact, PSS_MESSAGE, (WPARAM)flags, (LPARAM)msg); - } - } - else if(MessageBox(0, _T("We trying to encrypt with untrusted key, do you want to trust this key permanently ?"), _T("Warning"), MB_YESNO) == IDYES) + if(MessageBox(0, _T("We trying to encrypt with untrusted key, do you want to trust this key permanently ?"), _T("Warning"), MB_YESNO) == IDYES) { DBWriteContactSettingByte(hContact, szGPGModuleName, "bAlwaysTrust", 1); cmd.insert(0, _T("--trust-model always ")); diff --git a/metacontacts.cpp b/metacontacts.cpp index 46185e4..1abc2aa 100644..100755 --- a/metacontacts.cpp +++ b/metacontacts.cpp @@ -1,4 +1,4 @@ -// Copyright © 2010 SecureIM developers (baloo and others), sss
+// Copyright © 2010-2012 SecureIM developers (baloo and others), sss
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -44,7 +44,7 @@ HANDLE metaGetContact(HANDLE hContact) if(bMetaContacts)
if(metaIsSubcontact(hContact))
return (HANDLE)CallService(MS_MC_GETMETACONTACT,(WPARAM)hContact,0);
- return hContact;
+ return NULL;
}
bool metaIsSubcontact(HANDLE hContact)
{
@@ -60,7 +60,7 @@ HANDLE metaGetMostOnline(HANDLE hContact) if(bMetaContacts)
if(metaIsProtoMetaContacts(hContact))
return (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT,(WPARAM)hContact,0);
- return hContact;
+ return NULL;
}
HANDLE metaGetDefault(HANDLE hContact)
{
@@ -68,7 +68,7 @@ HANDLE metaGetDefault(HANDLE hContact) if(bMetaContacts)
if(metaIsProtoMetaContacts(hContact))
return (HANDLE)CallService(MS_MC_GETDEFAULTCONTACT,(WPARAM)hContact,0);
- return hContact;
+ return NULL;
}
diff --git a/metacontacts.h b/metacontacts.h index f7dcfe7..8b8873e 100644..100755 --- a/metacontacts.h +++ b/metacontacts.h @@ -1,4 +1,4 @@ -// Copyright © 2010 sss
+// Copyright © 2010-2012 sss
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
diff --git a/new_gpg.rc b/new_gpg.rc index 0d8f569..fadafdc 100644..100755 --- a/new_gpg.rc +++ b/new_gpg.rc @@ -57,26 +57,30 @@ FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN
DEFPUSHBUTTON "ÎÊ",ID_OK,7,169,50,14
PUSHBUTTON "Load from file",ID_LOAD_FROM_FILE,273,169,58,14
- EDITTEXT IDC_PUBLIC_KEY_EDIT,7,7,324,134,ES_MULTILINE | WS_VSCROLL,WS_EX_STATICEDGE
+ EDITTEXT IDC_PUBLIC_KEY_EDIT,7,7,324,134,ES_MULTILINE | ES_AUTOVSCROLL | ES_AUTOHSCROLL | WS_VSCROLL,WS_EX_STATICEDGE
PUSHBUTTON "Select existing",IDC_SELECT_EXISTING,113,169,97,14
CONTROL "Turn on encryption",IDC_ENABLE_ENCRYPTION,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,8,143,196,10
PUSHBUTTON "Import key from keyserver",IDC_IMPORT,140,152,188,14,WS_DISABLED
END
-IDD_FIRST_RUN DIALOGEX 0, 0, 291, 205
+IDD_FIRST_RUN DIALOGEX 0, 0, 291, 230
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Set own key"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
- DEFPUSHBUTTON "ÎÊ",ID_OK,12,184,50,14,WS_DISABLED
- CONTROL "",IDC_KEY_LIST,"SysListView32",LVS_REPORT | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,7,23,277,105
- PUSHBUTTON "Generate key",IDC_GENERATE_KEY,8,131,74,14
- LTEXT "Select key for use",IDC_STATIC,16,12,186,8
- EDITTEXT IDC_KEY_PASSWORD,94,147,77,14,ES_PASSWORD | ES_AUTOHSCROLL
- RTEXT "Key password:",IDC_STATIC,12,149,76,8
- PUSHBUTTON "Load other",IDC_OTHER,83,131,64,14
- PUSHBUTTON "Delete key",IDC_DELETE_KEY,149,131,70,14
- PUSHBUTTON "Generate and use random key",IDC_GENERATE_RANDOM,99,163,118,14
+ DEFPUSHBUTTON "ÎÊ",ID_OK,12,209,50,14,WS_DISABLED
+ CONTROL "",IDC_KEY_LIST,"SysListView32",LVS_REPORT | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,7,44,277,105
+ PUSHBUTTON "Generate key",IDC_GENERATE_KEY,8,152,74,14
+ LTEXT "Select key for use",IDC_STATIC,16,33,186,8
+ EDITTEXT IDC_KEY_PASSWORD,94,168,77,14,ES_PASSWORD | ES_AUTOHSCROLL
+ RTEXT "Key password:",IDC_STATIC,12,170,76,8
+ PUSHBUTTON "Load other",IDC_OTHER,83,152,64,14
+ PUSHBUTTON "Delete key",IDC_DELETE_KEY,149,152,70,14
+ PUSHBUTTON "Generate and use random key",IDC_GENERATE_RANDOM,99,184,118,14
+ LTEXT "",IDC_GENERATING_KEY,82,207,174,8
+ LTEXT "Account:",IDC_STATIC,15,12,42,8
+ LTEXT "key id: ",IDC_KEY_ID,178,12,99,8
+ COMBOBOX IDC_ACCOUNT,66,9,104,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
END
IDD_BIN_PATH DIALOGEX 0, 0, 354, 108
@@ -84,15 +88,15 @@ STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_VISIBLE | WS_CAPT CAPTION "Set GPG bin path and keyring home dir."
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
- DEFPUSHBUTTON "ÎÊ",ID_OK,7,87,50,14
+ DEFPUSHBUTTON "Continue",ID_OK,7,87,50,14
LTEXT "Home directory:",IDC_STATIC,9,34,325,8
LTEXT "GnuPG binary:",IDC_STATIC,10,7,147,8
PUSHBUTTON "Browse",IDC_SET_BIN_PATH,293,18,54,14
PUSHBUTTON "Browse",IDC_SET_HOME_DIR,293,44,54,14
EDITTEXT IDC_HOME_DIR,7,44,277,14,ES_AUTOHSCROLL
EDITTEXT IDC_BIN_PATH,7,17,277,14,ES_AUTOHSCROLL
- PUSHBUTTON "Generate and use random key",IDC_GENERATE_RANDOM,7,66,118,14
- CONTROL "Turn on key autoexchange",IDC_AUTO_EXCHANGE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,133,68,191,10
+ PUSHBUTTON "Generate and use random key",IDC_GENERATE_RANDOM,166,87,118,14
+ CONTROL "Turn on key autoexchange",IDC_AUTO_EXCHANGE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,64,277,10
END
IDD_NEW_KEY DIALOGEX 0, 0, 427, 68
@@ -115,22 +119,22 @@ BEGIN DEFPUSHBUTTON "OK",IDOK,7,148,50,14
PUSHBUTTON "Cancel",IDCANCEL,227,148,50,14
COMBOBOX IDC_KEY_TYPE,120,14,48,30,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_GROUP | WS_TABSTOP
+ EDITTEXT IDC_KEY_LENGTH,120,30,40,14,ES_AUTOHSCROLL | ES_NUMBER | WS_GROUP
+ EDITTEXT IDC_KEY_PASSWD,120,46,55,14,ES_AUTOHSCROLL | WS_GROUP
+ EDITTEXT IDC_KEY_REAL_NAME,120,61,55,14,ES_AUTOHSCROLL | WS_GROUP
+ EDITTEXT IDC_KEY_EMAIL,120,76,55,14,ES_AUTOHSCROLL | WS_GROUP
+ EDITTEXT IDC_KEY_COMMENT,120,91,55,14,ES_AUTOHSCROLL | WS_GROUP
+ EDITTEXT IDC_KEY_EXPIRE_DATE,120,106,55,14,ES_AUTOHSCROLL | WS_GROUP
LTEXT "Key type:",IDC_STATIC,8,16,96,8
LTEXT "Key length:",IDC_STATIC,7,32,106,8
LTEXT "Key password:",IDC_STATIC,7,49,105,8
- EDITTEXT IDC_KEY_PASSWD,120,46,55,14,ES_AUTOHSCROLL | WS_GROUP
LTEXT "Real name:",IDC_STATIC,7,63,105,8
LTEXT "Email:",IDC_STATIC,7,79,108,8
LTEXT "Comment:",IDC_STATIC,7,92,107,8
LTEXT "Expire date:",IDC_STATIC,7,109,111,8
- EDITTEXT IDC_KEY_EMAIL,120,76,55,14,ES_AUTOHSCROLL | WS_GROUP
- EDITTEXT IDC_KEY_REAL_NAME,120,61,55,14,ES_AUTOHSCROLL | WS_GROUP
- EDITTEXT IDC_KEY_COMMENT,120,91,55,14,ES_AUTOHSCROLL | WS_GROUP
- EDITTEXT IDC_KEY_EXPIRE_DATE,120,106,55,14,ES_AUTOHSCROLL | ES_NUMBER | WS_GROUP
LTEXT "ex.: 2010-08-15",IDC_STATIC,182,108,75,8
- EDITTEXT IDC_KEY_LENGTH,120,30,40,14,ES_AUTOHSCROLL | ES_NUMBER | WS_GROUP
LTEXT "From 1024 to 4096",IDC_STATIC,168,33,89,8
- LTEXT "It can take a long time, be patient",IDC_STATIC,15,132,246,8
+ LTEXT "It can take a long time, be patient",IDC_GENERATING_TEXT,15,132,246,8
LTEXT "0 - does not expire",IDC_STATIC,122,122,141,8
END
@@ -150,7 +154,7 @@ CAPTION "Enter password for your secret key" FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "ÎÊ",IDOK,7,87,50,14
- PUSHBUTTON "Îòìåíà",IDCANCEL,150,87,50,14
+ PUSHBUTTON "Cancel",IDCANCEL,150,87,50,14
EDITTEXT IDC_PASSWORD,13,38,179,14,ES_PASSWORD | ES_AUTOHSCROLL
LTEXT "Password:",IDC_STATIC,14,28,34,8
CONTROL "Save password to database",IDC_SAVE_PASSWORD,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,56,124,10
@@ -189,8 +193,10 @@ BEGIN BEGIN
LEFTMARGIN, 7
RIGHTMARGIN, 284
+ VERTGUIDE, 15
TOPMARGIN, 7
- BOTTOMMARGIN, 198
+ BOTTOMMARGIN, 223
+ HORZGUIDE, 20
END
IDD_BIN_PATH, DIALOG
@@ -316,15 +322,16 @@ BEGIN CTEXT "Userlist:",IDC_STATIC,25,7,201,8
PUSHBUTTON "Export PubKey",IDC_SAVE_KEY_BUTTON,8,135,75,14
PUSHBUTTON "Delete key",IDC_DELETE_KEY_BUTTON,90,135,70,14
- PUSHBUTTON "Select own key",IDC_SELECT_KEY,170,193,109,14
+ PUSHBUTTON "Select own key",IDC_SELECT_KEY,205,193,74,14
CONTROL "Turn on debug log",IDC_DEBUG_LOG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,181,159,89,10
EDITTEXT IDC_LOG_FILE_EDIT,11,157,98,14,ES_AUTOHSCROLL
PUSHBUTTON "Browse",IDC_LOG_FILE_SET,119,156,50,14
CONTROL "Use jabber api on Miranda IM >= 0.9 (recomended)",IDC_JABBER_API,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,175,251,10
- LTEXT "Current key",IDC_CURRENT_KEY,48,196,116,8
+ LTEXT "Default key",IDC_CURRENT_KEY,12,196,110,8
CONTROL "Encrypt file transfers",IDC_FILE_TRANSFERS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,185,137,10
CONTROL "Automatic key exchange",IDC_AUTO_EXCHANGE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,163,137,111,10
+ PUSHBUTTON "Copy own key",IDC_COPY_KEY,127,193,74,14
END
IDD_OPT_GPG_BIN DIALOGEX 0, 0, 282, 214
@@ -355,6 +362,16 @@ BEGIN EDITTEXT IDC_OUT_CLOSE_TAG,151,46,90,14,ES_AUTOHSCROLL
RTEXT "Open:",IDC_STATIC,13,49,26,8
RTEXT "Close:",IDC_STATIC,127,49,23,8
+ CONTROL "Strip all tags in outgoing messages",IDC_STRIP_TAGS,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,3,76,233,10
+END
+
+IDD_OPT_GPG_ADVANCED DIALOGEX 0, 0, 286, 214
+STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD
+FONT 8, "MS Shell Dlg", 400, 0, 0x0
+BEGIN
+ CONTROL "Turn on presence signing (Jabber)",IDC_PRESCENSE_SUBSCRIPTION,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,9,190,10
END
@@ -373,6 +390,15 @@ BEGIN IDD_OPT_GPG_BIN, DIALOG
BEGIN
END
+
+ IDD_OPT_GPG_MESSAGES, DIALOG
+ BEGIN
+ END
+
+ IDD_OPT_GPG_ADVANCED, DIALOG
+ BEGIN
+ VERTGUIDE, 12
+ END
END
#endif // APSTUDIO_INVOKED
diff --git a/new_gpg.sln b/new_gpg.sln index 6a74e17..6a74e17 100644..100755 --- a/new_gpg.sln +++ b/new_gpg.sln diff --git a/new_gpg.vcxproj b/new_gpg.vcxproj index 19274a0..69f5edd 100644..100755 --- a/new_gpg.vcxproj +++ b/new_gpg.vcxproj @@ -477,15 +477,14 @@ </Midl>
<ClCompile>
<Optimization>Disabled</Optimization>
- <AdditionalIncludeDirectories>e:\temp\windows\libs\utf8cpp\include;e:\temp\windows\libs\Boost\include\boost-1_46;e:\install\git\miranda\miranda-im\miranda\include;x:\install\git\miranda\mim_plugs;../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>x:\temp\windows\libs\utf8cpp\include;x:\temp\windows\libs\Boost\include;x:\install\git\miranda\miranda-im\miranda\include;x:\install\git\miranda\mim_plugs;../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;TESTPLUG_EXPORTS;_CRT_SECURE_NO_WARNINGS;_UNICODE;UNICODE;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>commonheaders.h</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>c:\temp\new_gpg.pch</PrecompiledHeaderOutputFile>
- <AssemblerOutput>
- </AssemblerOutput>
+ <AssemblerOutput>All</AssemblerOutput>
<AssemblerListingLocation>.\Debug/</AssemblerListingLocation>
<ObjectFileName>.\Debug/</ObjectFileName>
<ProgramDataBaseFileName>.\Debug/</ProgramDataBaseFileName>
@@ -493,23 +492,28 @@ <WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <MultiProcessorCompilation>true</MultiProcessorCompilation>
+ <RuntimeTypeInfo>true</RuntimeTypeInfo>
+ <CompileAs>CompileAsCpp</CompileAs>
+ <ExpandAttributedSource>true</ExpandAttributedSource>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0809</Culture>
</ResourceCompile>
<Link>
- <AdditionalDependencies>shlwapi.lib;%(AdditionalDependencies) libboost_thread-vc100-mt-sgd-1_47.lib</AdditionalDependencies>
+ <AdditionalDependencies>shlwapi.lib;%(AdditionalDependencies) libboost_thread-vc100-mt-sgd-1_51.lib</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
- <AdditionalLibraryDirectories>e:\temp\windows\libs\Boost\lib-debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalLibraryDirectories>x:\temp\windows\libs\Boost\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AssemblyDebug>true</AssemblyDebug>
- <GenerateMapFile>false</GenerateMapFile>
+ <GenerateMapFile>true</GenerateMapFile>
<MapExports>false</MapExports>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<ImportLibrary>.\Debug/testplug.lib</ImportLibrary>
+ <ProgramDatabaseFile>c:\debug\$(TargetName).pdb</ProgramDatabaseFile>
</Link>
<Bscmake>
<SuppressStartupBanner>true</SuppressStartupBanner>
@@ -527,7 +531,7 @@ </Midl>
<ClCompile>
<Optimization>Disabled</Optimization>
- <AdditionalIncludeDirectories>e:\temp\windows\libs\utf8cpp\include;e:\temp\windows\libs\Boost\include\boost-1_46;e:\install\git\miranda\miranda-im\miranda\include;x:\install\git\miranda\mim_plugs;../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>x:\temp\windows\libs\utf8cpp\include;X:\temp\windows\libs\Boost\include;x:\install\git\miranda\miranda-im\miranda\include;x:\install\git\miranda\mim_plugs;../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;TESTPLUG_EXPORTS;_CRT_SECURE_NO_WARNINGS;_UNICODE;UNICODE;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
@@ -551,7 +555,7 @@ <Link>
<AdditionalDependencies>shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
- <AdditionalLibraryDirectories>e:\temp\windows\libs\Boost\lib-debug-x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <AdditionalLibraryDirectories>X:\temp\windows\libs\Boost\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AssemblyDebug>true</AssemblyDebug>
<GenerateMapFile>false</GenerateMapFile>
@@ -560,6 +564,7 @@ <DataExecutionPrevention>
</DataExecutionPrevention>
<ImportLibrary>.\Debug/testplug.lib</ImportLibrary>
+ <ProgramDatabaseFile>c:\debug\$(TargetName).pdb</ProgramDatabaseFile>
</Link>
<Bscmake>
<SuppressStartupBanner>true</SuppressStartupBanner>
@@ -685,7 +690,7 @@ <FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<WholeProgramOptimization>true</WholeProgramOptimization>
- <AdditionalIncludeDirectories>e:\temp\windows\libs\utf8cpp\include;e:\temp\windows\libs\Boost\include\boost-1_46;e:\install\git\miranda\miranda-im\miranda\include;e:\install\git\miranda\mim_plugs;../../include</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>x:\temp\windows\libs\utf8cpp\include;X:\temp\windows\libs\Boost\include;x:\install\git\miranda\miranda-im\miranda\include;x:\install\git\miranda\mim_plugs;../../include</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;_UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
@@ -708,8 +713,8 @@ <Link>
<AdditionalDependencies>shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
- <AdditionalLibraryDirectories>e:\temp\windows\libs\Boost\lib-release;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <GenerateDebugInformation>false</GenerateDebugInformation>
+ <AdditionalLibraryDirectories>X:\temp\windows\libs\Boost\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>NotSet</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
@@ -718,6 +723,7 @@ <DataExecutionPrevention>
</DataExecutionPrevention>
<ImportLibrary>.\Release Unicode (static)/testplug.lib</ImportLibrary>
+ <ProgramDatabaseFile>c:\debug\$(TargetName).pdb</ProgramDatabaseFile>
</Link>
<Bscmake>
<SuppressStartupBanner>true</SuppressStartupBanner>
@@ -739,7 +745,7 @@ <FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<WholeProgramOptimization>true</WholeProgramOptimization>
- <AdditionalIncludeDirectories>e:\temp\windows\libs\utf8cpp\include;e:\temp\windows\libs\Boost\include\boost-1_46;e:\install\git\miranda\miranda-im\miranda\include;x:\install\git\miranda\mim_plugs;../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalIncludeDirectories>x:\temp\windows\libs\utf8cpp\include;x:\temp\windows\libs\Boost\include;x:\install\git\miranda\miranda-im\miranda\include;x:\install\git\miranda\mim_plugs;../../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_WARNINGS;_UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
@@ -762,8 +768,8 @@ <Link>
<AdditionalDependencies>shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SuppressStartupBanner>true</SuppressStartupBanner>
- <AdditionalLibraryDirectories>e:\temp\windows\libs\Boost\lib-release-x64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
- <GenerateDebugInformation>false</GenerateDebugInformation>
+ <AdditionalLibraryDirectories>x:\temp\windows\libs\Boost\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>NotSet</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
@@ -772,6 +778,7 @@ <DataExecutionPrevention>
</DataExecutionPrevention>
<ImportLibrary>.\Release Unicode (static)/testplug.lib</ImportLibrary>
+ <ProgramDatabaseFile>c:\debug\$(TargetName).pdb</ProgramDatabaseFile>
</Link>
<Bscmake>
<SuppressStartupBanner>true</SuppressStartupBanner>
@@ -1337,4 +1344,9 @@ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
+ <ProjectExtensions>
+ <VisualStudio>
+ <UserProperties RESOURCE_FILE="new_gpg.rc" />
+ </VisualStudio>
+ </ProjectExtensions>
</Project>
\ No newline at end of file diff --git a/new_gpg_lang_ru.txt b/new_gpg_lang_ru.txt new file mode 100644 index 0000000..4cf3659 --- /dev/null +++ b/new_gpg_lang_ru.txt @@ -0,0 +1,115 @@ +;============================================================
+; File: new_gpg.dll
+; Module: new GPG encryption plugin
+; Versions: 0.0.0.11
+; URL: http://addons.miranda-im.org/details.php?action=viewfile&id=958
+; Source: git://sss.chaoslab.ru/mim_plugs.git (checkout new_gpg)
+; Authors: sss
+;============================================================
+
+[Your GPG version is supported. The language file was found.\nGPG plugin should work fine.\nPress OK to continue.]
+Âàøà âåðñèÿ GPG ïîääåðæèâàåòñÿ. ßçûêîâûå ôàéëû íàéäåíû.\nGPG Äîëæåí ðàáîòàòü íîðìàëüíî.\nÍàæìèòå ÎÊ.
+[Copy own key]
+Êîïèð. ñâîé êëþ÷
+[Select own key]
+Âûáðàòü ñâîé êëþ÷
+[Export PubKey]
+Ñîõðàíèòü êëþ÷
+[GnuPG Variables]
+Ïóòè ê GPG
+[Turn on debug log]
+Âêë. çàïèñü îòëàäêè
+[Accept]
+Ïðèíÿòü
+[Accept and enable encryption]
+Ïðèíÿòü è âêëþ÷èòü øèôðîâàíèå
+[Replace]
+Çàìåíèòü
+[Import key]
+Èìïîðò êëþ÷à
+[Load from file]
+Èìïîðò èç ôàéëà
+[Load other]
+Çàãðóçèòü
+[Delete key]
+Óäàëèòü êëþ÷
+[Select existing]
+Âûáðàòü ñóùåñòâóþùèé
+[Turn on encryption]
+Âêëþ÷èòü øèôðîâàíèå
+[Import key from keyserver]
+Èìïîðò êëþ÷à ñ ñåðâåðà êëþ÷åé
+[New public key was received, do you want to import it?]
+Ïîëó÷åí íîâûé îòðûòûé êëþ÷. Âû õîòèòå åãî ïðèíÿòü?
+[There is existing key for contact, would you like to replace with new key ?]
+Ïîëó÷åí êëþ÷, íî ó êîíòàêòà óæå åñòü êëþ÷. Âû õîòèòå åãî çàìåíèòü íîâûì?
+[The new public key was recieved]
+Ïîëó÷åí íîâûé îòðûòûé êëþ÷.
+[Received key from]
+Ïîëó÷åí êëþ÷ îò
+[Do you want to remove key from entire metacontact (all subcontacts) ?]
+Âû õîòèòå óáðàòü êëþ÷ äëÿ ìåòàêîíòàêòà (âñåõ ñóáêîíòàêòîâ)?
+[Select existing public key from list]
+Âûáðàòü îòêðûòûé êëþ÷ èç ñïèñêà
+[Encrypt file transfers]
+Øèôðîâàííàÿ ïåðåäà÷à ôàéëîâ
+[Use jabber api on Miranda IM >= 0.9 (recomended)]
+Èñïîëüçîâàòü jabber api åñëè Miranda IM >= 0.9 (Ðåêîìåíäóåòñÿ)
+[Current private key id]
+Çàêðûòûé êëþ÷
+[This is not gnupg binary !\nrecommended to use GnuPG v1.x.x with this plugn.]
+Âûáðàííûé âàìè exe íå GnuPG!\nÐåêîìåíäóåòñÿ èñïîëüçîâàòü GnuPG v1.x.x ñ ýòèì ïëàãèíîì.
+[Unsupported gnupg version found, use at you own risk!\nrecommended to use GnuPG v1.x.x with this plugn.]
+Âàøà âåðñèÿ GnuPG íå ïîääåðæèâàåòñÿ è ìîæåò ðàáîòàòü íå ïðàâèëüíî!\nÐåêîìåíäóåòñÿ èñïîëüçîâàòü GnuPG v1.x.x ñ ýòèì ïëàãèíîì.
+[Generate key]
+Ñãåíåðèðîâàòü
+[Select key for use]
+Âûáðàòü êëþ÷
+[Generate and use random key]
+Ñãåíåðèðîâàòü è èñïîëüçîâàòü êëþ÷
+[GnuPG binary:]
+Ïóòü ê exe:
+[Home directory:]
+Äîìàøíèé êàòàëîã:
+[Turn on key autoexchange]
+Âêëþ÷èòü àâòîîáìåí êëþ÷àìè
+[Key type:]
+Òèï êëþ÷à:
+[Key length:]
+Äëèííà êëþ÷à
+[Key password:]
+Ïàðîëü êëþ÷à:
+[Real name:]
+Èìÿ/Íèê:
+[Comment:]
+Êîììåíòàðèé:
+[Expire date:]
+Îêîí÷àíèå äåéñòâèÿ êëþ÷à:
+[ex.: 2010-08-15]
+ïðèìåð: 2010-08-15
+[From 1024 to 4096]
+îò 1024 äî 4096
+[It can take a long time, be patient]
+* Ýòî ìîæåò çàíÿòü íåñêîëüêî ìèíóò.
+[0 - does not expire]
+0 - íèêîãäà íå çàêàí÷èâàåòñÿ
+[Save password to database]
+Ñîõðàíèòü ïàðîëü â áàçó
+[Default password]
+Ïàðîëü ïî óìîë÷àíèþ
+[Import]
+Èìïîðòèðîâàòü
+[Select keyserver for key search:]
+Âûáðàòü ñåðâåð êëþ÷åé äëÿ ïîèñêà:
+[Userlist:]
+Ëèñò ïîëüçîâàòåëåé:
+[Add tags to encoded and decoded messages]
+Äîáàâëÿòü ìåòêè ê ñîîáùåíèÿì
+[Incomming message tags:]
+Äîáàâëÿòü ìåòêè ê âõîäÿùèì ñîîáùåíèÿì:
+[Outgoing message tags:]
+Äîáàâëÿòü ìåòêè èñõîäÿùèì ñîîáùåíèÿñ:
+[Open:]
+Íà÷àëî
+[Close:]
+Êîíåö
diff --git a/options.cpp b/options.cpp index 7eafe97..109d54c 100644..100755 --- a/options.cpp +++ b/options.cpp @@ -1,4 +1,4 @@ -// Copyright © 2010 sss
+// Copyright © 2010-2012 sss
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -21,6 +21,7 @@ extern HINSTANCE hInst; static BOOL CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
static BOOL CALLBACK DlgProcGpgMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+static BOOL CALLBACK DlgProcGpgAdvOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
BOOL CheckStateLoadDB(HWND hwndDlg, int idCtrl, const char* szSetting, BYTE bDef)
{
@@ -74,6 +75,18 @@ int GpgOptInit(WPARAM wParam,LPARAM lParam) odp.pfnDlgProc = (DLGPROC)DlgProcGpgMsgOpts;
CallService(MS_OPT_ADDPAGE,wParam,(LPARAM)&odp);
+ ZeroMemory(&odp, sizeof(odp));
+
+ odp.cbSize = sizeof(odp);
+ odp.hInstance = hInst;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_GPG_ADVANCED);
+ odp.pszTitle = szGPGModuleName;
+ odp.pszGroup = "Services";
+ odp.pszTab = "Advanced";
+ odp.flags=ODPF_BOLDGROUPS | ODPF_EXPERTONLY;
+ odp.pfnDlgProc = (DLGPROC)DlgProcGpgAdvOpts;
+ CallService(MS_OPT_ADDPAGE,wParam,(LPARAM)&odp);
+
return 0;
}
@@ -151,13 +164,19 @@ static BOOL CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA mir_free(tmp2);
ListView_SetItemText(hwndList, iRow, 1, (_tcslen(tmp) > 1)?tmp:_T("not set"));
mir_free(tmp);
- tmp2 = UniGetContactSettingUtf(hContact, szGPGModuleName, "KeyMainName", "");
- tmp = mir_a2t(tmp2);
+ char *tmp2 = UniGetContactSettingUtf(hContact, szGPGModuleName, "KeyMainName", "");
+ if(!toUTF16(tmp2).empty())
+ tmp = mir_wstrdup(toUTF16(tmp2).c_str());
+ else
+ tmp = UniGetContactSettingUtf(hContact, szGPGModuleName, "KeyMainName", _T(""));
mir_free(tmp2);
ListView_SetItemText(hwndList, iRow, 2, (_tcslen(tmp) > 1)?tmp:_T("not set"));
mir_free(tmp);
tmp2 = UniGetContactSettingUtf(hContact, szGPGModuleName, "KeyMainEmail", "");
- tmp = mir_a2t(tmp2);
+ if(!toUTF16(tmp2).empty())
+ tmp = mir_wstrdup(toUTF16(tmp2).c_str());
+ else
+ tmp = UniGetContactSettingUtf(hContact, szGPGModuleName, "KeyMainEmail", _T(""));
mir_free(tmp2);
ListView_SetItemText(hwndList, iRow, 3, (_tcslen(tmp) > 1)?tmp:_T("not set"));
mir_free(tmp);
@@ -180,15 +199,16 @@ static BOOL CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA EnableWindow(GetDlgItem(hwndDlg, IDC_JABBER_API), bIsMiranda09);
EnableWindow(GetDlgItem(hwndDlg, IDC_AUTO_EXCHANGE), (bIsMiranda09 && bJabberAPI));
{
- string keyinfo = Translate("Current private key id: ");
+ string keyinfo = Translate("Default private key id");
+ keyinfo += ": ";
char *keyid = UniGetContactSettingUtf(NULL, szGPGModuleName, "KeyID", "");
- keyinfo += (strlen(keyid) > 0)?keyid:"not set";
+ keyinfo += (strlen(keyid) > 0)?keyid:Translate("not set");
mir_free(keyid);
SetDlgItemTextA(hwndDlg, IDC_CURRENT_KEY, keyinfo.c_str());
}
if(bIsMiranda09)
CheckStateLoadDB(hwndDlg, IDC_JABBER_API, "bJabberAPI", 1);
- CheckStateLoadDB(hwndDlg, IDC_FILE_TRANSFERS, "bFileTransfers", 1);
+ CheckStateLoadDB(hwndDlg, IDC_FILE_TRANSFERS, "bFileTransfers", 0);
CheckStateLoadDB(hwndDlg, IDC_AUTO_EXCHANGE, "bAutoExchange", 0);
return TRUE;
}
@@ -353,6 +373,51 @@ static BOOL CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA f.close();
}
break;
+ case IDC_COPY_KEY:
+ {
+ if(OpenClipboard(hwndDlg))
+ {
+ char *szKey = UniGetContactSettingUtf(NULL, szGPGModuleName, "GPGPubKey", "");
+ std::string str = szKey;;
+ mir_free(szKey);
+ for(std::string::size_type i = str.find("\n"); i != std::string::npos; i = str.find("\n", i+2))
+ str.replace(i, 1, "\r\n");
+ HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, str.size() +1);
+ if(!hMem)
+ {
+ MessageBoxA(0, "Failed to alocate memory", "Error", MB_OK);
+ break;
+ }
+ szKey = (char*)GlobalLock(hMem);
+ if(!szKey)
+ {
+ char msg[64];
+ mir_snprintf(msg, 127, "Failed to lock memory with error %d", GetLastError());
+ MessageBoxA(0, msg, "Error", MB_OK);
+ GlobalFree(hMem);
+ }
+ memcpy(szKey, str.c_str(), str.size());
+ szKey[str.size()] = '\0';
+ str.clear();
+ EmptyClipboard();
+ GlobalUnlock(hMem);
+ if(!SetClipboardData(CF_OEMTEXT, hMem))
+ {
+ GlobalFree(hMem);
+ char msg[64];
+ mir_snprintf(msg, 127, "Failed write to clipboard with error %d", GetLastError());
+ MessageBoxA(0, msg, "Error", MB_OK);
+ }
+ CloseClipboard();
+ }
+ else
+ {
+ char msg[64];
+ mir_snprintf(msg, 127, "Failed to open clipboard with error %d", GetLastError());
+ MessageBoxA(0, msg, "Error", MB_OK);
+ }
+ }
+ break;
case IDC_LOG_FILE_SET:
{
tmp = GetFilePath(_T("Set log file"), _T("*"), _T("LOG files"), 1);
@@ -366,7 +431,7 @@ static BOOL CALLBACK DlgProcGpgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
}
-
+
case WM_NOTIFY:
{
EnableWindow(GetDlgItem(hwndDlg, IDC_AUTO_EXCHANGE), (bIsMiranda09 && IsDlgButtonChecked(hwndDlg, IDC_JABBER_API)));
@@ -481,10 +546,10 @@ static BOOL CALLBACK DlgProcGpgBinOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP else
{
bad_version = false;
- MessageBox(0, _T("This is not gnupg binary !\nrecommended to use GnuPG v1.x.x with this plugn."), _T("Warning"), MB_OK);
+ MessageBox(0, TranslateT("This is not gnupg binary !\nrecommended to use GnuPG v1.x.x with this plugn."), _T("Warning"), MB_OK);
}
- if(bad_version)
- MessageBox(0, _T("Unsupported gnupg version found, use at you own risk!\nrecommended to use GnuPG v1.x.x with this plugn."), _T("Warning"), MB_OK);
+/* if(bad_version) //looks like working fine with gpg2
+ MessageBox(0, TranslateT("Unsupported gnupg version found, use at you own risk!\nrecommended to use GnuPG v1.x.x with this plugn."), _T("Warning"), MB_OK); */
}
}
char mir_path[MAX_PATH];
@@ -557,6 +622,7 @@ static BOOL CALLBACK DlgProcGpgMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP {
TranslateDialogDefault(hwndDlg);
CheckStateLoadDB(hwndDlg, IDC_APPEND_TAGS, "bAppendTags", 0);
+ CheckStateLoadDB(hwndDlg, IDC_STRIP_TAGS, "bStripTags", 0);
{
TCHAR *tmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "szInOpenTag", _T("<GPGdec>"));
SetDlgItemText(hwndDlg, IDC_IN_OPEN_TAG, tmp);
@@ -597,6 +663,7 @@ static BOOL CALLBACK DlgProcGpgMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP case PSN_APPLY:
{
bAppendTags = CheckStateStoreDB(hwndDlg, IDC_APPEND_TAGS, "bAppendTags");
+ bStripTags = CheckStateStoreDB(hwndDlg, IDC_STRIP_TAGS, "bStripTags");
{
TCHAR tmp[128];
GetDlgItemText(hwndDlg, IDC_IN_OPEN_TAG, tmp, 128);
@@ -629,12 +696,67 @@ static BOOL CALLBACK DlgProcGpgMsgOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP return FALSE;
}
+static BOOL CALLBACK DlgProcGpgAdvOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ {
+ extern bool bJabberAPI;
+ TranslateDialogDefault(hwndDlg);
+ CheckStateLoadDB(hwndDlg, IDC_PRESCENSE_SUBSCRIPTION, "bPresenceSigning", 0);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_PRESCENSE_SUBSCRIPTION), bJabberAPI);
+
+ return TRUE;
+ }
+
+
+ case WM_COMMAND:
+ {
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+ }
+
+ case WM_NOTIFY:
+ {
+ switch (((LPNMHDR)lParam)->code)
+ {
+
+ case PSN_APPLY:
+ {
+ bPresenceSigning = CheckStateStoreDB(hwndDlg, IDC_PRESCENSE_SUBSCRIPTION, "bPresenceSigning");
+ return TRUE;
+ }
+ }
+ }
+ break;
+ }
+ return FALSE;
+}
+
HWND hPubKeyEdit = NULL;
+LONG_PTR default_edit_proc = NULL;
+
+static BOOL CALLBACK editctrl_ctrl_a(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam)
+{
+ LRESULT ret = 0;
+ switch(msg)
+ {
+ case WM_KEYDOWN:
+ if(wParam == 0x41 && GetKeyState(VK_CONTROL)< 0 )
+ SendMessage(hwndDlg, EM_SETSEL, 0, -1);
+ break;
+ default:
+ ret = CallWindowProc((WNDPROC)default_edit_proc, hwndDlg, msg, wParam, lParam);
+ break;
+ }
+ return ret;
+}
static BOOL CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam)
{
- HANDLE hContact = user_data[item_num+1];
+ static HANDLE hContact = user_data[item_num+1];
TCHAR *tmp = NULL;
@@ -645,7 +767,9 @@ static BOOL CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam,LP {
case WM_INITDIALOG:
{
+ default_edit_proc = GetWindowLong(GetDlgItem(hwndDlg, IDC_PUBLIC_KEY_EDIT), GWLP_WNDPROC);
SetWindowPos(hwndDlg, 0, load_key_rect.left, load_key_rect.top, 0, 0, SWP_NOSIZE|SWP_SHOWWINDOW);
+ SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_PUBLIC_KEY_EDIT), GWLP_WNDPROC, (LONG_PTR)editctrl_ctrl_a);
HANDLE hcnt = hContact;
if(metaIsProtoMetaContacts(hcnt))
hcnt = metaGetMostOnline(hcnt);
@@ -761,7 +885,6 @@ static BOOL CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam,LP return TRUE;
}
-
case WM_COMMAND:
{
switch (LOWORD(wParam))
@@ -1250,7 +1373,6 @@ static BOOL CALLBACK DlgProcLoadPublicKey(HWND hwndDlg,UINT msg,WPARAM wParam,LP DBWriteContactSettingDword(NULL, szGPGModuleName, "LoadKeyWindowY", load_key_rect.top);
}
break;
-
}
return FALSE;
diff --git a/resource.h b/resource.h index 9043ac1..027e279 100644..100755 --- a/resource.h +++ b/resource.h @@ -1,85 +1,96 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by new_gpg.rc -// -#define IDD_LOAD_PUBLIC_KEY 102 -#define IDD_FIRST_RUN 103 -#define IDD_OPT_GPG 104 -#define IDD_OPT_GPG_BIN 105 -#define IDD_BIN_PATH 106 -#define IDD_OPT_GPG_MESSAGES 107 -#define IDD_NEW_KEY 108 -#define IDD_KEY_GEN 109 -#define IDD_LOAD_EXISTING_KEY 110 -#define IDD_KEY_PASSWD 111 -#define IDI_SECURED 112 -#define IDD_IMPORT_KEY 112 -#define IDI_UNSECURED 113 -#define IDC_SET_BIN_PATH 1016 -#define IDC_SET_HOME_DIR 1017 -#define IDC_BIN_PATH 1018 -#define IDC_HOME_DIR 1019 -#define IDC_USERLIST 1020 -#define IDC_LOAD_KEY_BUTTON 1022 -#define ID_OK 1023 -#define ID_LOD_FROM_FILE 1024 -#define ID_LOAD_FROM_FILE 1024 -#define IDC_EDIT1 1025 -#define IDC_PUBLIC_KEY_EDIT 1025 -#define IDC_KEY_PASSWORD 1025 -#define IDC_IN_OPEN_TAG 1025 -#define IDC_KEY_PASSWD 1025 -#define IDC_PASSWORD 1025 -#define IDC_LOG_FILE_EDIT 1025 -#define IDC_BUTTON1 1026 -#define IDC_SAVE_KEY_BUTTON 1026 -#define IDC_GENERATE_KEY 1026 -#define IDC_IGNORE_KEY 1026 -#define IDC_SELECT_EXISTING 1026 -#define IDC_KEY_EMAIL 1026 -#define IDC_DELETE_KEY_BUTTON 1027 -#define IDC_IN_CLOSE_TAG 1027 -#define IDC_KEY_REAL_NAME 1027 -#define IDC_KEY_LIST 1028 -#define IDC_KEY_COMMENT 1028 -#define IDC_OUT_OPEN_TAG 1029 -#define IDC_APPEND_TAGS 1030 -#define IDC_OUT_CLOSE_TAG 1031 -#define IDC_SELECT_KEY 1033 -#define IDC_MESSAGE 1034 -#define ID_IMPORT 1035 -#define IDC_IMPORT_AND_USE 1036 -#define IDC_KEY_TYPE 1039 -#define IDC_KEY_LENGTH 1040 -#define IDC_KEY_EXPIRE_DATE 1043 -#define IDC_EXISTING_KEY_LIST 1045 -#define IDC_BUTTON2 1046 -#define IDC_OTHER 1046 -#define IDC_LOG_FILE_SET 1046 -#define IDC_IMPORT 1046 -#define IDC_SAVE_PASSWORD 1047 -#define IDC_DEBUG_LOG 1048 -#define IDC_JABBER_API 1049 -#define IDC_ENABLE_ENCRYPTION 1050 -#define IDC_KEY_FROM 1051 -#define IDC_DELETE_KEY 1052 -#define IDC_KEYID 1053 -#define IDC_CURRENT_KEY 1054 -#define IDC_DEFAULT_PASSWORD 1055 -#define IDC_KEYSERVER 1058 -#define IDC_FILE_TRANSFERS 1061 -#define IDC_REMOVE_FILTERS 1062 -#define IDC_GENERATE_RANDOM 1063 -#define IDC_AUTO_EXCHANGE 1064 -#define IDC_AUT_EXCHANGE 1065 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 114 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1066 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif +//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by new_gpg.rc
+//
+#define IDD_LOAD_PUBLIC_KEY 102
+#define IDD_FIRST_RUN 103
+#define IDD_OPT_GPG 104
+#define IDD_OPT_GPG_BIN 105
+#define IDD_BIN_PATH 106
+#define IDD_OPT_GPG_MESSAGES 107
+#define IDD_NEW_KEY 108
+#define IDD_KEY_GEN 109
+#define IDD_LOAD_EXISTING_KEY 110
+#define IDD_KEY_PASSWD 111
+#define IDI_SECURED 112
+#define IDD_IMPORT_KEY 112
+#define IDI_UNSECURED 113
+#define IDD_OPT_GPG_ADVANCED 113
+#define IDC_SET_BIN_PATH 1016
+#define IDC_SET_HOME_DIR 1017
+#define IDC_BIN_PATH 1018
+#define IDC_HOME_DIR 1019
+#define IDC_USERLIST 1020
+#define IDC_LOAD_KEY_BUTTON 1022
+#define ID_OK 1023
+#define ID_LOD_FROM_FILE 1024
+#define ID_LOAD_FROM_FILE 1024
+#define IDC_EDIT1 1025
+#define IDC_PUBLIC_KEY_EDIT 1025
+#define IDC_KEY_PASSWORD 1025
+#define IDC_IN_OPEN_TAG 1025
+#define IDC_KEY_PASSWD 1025
+#define IDC_PASSWORD 1025
+#define IDC_LOG_FILE_EDIT 1025
+#define IDC_BUTTON1 1026
+#define IDC_SAVE_KEY_BUTTON 1026
+#define IDC_GENERATE_KEY 1026
+#define IDC_IGNORE_KEY 1026
+#define IDC_SELECT_EXISTING 1026
+#define IDC_KEY_EMAIL 1026
+#define IDC_DELETE_KEY_BUTTON 1027
+#define IDC_IN_CLOSE_TAG 1027
+#define IDC_KEY_REAL_NAME 1027
+#define IDC_KEY_LIST 1028
+#define IDC_KEY_COMMENT 1028
+#define IDC_OUT_OPEN_TAG 1029
+#define IDC_APPEND_TAGS 1030
+#define IDC_OUT_CLOSE_TAG 1031
+#define IDC_SELECT_KEY 1033
+#define IDC_MESSAGE 1034
+#define ID_IMPORT 1035
+#define IDC_IMPORT_AND_USE 1036
+#define IDC_KEY_TYPE 1039
+#define IDC_KEY_LENGTH 1040
+#define IDC_KEY_EXPIRE_DATE 1043
+#define IDC_EXISTING_KEY_LIST 1045
+#define IDC_BUTTON2 1046
+#define IDC_OTHER 1046
+#define IDC_LOG_FILE_SET 1046
+#define IDC_IMPORT 1046
+#define IDC_SAVE_PASSWORD 1047
+#define IDC_DEBUG_LOG 1048
+#define IDC_JABBER_API 1049
+#define IDC_ENABLE_ENCRYPTION 1050
+#define IDC_KEY_FROM 1051
+#define IDC_DELETE_KEY 1052
+#define IDC_KEYID 1053
+#define IDC_CURRENT_KEY 1054
+#define IDC_DEFAULT_PASSWORD 1055
+#define IDC_KEYSERVER 1058
+#define IDC_FILE_TRANSFERS 1061
+#define IDC_REMOVE_FILTERS 1062
+#define IDC_GENERATE_RANDOM 1063
+#define IDC_AUTO_EXCHANGE 1064
+#define IDC_AUT_EXCHANGE 1065
+#define IDC_BUTTON3 1066
+#define IDC_COPY_KEY 1066
+#define IDC_STRIP_TAGS 1067
+#define IDC_CHECK1 1068
+#define IDC_PRESCENSE_SUBSCRIPTION 1068
+#define IDC_GENERATING_KEY 1069
+#define IDC_GENERATING_TEXT 1070
+#define IDC_KEY_ID 1071
+#define IDC_COMBO1 1072
+#define IDC_ACCOUNT 1072
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 114
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1073
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
@@ -1,4 +1,4 @@ -// Copyright © 2010 SecureIM developers (baloo and others), sss
+// Copyright © 2010-2012 SecureIM developers (baloo and others), sss
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -34,9 +34,12 @@ int __cdecl onWindowEvent(WPARAM wParam, LPARAM lParam) { int __cdecl onIconPressed(WPARAM wParam, LPARAM lParam) {
HANDLE hContact = (HANDLE)wParam;
- HANDLE hMeta = hContact;
+ HANDLE hMeta = NULL;
if(metaIsProtoMetaContacts(hContact))
+ {
+ hMeta = hContact;
hContact = metaGetMostOnline(hContact); // âîçüìåì òîò, ÷åðåç êîòîðûé ïîéäåò ñîîáùåíèå
+ }
else if(metaIsSubcontact(hContact))
hMeta = metaGetContact(hContact);
StatusIconClickData *sicd = (StatusIconClickData *)lParam;
@@ -50,7 +53,7 @@ int __cdecl onIconPressed(WPARAM wParam, LPARAM lParam) { if(enc)
{
DBWriteContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", 0);
- DBWriteContactSettingByte(hMeta, szGPGModuleName, "GPGEncryption", 0);
+ hMeta?DBWriteContactSettingByte(hMeta, szGPGModuleName, "GPGEncryption", 0):0;
setSrmmIcon(hContact);
setClistIcon(hContact);
}
@@ -68,7 +71,7 @@ int __cdecl onIconPressed(WPARAM wParam, LPARAM lParam) { else
{
DBWriteContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", 1);
- DBWriteContactSettingByte(hMeta, szGPGModuleName, "GPGEncryption", 1);
+ hMeta?DBWriteContactSettingByte(hMeta, szGPGModuleName, "GPGEncryption", 1):0;
setSrmmIcon(hContact);
setClistIcon(hContact);
return 0;
@@ -76,7 +79,7 @@ int __cdecl onIconPressed(WPARAM wParam, LPARAM lParam) { if(isContactHaveKey(hContact))
{
DBWriteContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", 1);
- DBWriteContactSettingByte(hMeta, szGPGModuleName, "GPGEncryption", 1);
+ hMeta?DBWriteContactSettingByte(hMeta, szGPGModuleName, "GPGEncryption", 1):0;
setSrmmIcon(hContact);
setClistIcon(hContact);
}
diff --git a/utilities.cpp b/utilities.cpp index dbf8786..2207213 100644..100755 --- a/utilities.cpp +++ b/utilities.cpp @@ -1,4 +1,4 @@ -// Copyright © 2010 sss +// Copyright © 2010-2012 sss // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -195,8 +195,23 @@ int SendKey(WPARAM w, LPARAM l) HANDLE hContact = (HANDLE)w; if(metaIsProtoMetaContacts(hContact)) hContact = metaGetMostOnline(hContact); - char *szMessage = UniGetContactSettingUtf(NULL, szGPGModuleName, "GPGPubKey", ""); - if(strlen(szMessage) > 1) + char *szMessage; + { + char *proto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + char setting[64]; + if(proto) + { + strcpy(setting, proto); + strcat(setting, "_GPGPubKey"); + szMessage = UniGetContactSettingUtf(NULL, szGPGModuleName, setting, ""); + } + if(!szMessage[0]) + { + mir_free(szMessage); + szMessage = UniGetContactSettingUtf(NULL, szGPGModuleName, "GPGPubKey", ""); + } + } + if(szMessage[0]) { BYTE enc = DBGetContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", 0); DBWriteContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", 0); @@ -234,7 +249,7 @@ int ToggleEncryption(WPARAM w, LPARAM l) } } else - DBWriteContactSettingByte(metaGetMostOnline(hContact), szGPGModuleName, "GPGEncryption", enc?0:1); + DBWriteContactSettingByte(hContact, szGPGModuleName, "GPGEncryption", enc?0:1); void setSrmmIcon(HANDLE hContact); void setClistIcon(HANDLE hContact); setSrmmIcon(hContact); @@ -275,171 +290,195 @@ extern bool bFileTransfers; int onProtoAck(WPARAM w, LPARAM l) { - if(!bFileTransfers) - return 0; ACKDATA *ack=(ACKDATA*)l; CCSDATA *ccs=(CCSDATA*)ack->lParam; - if (ack->type!=ACKTYPE_FILE) - return 0; - - switch(ack->result) + + if(ack->type == ACKTYPE_FILE && bFileTransfers) { - case ACKRESULT_DENIED: case ACKRESULT_FAILED: - break; - case ACKRESULT_SUCCESS: + switch(ack->result) { - PROTOFILETRANSFERSTATUS *f = (PROTOFILETRANSFERSTATUS*) ack->hProcess; - TCHAR *filename = NULL; - if(f->flags & PFTS_UNICODE) - { - if(f->tszCurrentFile && f->tszCurrentFile[0]) - filename = mir_wstrdup(f->tszCurrentFile); - if(!filename) - return 0; - } - else + case ACKRESULT_DENIED: case ACKRESULT_FAILED: + break; + case ACKRESULT_SUCCESS: { - if(f->szCurrentFile && f->szCurrentFile[0]) - filename = mir_utf8decodeT(f->szCurrentFile); - if(!filename) - return 0; - } - if(_tcsstr(filename, _T(".gpg"))) //decrypt it - { //process encrypted file - if(_waccess(f->tszCurrentFile, 0) == -1) + PROTOFILETRANSFERSTATUS *f = (PROTOFILETRANSFERSTATUS*) ack->hProcess; + TCHAR *filename = NULL; + if(f->flags & PFTS_UNICODE) { - if(errno == ENOENT) + if(f->tszCurrentFile && f->tszCurrentFile[0]) + filename = mir_wstrdup(f->tszCurrentFile); + if(!filename) return 0; } - string out; - DWORD code; - pxResult result; - wstring cmd = _T("-o "); - wstring file = filename; - wstring::size_type p1 = file.rfind(_T(".gpg")); - file.erase(p1, _tcslen(_T(".gpg"))); - if(_waccess(file.c_str(), 0) != -1) + else { - if(MessageBox(0, _T("Target file exists, do you want to replace it ?"), _T("Warning"), MB_YESNO) == IDNO) + if(f->szCurrentFile && f->szCurrentFile[0]) + filename = mir_utf8decodeT(f->szCurrentFile); + if(!filename) return 0; } - DeleteFile(file.c_str()); - file.insert(0, _T("\"")); - file.insert(file.length(), _T("\" ")); - cmd += file; - cmd += _T(" -d \""); - cmd += filename; - cmd += _T("\""); - extern TCHAR *password; - { // password - TCHAR *pass = NULL; - char *keyid = UniGetContactSettingUtf(ccs->hContact, szGPGModuleName, "KeyID", ""); - if(strlen(keyid) > 0) - { - string dbsetting = "szKey_"; - dbsetting += keyid; - dbsetting += "_Password"; - pass = UniGetContactSettingUtf(NULL, szGPGModuleName, dbsetting.c_str(), _T("")); - if(_tcslen(pass) > 0) - debuglog<<time_str()<<": info: found password in database for key id: "<<keyid<<", trying to decrypt message from "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR)<<" with password\n"; - } - else - { - pass = UniGetContactSettingUtf(NULL, szGPGModuleName, "szKeyPassword", _T("")); - if(_tcslen(pass) > 0) - debuglog<<time_str()<<": info: found password for all keys in database, trying to decrypt message from "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR)<<" with password\n"; - } - if(_tcslen(pass) > 0) + if(_tcsstr(filename, _T(".gpg"))) //decrypt it + { //process encrypted file + if(_waccess(f->tszCurrentFile, 0) == -1) { - cmd += _T("--passphrase \""); - cmd += pass; - cmd += _T("\" "); + if(errno == ENOENT) + return 0; } - else if(password) + string out; + DWORD code; + pxResult result; + wstring cmd = _T(" -o "); + wstring file = filename; + wstring::size_type p1 = file.rfind(_T(".gpg")); + file.erase(p1, _tcslen(_T(".gpg"))); + if(_waccess(file.c_str(), 0) != -1) { - debuglog<<time_str()<<": info: found password in memory, trying to decrypt message from "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR)<<" with password\n"; - cmd += _T("--passphrase \""); - cmd += password; - cmd += _T("\" "); - } - else - debuglog<<time_str()<<": info: passwords not found in database or memory, trying to decrypt message from "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR)<<" with out password\n"; - mir_free(pass); - mir_free(keyid); - } - gpg_execution_params params; - params.cmd = &cmd; - params.useless = ""; - params.out = &out; - params.code = &code; - params.result = &result; - boost::thread *gpg_thread = new boost::thread(boost::bind(&pxEexcute_thread, ¶ms)); - if(!gpg_thread->timed_join(boost::posix_time::minutes(15))) - { - delete gpg_thread; - TerminateProcess(params.hProcess, 1); - params.hProcess = NULL; - debuglog<<time_str()<<": GPG execution timed out, aborted\n"; - return 0; - } - while(out.find("public key decryption failed: bad passphrase") != string::npos) - { - extern bool _terminate; - extern HANDLE new_key_hcnt; - extern boost::mutex new_key_hcnt_mutex; - debuglog<<time_str()<<": info: failed to decrypt messaage from "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR)<<" password needed, trying to get one\n"; - if(_terminate) - break; - { //save inkey id - string::size_type s = out.find(" encrypted with "); - s = out.find(" ID ", s); - s += strlen(" ID "); - string::size_type s2 = out.find(",",s); - DBWriteContactSettingString(metaGetMostOnline(ccs->hContact), szGPGModuleName, "InKeyID", out.substr(s, s2-s).c_str()); + if(MessageBox(0, _T("Target file exists, do you want to replace it ?"), _T("Warning"), MB_YESNO) == IDNO) + return 0; } - void ShowLoadKeyPasswordWindow(); - new_key_hcnt_mutex.lock(); - new_key_hcnt = ccs->hContact; - ShowLoadKeyPasswordWindow(); - wstring cmd2 = cmd; - if(password) - { - debuglog<<time_str()<<": info: found password in memory, trying to decrypt message from "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ccs->hContact, GCDNF_TCHAR)<<"\n"; - wstring tmp = _T("--passphrase \""); - tmp += password; - tmp += _T("\" "); - cmd2.insert(0, tmp); + DeleteFile(file.c_str()); + file.insert(0, _T("\"")); + file.insert(file.length(), _T("\" ")); + cmd += file; + extern TCHAR *password; + { // password + TCHAR *pass = NULL; + char *keyid = UniGetContactSettingUtf(ack->hContact, szGPGModuleName, "KeyID", ""); + if(strlen(keyid) > 0) + { + string dbsetting = "szKey_"; + dbsetting += keyid; + dbsetting += "_Password"; + pass = UniGetContactSettingUtf(NULL, szGPGModuleName, dbsetting.c_str(), _T("")); + if(_tcslen(pass) > 0) + debuglog<<time_str()<<": info: found password in database for key id: "<<keyid<<", trying to decrypt message from "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ack->hContact, GCDNF_TCHAR)<<" with password\n"; + } + else + { + pass = UniGetContactSettingUtf(NULL, szGPGModuleName, "szKeyPassword", _T("")); + if(_tcslen(pass) > 0) + debuglog<<time_str()<<": info: found password for all keys in database, trying to decrypt message from "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ack->hContact, GCDNF_TCHAR)<<" with password\n"; + } + if(_tcslen(pass) > 0) + { + cmd += _T("--passphrase \""); + cmd += pass; + cmd += _T("\" "); + } + else if(password) + { + debuglog<<time_str()<<": info: found password in memory, trying to decrypt message from "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ack->hContact, GCDNF_TCHAR)<<" with password\n"; + cmd += _T("--passphrase \""); + cmd += password; + cmd += _T("\" "); + } + else + debuglog<<time_str()<<": info: passwords not found in database or memory, trying to decrypt message from "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ack->hContact, GCDNF_TCHAR)<<" with out password\n"; + mir_free(pass); + mir_free(keyid); } - out.clear(); + cmd += _T(" -d \""); + cmd += filename; + cmd += _T("\""); gpg_execution_params params; - pxResult result; - params.cmd = &cmd2; + params.cmd = &cmd; params.useless = ""; params.out = &out; params.code = &code; params.result = &result; - gpg_thread = gpg_thread = new boost::thread(boost::bind(&pxEexcute_thread, ¶ms)); - if(!gpg_thread->timed_join(boost::posix_time::seconds(15))) + boost::thread *gpg_thread = new boost::thread(boost::bind(&pxEexcute_thread, ¶ms)); + if(!gpg_thread->timed_join(boost::posix_time::minutes(15))) { delete gpg_thread; TerminateProcess(params.hProcess, 1); params.hProcess = NULL; debuglog<<time_str()<<": GPG execution timed out, aborted\n"; - DeleteFile(filename); return 0; } - if(result == pxNotFound) + while(out.find("public key decryption failed: bad passphrase") != string::npos) { - DeleteFile(filename); - return 0; + extern bool _terminate; + extern HANDLE new_key_hcnt; + extern boost::mutex new_key_hcnt_mutex; + debuglog<<time_str()<<": info: failed to decrypt messaage from "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ack->hContact, GCDNF_TCHAR)<<" password needed, trying to get one\n"; + if(_terminate) + break; + { //save inkey id + string::size_type s = out.find(" encrypted with "); + s = out.find(" ID ", s); + s += strlen(" ID "); + string::size_type s2 = out.find(",",s); + if(metaIsProtoMetaContacts(ack->hContact)) + DBWriteContactSettingString(metaGetMostOnline(ack->hContact), szGPGModuleName, "InKeyID", out.substr(s, s2-s).c_str()); + else + DBWriteContactSettingString(ack->hContact, szGPGModuleName, "InKeyID", out.substr(s, s2-s).c_str()); + } + void ShowLoadKeyPasswordWindow(); + new_key_hcnt_mutex.lock(); + new_key_hcnt = ack->hContact; + ShowLoadKeyPasswordWindow(); + wstring cmd2 = cmd; + if(password) + { + debuglog<<time_str()<<": info: found password in memory, trying to decrypt message from "<<(TCHAR*)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)ack->hContact, GCDNF_TCHAR)<<"\n"; + wstring tmp = _T("--passphrase \""); + tmp += password; + tmp += _T("\" "); + cmd2.insert(0, tmp); + } + out.clear(); + gpg_execution_params params; + pxResult result; + params.cmd = &cmd2; + params.useless = ""; + params.out = &out; + params.code = &code; + params.result = &result; + gpg_thread = gpg_thread = new boost::thread(boost::bind(&pxEexcute_thread, ¶ms)); + if(!gpg_thread->timed_join(boost::posix_time::seconds(15))) + { + delete gpg_thread; + TerminateProcess(params.hProcess, 1); + params.hProcess = NULL; + debuglog<<time_str()<<": GPG execution timed out, aborted\n"; + DeleteFile(filename); + return 0; + } + if(result == pxNotFound) + { + DeleteFile(filename); + return 0; + } } - } - DeleteFile(filename); - mir_free(filename); + DeleteFile(filename); + mir_free(filename); } } break; } + } + else if(ack->type == ACKTYPE_MESSAGE) + { + extern std::list<HANDLE> sent_msgs; + if(!sent_msgs.empty()) + { + if(ack->result == ACKRESULT_FAILED) + { + std::list<HANDLE>::iterator it = std::find(sent_msgs.begin(), sent_msgs.end(), ack->hProcess); + if(it != sent_msgs.end()) + { + HistoryLog(ack->hContact, db_event("Failed to send encrypted message", 0,0, 0)); + + } + } + else if(ack->result == ACKRESULT_SUCCESS) + { + std::list<HANDLE>::iterator it = std::find(sent_msgs.begin(), sent_msgs.end(), ack->hProcess); + if(it != sent_msgs.end()) + sent_msgs.erase(it); + } + } + } return 0; } @@ -448,10 +487,9 @@ std::wstring encrypt_file(HANDLE hContact, TCHAR *filename) string out; DWORD code; pxResult result; + HANDLE hcnt = metaIsProtoMetaContacts(hContact)?metaGetMostOnline(hContact):hContact; wstring cmd = _T("--batch --yes -r "); - char *keyid = UniGetContactSettingUtf(hContact, szGPGModuleName, "KeyID", ""); - if(DBGetContactSettingByte(hContact, szGPGModuleName, "bAlwaysTrust", 0)) - cmd += _T("--trust-model always "); + char *keyid = UniGetContactSettingUtf(hcnt, szGPGModuleName, "KeyID", ""); TCHAR *szKeyid = mir_a2t(keyid); TCHAR *name = _tcsrchr(filename,_T('\\')); if( !name ) @@ -461,6 +499,8 @@ std::wstring encrypt_file(HANDLE hContact, TCHAR *filename) TCHAR *file_out = new TCHAR [_tcslen(filename)+4]; mir_sntprintf(file_out, _tcslen(name)+7, _T("%s.gpg"), name); cmd += szKeyid; + if(DBGetContactSettingByte(hcnt, szGPGModuleName, "bAlwaysTrust", 0)) + cmd += _T(" --trust-model always "); mir_free(szKeyid); mir_free(keyid); cmd += _T(" -o \""); @@ -499,7 +539,7 @@ std::wstring encrypt_file(HANDLE hContact, TCHAR *filename) out.clear(); if(MessageBox(0, _T("We trying to encrypt with untrusted key, do you want to trust this key permanently ?"), _T("Warning"), MB_YESNO) == IDYES) { - DBWriteContactSettingByte(hContact, szGPGModuleName, "bAlwaysTrust", 1); + DBWriteContactSettingByte(hcnt, szGPGModuleName, "bAlwaysTrust", 1); cmd.insert(0, _T("--trust-model always ")); gpg_thread = new boost::thread(boost::bind(&pxEexcute_thread, ¶ms)); if(!gpg_thread->timed_join(boost::posix_time::seconds(180))) @@ -528,7 +568,8 @@ int onSendFile(WPARAM w, LPARAM l) DWORD flags = (DWORD)ccs->wParam; //check for PFTS_UNICODE here int i; - if(flags & PFTS_UNICODE) +// if(flags & PFTS_UNICODE) //this does not work .... + if(StriStr(ccs->szProtoService, "/sendfilew")) { TCHAR **file=(TCHAR **)ccs->lParam; for(i = 0; file[i]; i++) @@ -692,7 +733,7 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void *pU return FALSE; } } - if(nodename) + if(bPresenceSigning && nodename) { if(_tcsstr(nodename, _T("status"))) { @@ -720,7 +761,19 @@ static JABBER_HANDLER_FUNC SendHandler(IJabberInterface *ji, HXML node, void *pU DWORD code; wstring cmd; { - char *inkeyid = UniGetContactSettingUtf(NULL, szGPGModuleName, "KeyID", ""); + char *inkeyid; + { + char *proto = ji->Sys()->GetModuleName(); + char setting[64]; + strcpy(setting, proto); + strcat(setting, "_KeyID"); + inkeyid = UniGetContactSettingUtf(NULL, szGPGModuleName, setting, ""); + if(!inkeyid[0]) + { + mir_free(inkeyid); + inkeyid = UniGetContactSettingUtf(NULL, szGPGModuleName, "KeyID", ""); + } + } TCHAR *pass = NULL; if(inkeyid[0]) { @@ -967,8 +1020,8 @@ void AddHandlers() (*p)->setSendHandler((*p)->getJabberInterface()->Net()->AddSendHandler((JABBER_HANDLER_FUNC)SendHandler)); if((*p)->getPrescenseHandler() == INVALID_HANDLE_VALUE) (*p)->setPrescenseHandler((*p)->getJabberInterface()->Net()->AddPresenceHandler((JABBER_HANDLER_FUNC)PrescenseHandler)); - if((*p)->getMessageHandler() == INVALID_HANDLE_VALUE) - (*p)->setMessageHandler((*p)->getJabberInterface()->Net()->AddMessageHandler((JABBER_HANDLER_FUNC)MessageHandler, JABBER_MESSAGE_TYPE_ERROR,0 ,0)); +// if((*p)->getMessageHandler() == INVALID_HANDLE_VALUE) +// (*p)->setMessageHandler((*p)->getJabberInterface()->Net()->AddMessageHandler((JABBER_HANDLER_FUNC)MessageHandler, JABBER_MESSAGE_TYPE_ANY ,NULL,NULL)); if(bAutoExchange) { (*p)->getJabberInterface()->Net()->RegisterFeature(_T("GPG_Key_Auto_Exchange:0"), _T("Indicates that gpg installed and configured to public key auto exchange (currently implemented in new_gpg Miranda IM plugin)")); @@ -1012,7 +1065,7 @@ bool isContactHaveKey(HANDLE hContact) return false; } -bool isGPGConfigured() +bool isGPGKeyExist() { TCHAR *id = UniGetContactSettingUtf(NULL, szGPGModuleName, "KeyID", _T("")); char *key = UniGetContactSettingUtf(NULL, szGPGModuleName, "GPGPubKey", ""); @@ -1026,6 +1079,74 @@ bool isGPGConfigured() mir_free(key); return false; } +bool isGPGValid() +{ + TCHAR *tmp; + bool gpg_exists = false, is_valid = true; + tmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "szGpgBinPath", _T("")); + if(_waccess(tmp, 0) != -1) + gpg_exists = true; + else + { + mir_free(tmp); + TCHAR *path = new TCHAR [MAX_PATH]; + char *mir_path = new char [MAX_PATH]; + CallService(MS_UTILS_PATHTOABSOLUTE, (WPARAM)"\\", (LPARAM)mir_path); + SetCurrentDirectoryA(mir_path); + tmp = mir_a2t(mir_path); + mir_free(mir_path); + mir_realloc(path, (_tcslen(path)+128)*sizeof(TCHAR)); + TCHAR *gpg_path = new TCHAR [MAX_PATH]; + _tcscpy(gpg_path, tmp); + _tcscat(gpg_path, _T("\\GnuPG\\gpg.exe")); + mir_free(tmp); + if(_waccess(gpg_path, 0) != -1) + { + gpg_exists = true; + _tcscpy(path, _T("GnuPG\\gpg.exe")); + } + mir_free(gpg_path); + tmp = mir_wstrdup(path); + delete [] path; + } + DWORD len = MAX_PATH; + if(gpg_exists) + { + DBWriteContactSettingTString(NULL, szGPGModuleName, "szGpgBinPath", tmp); + string out; + DWORD code; + wstring cmd = _T("--version"); + gpg_execution_params params; + pxResult result; + params.cmd = &cmd; + params.useless = ""; + params.out = &out; + params.code = &code; + params.result = &result; + gpg_valid = true; + 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"; + } + gpg_valid = false; + string::size_type p1 = out.find("(GnuPG) "); + if(p1 == string::npos) + is_valid = false; + } + mir_free(tmp); + if(!gpg_exists) + { + wstring path_ = _wgetenv(_T("APPDATA")); + path_ += _T("\\GnuPG"); + tmp = UniGetContactSettingUtf(NULL, szGPGModuleName, "szHomePath", (TCHAR*)path_.c_str()); + } + mir_free(tmp); + return is_valid; +} #define NEWTSTR_MALLOC(A) (A==NULL)?NULL:strcpy((char*)mir_alloc(sizeof(char)*(strlen(A)+1)),A) @@ -1117,7 +1238,14 @@ int returnNoError(HANDLE hContact) { string toUTF8(wstring str) { string ustr; + try{ utf8::utf16to8(str.begin(), str.end(), back_inserter(ustr)); + } + catch(const utf8::exception& e) + { + debuglog<<std::string("utf8cpp encoding exception: ")+(char*)e.what(); + //TODO + } return ustr; } @@ -1127,8 +1255,15 @@ wstring toUTF16(string str) //convert as much as possible { wstring ustr; string tmpstr; + try{ utf8::replace_invalid(str.begin(), str.end(), back_inserter(tmpstr)); utf8::utf8to16(tmpstr.begin(), tmpstr.end(), back_inserter(ustr)); + } + catch(const utf8::exception& e) + { + debuglog<<std::string("utf8cpp decoding exception: ")+(char*)e.what(); + //TODO + } return ustr; } @@ -1154,13 +1289,14 @@ void send_encrypted_msgs_thread(HANDLE hContact) { boost::this_thread::sleep(boost::posix_time::seconds(1)); list<string>::iterator end = hcontact_data[hContact].msgs_to_send.end(); + extern std::list<HANDLE> sent_msgs; for(list<string>::iterator p = hcontact_data[hContact].msgs_to_send.begin(); p != end; ++p) { - CallContactService(hContact, PSS_MESSAGE, (WPARAM)PREF_UTF, (LPARAM)p->c_str()); - + sent_msgs.push_back((HANDLE)CallContactService(hContact, PSS_MESSAGE, (WPARAM)PREF_UTF, (LPARAM)p->c_str())); HistoryLog(hContact, db_event((char*)p->c_str(),0,0, DBEF_SENT)); boost::this_thread::sleep(boost::posix_time::seconds(1)); } + hcontact_data[hContact].msgs_to_send.clear(); return; } else @@ -1173,3 +1309,515 @@ string time_str() boost::posix_time::ptime now = boost::posix_time::second_clock::local_time(); return (string)boost::posix_time::to_simple_string(now); } + +int handleEnum(const char *szSetting, LPARAM lParam) +{ + if(!*(bool*)lParam && szSetting[0] && StriStr(szSetting, "tabsrmm")) + { + bool f = false, *found = (bool*)lParam; + f = !DBGetContactSettingByte(NULL, "PluginDisable", szSetting, 0); + if(f) + *found = f; + } + return 0; +} + +bool isTabsrmmUsed() +{ + DBCONTACTENUMSETTINGS enm = {0}; + bool found = false; + enm.lParam = (LPARAM)&found; + enm.pfnEnumProc = (DBSETTINGENUMPROC)&handleEnum; + enm.szModule = "PluginDisable"; + if(CallService(MS_DB_CONTACT_ENUMSETTINGS, (WPARAM)NULL, (LPARAM)&enm) == -1) + return false; + + return found; +} + + +int ExportGpGKeys(WPARAM w, LPARAM l) +{ + TCHAR *p = GetFilePath(_T("Choose file to export public keys"), _T("*"), _T("Any file"), true); + if(!p || !p[0]) + { + delete [] p; + //TODO: handle error + return 1; + } + char *path = mir_t2a(p); + delete [] p; + std::ofstream file; + file.open(path, std::ios::trunc | std::ios::out); + mir_free(path); + int exported_keys = 0; + if(!file.is_open()) + return 1; //TODO: handle error + for(HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); hContact; hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0)) + { + char *k = UniGetContactSettingUtf(hContact, szGPGModuleName, "GPGPubKey", ""); + if(!k[0]) + { + mir_free(k); + continue; + } + std::string key = k; + mir_free(k); + + const char* proto = (const char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); + std::string id = "Comment: login "; + const char * uid = (const char*)CallProtoService(proto, PS_GETCAPS, (WPARAM)PFLAG_UNIQUEIDSETTING, 0); + DBVARIANT dbv = {0}; + DBCONTACTGETSETTING dbcgs = {0}; + dbcgs.pValue = &dbv; + dbcgs.szModule = proto; + dbcgs.szSetting = uid; + CallService(MS_DB_CONTACT_GETSETTING, 0, (LPARAM)&dbcgs); + switch(dbcgs.pValue->type) + { + case DBVT_DELETED: + continue; + break; + case DBVT_BYTE: + { + char _id[64]; + mir_snprintf(_id, 63, "%d", dbcgs.pValue->bVal); + id += _id; + } + break; + case DBVT_WORD: + { + char _id[64]; + mir_snprintf(_id, 63, "%d", dbcgs.pValue->wVal); + id += _id; + } + break; + case DBVT_DWORD: + { + char _id[64]; + mir_snprintf(_id, 63, "%d", dbcgs.pValue->dVal); + id += _id; + } + break; + case DBVT_ASCIIZ: + { + id += dbcgs.pValue->pszVal; + CallService(MS_DB_CONTACT_FREEVARIANT, 0, (LPARAM)&dbv); + } + break; + case DBVT_UTF8: + { + char *tmp = mir_utf8decodeA(dbcgs.pValue->pszVal); + if(tmp[0]) + id += tmp; + mir_free(tmp); + CallService(MS_DB_CONTACT_FREEVARIANT, 0, (LPARAM)&dbv); + } + break; + case DBVT_BLOB: + //TODO + CallService(MS_DB_CONTACT_FREEVARIANT, 0, (LPARAM)&dbv); + break; + case DBVT_WCHAR: + //TODO + CallService(MS_DB_CONTACT_FREEVARIANT, 0, (LPARAM)&dbv); + break; + } + id += " contact_id "; + ZeroMemory(&dbv, sizeof(dbv)); + ZeroMemory(&dbcgs, sizeof(dbcgs)); + dbcgs.pValue = &dbv; + dbcgs.szModule = proto; + dbcgs.szSetting = uid; + CallService(MS_DB_CONTACT_GETSETTING, (WPARAM)hContact, (LPARAM)&dbcgs); + switch(dbcgs.pValue->type) + { + case DBVT_DELETED: + continue; + break; + case DBVT_BYTE: + { + char _id[64]; + mir_snprintf(_id, 63, "%d", dbcgs.pValue->bVal); + id += _id; + } + break; + case DBVT_WORD: + { + char _id[64]; + mir_snprintf(_id, 63, "%d", dbcgs.pValue->wVal); + id += _id; + } + break; + case DBVT_DWORD: + { + char _id[64]; + mir_snprintf(_id, 63, "%d", dbcgs.pValue->dVal); + id += _id; + } + break; + case DBVT_ASCIIZ: + { + id += dbcgs.pValue->pszVal; + CallService(MS_DB_CONTACT_FREEVARIANT, 0, (LPARAM)&dbv); + } + break; + case DBVT_UTF8: + { + char *tmp = mir_utf8decodeA(dbcgs.pValue->pszVal); + if(tmp[0]) + id += tmp; + mir_free(tmp); + CallService(MS_DB_CONTACT_FREEVARIANT, 0, (LPARAM)&dbv); + } + break; + case DBVT_BLOB: + //TODO + CallService(MS_DB_CONTACT_FREEVARIANT, 0, (LPARAM)&dbv); + break; + case DBVT_WCHAR: + //TODO + CallService(MS_DB_CONTACT_FREEVARIANT, 0, (LPARAM)&dbv); + break; + } + std::string::size_type p1 = key.find("-----BEGIN PGP PUBLIC KEY BLOCK-----"); + if(p1 == std::string::npos) + continue; + p1 += strlen("-----BEGIN PGP PUBLIC KEY BLOCK-----"); + p1 ++; + id += '\n'; + key.insert(p1, id); + file<<key; + file<<std::endl; + exported_keys++; + } + if(file.is_open()) + file.close(); + char msg[512]; + mir_snprintf(msg, 511, "we have succesfully exported %d keys", exported_keys); + MessageBoxA(NULL, msg, Translate("Keys export result"), MB_OK); + return 0; +} + +int ImportGpGKeys(WPARAM w, LPARAM l) +{ + TCHAR *p = GetFilePath(_T("Choose file to import keys from"), _T("*"), _T("Any file")); + if(!p || !p[0]) + { + delete [] p; + //TODO: handle error + return 1; + } + char *path = mir_t2a(p); + delete [] p; + std::ifstream file; + file.open(path, std::ios::in); + mir_free(path); + if(!file.is_open()) + return 1; //TODO: handle error + PROTOACCOUNT **accs; + int acc_count = 0, processed_keys = 0; + ProtoEnumAccounts(&acc_count, &accs); + char line[256]; + file.getline(line, 255); + if(!strstr(line, "-----BEGIN PGP PUBLIC KEY BLOCK-----")) + return 1; //TODO: handle error + std::string key, login, contact_id; + key += line; + key += '\n'; + while(file.is_open() && !file.eof()) + { + file.getline(line, 255); + key += line; + key += '\n'; + if(strstr(line, "-----END PGP PUBLIC KEY BLOCK-----")) + { //TODO: parse key + std::string::size_type p1 = 0, p2 = 0; + p1 = key.find("Comment: login "); + p1 += strlen("Comment: login "); + p2 = key.find(" contact_id "); + login = key.substr(p1, p2-p1); + p2 += strlen(" contact_id "); + p1 = key.find("\n", p2); + contact_id = key.substr(p2, p1-p2); + p1 = key.find("Comment: login "); + p2 = key.find("\n", p1); + p2++; + key.erase(p1, p2-p1); + std::string acc; + for(int i = 0; i < acc_count; i++) + { + if(acc.length()) + break; + const char * uid = (const char*)CallProtoService(accs[i]->szModuleName, PS_GETCAPS, (WPARAM)PFLAG_UNIQUEIDSETTING, 0); + DBVARIANT dbv = {0}; + DBCONTACTGETSETTING dbcgs = {0}; + dbcgs.pValue = &dbv; + dbcgs.szModule = accs[i]->szModuleName; + dbcgs.szSetting = uid; + CallService(MS_DB_CONTACT_GETSETTING, 0, (LPARAM)&dbcgs); + std::string id; + switch(dbcgs.pValue->type) + { + case DBVT_DELETED: + continue; + break; + case DBVT_BYTE: + { + char _id[64]; + mir_snprintf(_id, 63, "%d", dbcgs.pValue->bVal); + id += _id; + if(id == login) + acc = accs[i]->szModuleName; + } + break; + case DBVT_WORD: + { + char _id[64]; + mir_snprintf(_id, 63, "%d", dbcgs.pValue->wVal); + id += _id; + if(id == login) + acc = accs[i]->szModuleName; + } + break; + case DBVT_DWORD: + { + char _id[64]; + mir_snprintf(_id, 63, "%d", dbcgs.pValue->dVal); + id += _id; + if(id == login) + acc = accs[i]->szModuleName; + } + break; + case DBVT_ASCIIZ: + { + id += dbcgs.pValue->pszVal; + CallService(MS_DB_CONTACT_FREEVARIANT, 0, (LPARAM)&dbv); + if(id == login) + acc = accs[i]->szModuleName; + } + break; + case DBVT_UTF8: + { + char *tmp = mir_utf8decodeA(dbcgs.pValue->pszVal); + if(tmp[0]) + id += tmp; + mir_free(tmp); + CallService(MS_DB_CONTACT_FREEVARIANT, 0, (LPARAM)&dbv); + if(id == login) + acc = accs[i]->szModuleName; + } + break; + case DBVT_BLOB: + //TODO + CallService(MS_DB_CONTACT_FREEVARIANT, 0, (LPARAM)&dbv); + break; + case DBVT_WCHAR: + //TODO + CallService(MS_DB_CONTACT_FREEVARIANT, 0, (LPARAM)&dbv); + break; + } + } + if(acc.length()) + { + const char * uid = (const char*)CallProtoService(acc.c_str(), PS_GETCAPS, (WPARAM)PFLAG_UNIQUEIDSETTING, 0); + for(HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, (LPARAM)acc.c_str()); hContact; hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, (LPARAM)acc.c_str())) + { + DBVARIANT dbv = {0}; + DBCONTACTGETSETTING dbcgs = {0}; + dbcgs.pValue = &dbv; + dbcgs.szModule = acc.c_str(); + dbcgs.szSetting = uid; + CallService(MS_DB_CONTACT_GETSETTING, (WPARAM)hContact, (LPARAM)&dbcgs); + std::string id; + bool found = false; + switch(dbcgs.pValue->type) + { + case DBVT_DELETED: + continue; + break; + case DBVT_BYTE: + { + char _id[64]; + mir_snprintf(_id, 63, "%d", dbcgs.pValue->bVal); + id += _id; + if(id == contact_id) + found = true; + } + break; + case DBVT_WORD: + { + char _id[64]; + mir_snprintf(_id, 63, "%d", dbcgs.pValue->wVal); + id += _id; + if(id == contact_id) + found = true; + } + break; + case DBVT_DWORD: + { + char _id[64]; + mir_snprintf(_id, 63, "%d", dbcgs.pValue->dVal); + id += _id; + if(id == contact_id) + found = true; + } + break; + case DBVT_ASCIIZ: + { + id += dbcgs.pValue->pszVal; + CallService(MS_DB_CONTACT_FREEVARIANT, 0, (LPARAM)&dbv); + if(id == contact_id) + found = true; + } + break; + case DBVT_UTF8: + { + char *tmp = mir_utf8decodeA(dbcgs.pValue->pszVal); + if(tmp[0]) + id += tmp; + mir_free(tmp); + CallService(MS_DB_CONTACT_FREEVARIANT, 0, (LPARAM)&dbv); + if(id == contact_id) + found = true; + } + break; + case DBVT_BLOB: + //TODO + CallService(MS_DB_CONTACT_FREEVARIANT, 0, (LPARAM)&dbv); + break; + case DBVT_WCHAR: + //TODO + CallService(MS_DB_CONTACT_FREEVARIANT, 0, (LPARAM)&dbv); + 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++; + { + 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; + } + } + } + key.clear(); + } + } + if(file.is_open()) + file.close(); + char msg[512]; + mir_snprintf(msg, 511, "we have succesfully processed %d keys", processed_keys); + MessageBoxA(NULL, msg, Translate("Keys import result"), MB_OK); + return 0; +}
\ No newline at end of file diff --git a/utilities.h b/utilities.h index 5922311..30e9f68 100644..100755 --- a/utilities.h +++ b/utilities.h @@ -1,4 +1,4 @@ -// Copyright © 2010 sss
+// Copyright © 2010-2012 sss
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -27,7 +27,9 @@ void storeOutput(HANDLE ahandle, string *output); int ComboBoxAddStringUtf(HWND hCombo, const TCHAR *szString, DWORD data);
bool isContactSecured(HANDLE hContact);
bool isContactHaveKey(HANDLE hContact);
-bool isGPGConfigured();
+bool isTabsrmmUsed();
+bool isGPGKeyExist();
+bool isGPGValid();
const bool StriStr(const char *str, const char *substr);
string toUTF8(wstring str);
wstring toUTF16(string str);
|