summaryrefslogtreecommitdiff
path: root/plugins/Dbx_mmap_SA
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2012-07-18 17:17:20 +0000
committerGeorge Hazan <george.hazan@gmail.com>2012-07-18 17:17:20 +0000
commit43987a12a08c3a656ba4401c727214096c046a5a (patch)
tree24098acc7172817a2e3b79fc5b792e44b88cb571 /plugins/Dbx_mmap_SA
parentd3a1b7b40f4bd53a467a5b15b426b6f3d6ea1088 (diff)
code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@1019 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Dbx_mmap_SA')
-rw-r--r--plugins/Dbx_mmap_SA/database.cpp2
-rw-r--r--plugins/Dbx_mmap_SA/db3x_mmap_sa_10.vcxproj1
-rw-r--r--plugins/Dbx_mmap_SA/db3x_mmap_sa_10.vcxproj.filters3
-rw-r--r--plugins/Dbx_mmap_SA/dbevents.cpp2
-rw-r--r--plugins/Dbx_mmap_SA/dbmodulechain.cpp2
-rw-r--r--plugins/Dbx_mmap_SA/dbpreset.cpp6
-rw-r--r--plugins/Dbx_mmap_SA/dbsettings.cpp2
-rw-r--r--plugins/Dbx_mmap_SA/dialogs.cpp557
-rw-r--r--plugins/Dbx_mmap_SA/security.cpp8
9 files changed, 269 insertions, 314 deletions
diff --git a/plugins/Dbx_mmap_SA/database.cpp b/plugins/Dbx_mmap_SA/database.cpp
index 288c7b898a..56c44850a1 100644
--- a/plugins/Dbx_mmap_SA/database.cpp
+++ b/plugins/Dbx_mmap_SA/database.cpp
@@ -30,7 +30,6 @@ int InitSettings(void);
void UninitSettings(void);
int InitContacts(void);
int InitEvents(void);
-int InitCrypt(void);
int InitModuleNames(void);
void UninitModuleNames(void);
int InitCache(void);
@@ -149,7 +148,6 @@ int LoadDatabaseModule(void)
if (InitContacts()) return 1;
if (InitSettings()) return 1;
if (InitEvents()) return 1;
- if (InitCrypt()) return 1;
if (InitPreset()) return 1;
if (InitDialogs()) return 1;
return 0;
diff --git a/plugins/Dbx_mmap_SA/db3x_mmap_sa_10.vcxproj b/plugins/Dbx_mmap_SA/db3x_mmap_sa_10.vcxproj
index 197f7668ba..5f6e6608a2 100644
--- a/plugins/Dbx_mmap_SA/db3x_mmap_sa_10.vcxproj
+++ b/plugins/Dbx_mmap_SA/db3x_mmap_sa_10.vcxproj
@@ -199,7 +199,6 @@
<ClCompile Include="dbpreset.cpp" />
<ClCompile Include="dbsettings.cpp" />
<ClCompile Include="dialogs.cpp" />
- <ClCompile Include="encrypt.cpp" />
<ClCompile Include="init.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
diff --git a/plugins/Dbx_mmap_SA/db3x_mmap_sa_10.vcxproj.filters b/plugins/Dbx_mmap_SA/db3x_mmap_sa_10.vcxproj.filters
index af0a5f88ba..a50b10919b 100644
--- a/plugins/Dbx_mmap_SA/db3x_mmap_sa_10.vcxproj.filters
+++ b/plugins/Dbx_mmap_SA/db3x_mmap_sa_10.vcxproj.filters
@@ -42,9 +42,6 @@
<ClCompile Include="dialogs.cpp">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="encrypt.cpp">
- <Filter>Source Files</Filter>
- </ClCompile>
<ClCompile Include="init.cpp">
<Filter>Source Files</Filter>
</ClCompile>
diff --git a/plugins/Dbx_mmap_SA/dbevents.cpp b/plugins/Dbx_mmap_SA/dbevents.cpp
index 4f80f31b41..2ee826c589 100644
--- a/plugins/Dbx_mmap_SA/dbevents.cpp
+++ b/plugins/Dbx_mmap_SA/dbevents.cpp
@@ -310,7 +310,7 @@ STDMETHODIMP_(BOOL) CDdxMmap::GetEvent(HANDLE hDbEvent, DBEVENTINFO *dbei)
dbei->cbBlob = dbe->cbBlob;
if (bytesToCopy && dbei->pBlob)
{
- for(i = 0;;i += MAXCACHEDREADSIZE) {
+ for (i = 0;;i += MAXCACHEDREADSIZE) {
if (bytesToCopy-i <= MAXCACHEDREADSIZE) {
DecodeCopyMemory(dbei->pBlob+i,DBRead(DWORD(hDbEvent)+offsetof(DBEvent,blob)+i,bytesToCopy-i,NULL),bytesToCopy-i);
break;
diff --git a/plugins/Dbx_mmap_SA/dbmodulechain.cpp b/plugins/Dbx_mmap_SA/dbmodulechain.cpp
index 257681b1a9..9c3d163e67 100644
--- a/plugins/Dbx_mmap_SA/dbmodulechain.cpp
+++ b/plugins/Dbx_mmap_SA/dbmodulechain.cpp
@@ -179,7 +179,7 @@ STDMETHODIMP_(BOOL) CDdxMmap::EnumModuleNames(DBMODULEENUMPROC pFunc, void *pPar
{
int ret;
ModuleName *pmn;
- for(int i = 0; i < lMods.realCount; i++) {
+ for (int i = 0; i < lMods.realCount; i++) {
pmn = (ModuleName *)lMods.items[i];
ret = pFunc(pmn->name, pmn->ofs, (LPARAM)pParam);
if (ret)
diff --git a/plugins/Dbx_mmap_SA/dbpreset.cpp b/plugins/Dbx_mmap_SA/dbpreset.cpp
index e690dc1aaa..0334f8f5d8 100644
--- a/plugins/Dbx_mmap_SA/dbpreset.cpp
+++ b/plugins/Dbx_mmap_SA/dbpreset.cpp
@@ -133,7 +133,7 @@ int InitPreset()
char *pszValue,*pszEnd;
buf = (PBYTE)mir_alloc(lstrlenA(szValue+1));
- for(len = 0,pszValue = szValue+1;;len++) {
+ for (len = 0,pszValue = szValue+1;;len++) {
buf[len] = (BYTE)strtol(pszValue,&pszEnd,0x10);
if (pszValue == pszEnd) break;
pszValue = pszEnd;
@@ -275,13 +275,13 @@ static void DBPresetItem_Hash(DBPresetItem *item)
int i;
int shift = 0;
item->dwHash = 0;
- for(i = 0;item->szModule[i];i++)
+ for (i = 0;item->szModule[i];i++)
{
item->dwHash ^= item->szModule[i]<<shift;
if (shift>24) item->dwHash ^= (item->szModule[i]>>(32-shift))&0x7F;
shift = (shift+5)&0x1F;
}
- for(i = 0;item->szSetting[i];i++)
+ for (i = 0;item->szSetting[i];i++)
{
item->dwHash ^= item->szSetting[i]<<shift;
if (shift>24) item->dwHash ^= (item->szSetting[i]>>(32-shift))&0x7F;
diff --git a/plugins/Dbx_mmap_SA/dbsettings.cpp b/plugins/Dbx_mmap_SA/dbsettings.cpp
index 980385bad2..26900dd94e 100644
--- a/plugins/Dbx_mmap_SA/dbsettings.cpp
+++ b/plugins/Dbx_mmap_SA/dbsettings.cpp
@@ -965,7 +965,7 @@ STDMETHODIMP_(BOOL) CDdxMmap::EnumResidentSettings(DBMODULEENUMPROC pFunc, void
{
int i;
int ret;
- for(i = 0; i < lResidentSettings.realCount; i++) {
+ for (i = 0; i < lResidentSettings.realCount; i++) {
ret = pFunc((char*)lResidentSettings.items[i], 0, (LPARAM)pParam);
if (ret) return ret;
}
diff --git a/plugins/Dbx_mmap_SA/dialogs.cpp b/plugins/Dbx_mmap_SA/dialogs.cpp
index 7bd1347647..4e51381d24 100644
--- a/plugins/Dbx_mmap_SA/dialogs.cpp
+++ b/plugins/Dbx_mmap_SA/dialogs.cpp
@@ -140,13 +140,11 @@ int UnloadOptions()
return 0;
}
-
int InitDialogs()
{
OleInitialize(0);
CreateServiceFunction(MS_DB_CHANGEPASSWORD, ChangePassword);
HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoad);
-
return 0;
}
@@ -177,166 +175,167 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
HIMAGELIST hIml;
switch ( msg ) {
- case WM_INITDIALOG:
- hIml = ImageList_Create(16, 16, ILC_MASK | (IsWinVerXPPlus()? ILC_COLOR32 : ILC_COLOR16), 2, 0);
- TranslateDialogDefault( hwndDlg );
-
- ImageList_AddIcon_IconLibLoaded( hIml, "core_main_29" );
- ImageList_AddIcon_IconLibLoaded( hIml, "core_main_30" );
- ListView_SetImageList( hwndList, hIml, LVSIL_SMALL );
-
- col.pszText = NULL;
- col.mask = LVCF_TEXT | LVCF_WIDTH;
- col.fmt = LVCFMT_LEFT;
- col.cx = 50;
- ListView_InsertColumn(hwndList, 1, &col);
-
- col.pszText = TranslateT("Dll");
- col.mask = LVCF_TEXT | LVCF_WIDTH;
- col.fmt = LVCFMT_LEFT;
- col.cx = 1000;
- ListView_InsertColumn(hwndList, 2, &col);
-
- col.pszText = TranslateT("Name");
- col.cx = 1000;
- ListView_InsertColumn(hwndList, 3, &col);
-
- col.pszText = TranslateT("Version");
- col.cx = 1000;
- ListView_InsertColumn(hwndList, 4, &col);
-
- ListView_SetExtendedListViewStyleEx(hwndList, 0, LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT | LVS_EX_SUBITEMIMAGES);
-
- uid = DBGetContactSettingWord(NULL, "SecureMMAP", "CryptoModule", 0);
-
- for(i = 0; i < ModulesCount; i++) {
- char buf[100];
-
- item.mask = LVIF_TEXT;
- item.iItem = i;
- item.iSubItem = 0;
- item.pszText = NULL;
- iRow = ListView_InsertItem(hwndList, &item);
-
- ListView_SetItemText(hwndList, iRow, 1, (LPWSTR)Modules[i]->dllname);
- ListView_SetItemText(hwndList, iRow, 2, (LPWSTR)Modules[i]->cryptor->Name);
- mir_snprintf(buf,SIZEOF(buf),"%d.%d.%d.%d", HIBYTE(HIWORD(Modules[i]->cryptor->Version)), LOBYTE(HIWORD(Modules[i]->cryptor->Version)), HIBYTE(LOWORD(Modules[i]->cryptor->Version)), LOBYTE(LOWORD(Modules[i]->cryptor->Version)));
- ListView_SetItemText(hwndList, iRow, 3, (LPWSTR)buf);
-
- if (uid == Modules[i]->cryptor->uid && bEncoding)
- ListView_SetCheckState(hwndList, i, 1);
-
- item.mask = LVIF_IMAGE;
- item.iItem = iRow;
- item.iSubItem = 0;
- item.iImage = ( CryptoEngine == Modules[i]->cryptor && bEncoding ) ? 0 : 1;
- ListView_SetItem( hwndList, &item );
- }
-
- ListView_SetColumnWidth(hwndList, 0, LVSCW_AUTOSIZE);
- ListView_SetColumnWidth(hwndList, 1, LVSCW_AUTOSIZE);
- ListView_SetColumnWidth(hwndList, 2, LVSCW_AUTOSIZE);
- ListView_SetColumnWidth(hwndList, 3, LVSCW_AUTOSIZE);
- return TRUE;
+ case WM_INITDIALOG:
+ hIml = ImageList_Create(16, 16, ILC_MASK | (IsWinVerXPPlus()? ILC_COLOR32 : ILC_COLOR16), 2, 0);
+ TranslateDialogDefault( hwndDlg );
+
+ ImageList_AddIcon_IconLibLoaded( hIml, "core_main_29" );
+ ImageList_AddIcon_IconLibLoaded( hIml, "core_main_30" );
+ ListView_SetImageList( hwndList, hIml, LVSIL_SMALL );
+
+ col.pszText = NULL;
+ col.mask = LVCF_TEXT | LVCF_WIDTH;
+ col.fmt = LVCFMT_LEFT;
+ col.cx = 50;
+ ListView_InsertColumn(hwndList, 1, &col);
+
+ col.pszText = TranslateT("Dll");
+ col.mask = LVCF_TEXT | LVCF_WIDTH;
+ col.fmt = LVCFMT_LEFT;
+ col.cx = 1000;
+ ListView_InsertColumn(hwndList, 2, &col);
+
+ col.pszText = TranslateT("Name");
+ col.cx = 1000;
+ ListView_InsertColumn(hwndList, 3, &col);
+
+ col.pszText = TranslateT("Version");
+ col.cx = 1000;
+ ListView_InsertColumn(hwndList, 4, &col);
+
+ ListView_SetExtendedListViewStyleEx(hwndList, 0, LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT | LVS_EX_SUBITEMIMAGES);
+
+ uid = DBGetContactSettingWord(NULL, "SecureMMAP", "CryptoModule", 0);
+
+ for (i = 0; i < ModulesCount; i++) {
+ char buf[100];
+
+ item.mask = LVIF_TEXT;
+ item.iItem = i;
+ item.iSubItem = 0;
+ item.pszText = NULL;
+ iRow = ListView_InsertItem(hwndList, &item);
+
+ ListView_SetItemText(hwndList, iRow, 1, (LPWSTR)Modules[i]->dllname);
+ ListView_SetItemText(hwndList, iRow, 2, (LPWSTR)Modules[i]->cryptor->Name);
+ mir_snprintf(buf,SIZEOF(buf),"%d.%d.%d.%d", HIBYTE(HIWORD(Modules[i]->cryptor->Version)), LOBYTE(HIWORD(Modules[i]->cryptor->Version)), HIBYTE(LOWORD(Modules[i]->cryptor->Version)), LOBYTE(LOWORD(Modules[i]->cryptor->Version)));
+ ListView_SetItemText(hwndList, iRow, 3, (LPWSTR)buf);
+
+ if (uid == Modules[i]->cryptor->uid && bEncoding)
+ ListView_SetCheckState(hwndList, i, 1);
+
+ item.mask = LVIF_IMAGE;
+ item.iItem = iRow;
+ item.iSubItem = 0;
+ item.iImage = ( CryptoEngine == Modules[i]->cryptor && bEncoding ) ? 0 : 1;
+ ListView_SetItem( hwndList, &item );
+ }
- case WM_COMMAND:
- if ( HIWORD(wParam) == STN_CLICKED ) {
- switch (LOWORD(wParam)) {
- case IDC_EMAIL:
- case IDC_SITE:
- {
- char buf[512];
- char * p = &buf[7];
- lstrcpyA(buf,"mailto:");
- if ( GetWindowTextA(GetDlgItem(hwndDlg, LOWORD(wParam)), p, SIZEOF(buf) - 7)) {
- CallService(MS_UTILS_OPENURL,0,(LPARAM) (LOWORD(wParam) == IDC_EMAIL ? buf : p));
- }
- break;
- } } }
- break;
+ ListView_SetColumnWidth(hwndList, 0, LVSCW_AUTOSIZE);
+ ListView_SetColumnWidth(hwndList, 1, LVSCW_AUTOSIZE);
+ ListView_SetColumnWidth(hwndList, 2, LVSCW_AUTOSIZE);
+ ListView_SetColumnWidth(hwndList, 3, LVSCW_AUTOSIZE);
+ return TRUE;
- case WM_NOTIFY:
- if ( hdr && hdr->hdr.code == LVN_ITEMCHANGED && IsWindowVisible(hdr->hdr.hwndFrom) && hdr->iItem != (-1)) {
- iIndex = hdr->iItem;
- if (hdr->uNewState & 0x2000){
- for(i = 0; i < ModulesCount; i++) {
- if (i != iIndex) ListView_SetCheckState(hwndList, i, 0);
+ case WM_COMMAND:
+ if ( HIWORD(wParam) == STN_CLICKED ) {
+ switch (LOWORD(wParam)) {
+ case IDC_EMAIL:
+ case IDC_SITE:
+ {
+ char buf[512];
+ char * p = &buf[7];
+ lstrcpyA(buf,"mailto:");
+ if ( GetWindowTextA(GetDlgItem(hwndDlg, LOWORD(wParam)), p, SIZEOF(buf) - 7)) {
+ CallService(MS_UTILS_OPENURL,0,(LPARAM) (LOWORD(wParam) == IDC_EMAIL ? buf : p));
}
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
- break;
- }
- if (hdr->uNewState & 0x1000){
- SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
+ } } }
+ break;
+
+ case WM_NOTIFY:
+ if ( hdr && hdr->hdr.code == LVN_ITEMCHANGED && IsWindowVisible(hdr->hdr.hwndFrom) && hdr->iItem != (-1)) {
+ iIndex = hdr->iItem;
+ if (hdr->uNewState & 0x2000){
+ for (i = 0; i < ModulesCount; i++) {
+ if (i != iIndex) ListView_SetCheckState(hwndList, i, 0);
}
- if (hdr->uNewState & LVIS_SELECTED){
- SetDlgItemTextA(hwndDlg, IDC_AUTHOR, Modules[iIndex]->cryptor->Author);
- {
- TCHAR* info_t = mir_a2t((char*)(Modules[iIndex]->cryptor->Info));
- SetDlgItemText(hwndDlg, IDC_INFO, TranslateTS(info_t));
- mir_free(info_t);
- }
- SetDlgItemTextA(hwndDlg, IDC_SITE, Modules[iIndex]->cryptor->Site);
- SetDlgItemTextA(hwndDlg, IDC_EMAIL, Modules[iIndex]->cryptor->Email);
- SetDlgItemTextA(hwndDlg, IDC_ENC, Modules[iIndex]->cryptor->Name);
- SetDlgItemInt(hwndDlg, IDC_UID, Modules[iIndex]->cryptor->uid, 0);
- } else {
- SetDlgItemTextA(hwndDlg, IDC_AUTHOR, "");
- SetDlgItemTextA(hwndDlg, IDC_INFO, "");
- SetDlgItemTextA(hwndDlg, IDC_SITE, "");
- SetDlgItemTextA(hwndDlg, IDC_EMAIL, "");
- SetDlgItemTextA(hwndDlg, IDC_ENC, "");
- SetDlgItemTextA(hwndDlg, IDC_UID, "");
- }
-
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
}
- if (((LPNMHDR)lParam)->code == PSN_APPLY ) {
- int alg = -1;
- for(i = 0; i < ModulesCount; i++) {
- if (ListView_GetCheckState(hwndList, i)) {
- alg = i;
- break;
- }
+ if (hdr->uNewState & 0x1000){
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+ }
+ if (hdr->uNewState & LVIS_SELECTED){
+ SetDlgItemTextA(hwndDlg, IDC_AUTHOR, Modules[iIndex]->cryptor->Author);
+ {
+ TCHAR* info_t = mir_a2t((char*)(Modules[iIndex]->cryptor->Info));
+ SetDlgItemText(hwndDlg, IDC_INFO, TranslateTS(info_t));
+ mir_free(info_t);
+ }
+ SetDlgItemTextA(hwndDlg, IDC_SITE, Modules[iIndex]->cryptor->Site);
+ SetDlgItemTextA(hwndDlg, IDC_EMAIL, Modules[iIndex]->cryptor->Email);
+ SetDlgItemTextA(hwndDlg, IDC_ENC, Modules[iIndex]->cryptor->Name);
+ SetDlgItemInt(hwndDlg, IDC_UID, Modules[iIndex]->cryptor->uid, 0);
+ } else {
+ SetDlgItemTextA(hwndDlg, IDC_AUTHOR, "");
+ SetDlgItemTextA(hwndDlg, IDC_INFO, "");
+ SetDlgItemTextA(hwndDlg, IDC_SITE, "");
+ SetDlgItemTextA(hwndDlg, IDC_EMAIL, "");
+ SetDlgItemTextA(hwndDlg, IDC_ENC, "");
+ SetDlgItemTextA(hwndDlg, IDC_UID, "");
+ }
+
+ break;
+ }
+ if (((LPNMHDR)lParam)->code == PSN_APPLY ) {
+ int alg = -1;
+ for (i = 0; i < ModulesCount; i++) {
+ if (ListView_GetCheckState(hwndList, i)) {
+ alg = i;
+ break;
}
+ }
- if (alg > -1){
- if (!bEncoding){
+ if (alg > -1){
+ if (!bEncoding){
+ DBWriteContactSettingWord(NULL, "SecureMMAP", "CryptoModule", Modules[alg]->cryptor->uid);
+ g_Db->EncryptDB();
+ }
+ else {
+ if (Modules[alg]->cryptor->uid != DBGetContactSettingWord(NULL, "SecureMMAP", "CryptoModule", -1)) {
DBWriteContactSettingWord(NULL, "SecureMMAP", "CryptoModule", Modules[alg]->cryptor->uid);
- g_Db->EncryptDB();
- }
- else {
- if (Modules[alg]->cryptor->uid != DBGetContactSettingWord(NULL, "SecureMMAP", "CryptoModule", -1)) {
- DBWriteContactSettingWord(NULL, "SecureMMAP", "CryptoModule", Modules[alg]->cryptor->uid);
- g_Db->RecryptDB();
- }
+ g_Db->RecryptDB();
}
}
- else if (bEncoding)
- g_Db->DecryptDB();
+ }
+ else if (bEncoding)
+ g_Db->DecryptDB();
- uid = DBGetContactSettingWord(NULL, "SecureMMAP", "CryptoModule", 0);
+ uid = DBGetContactSettingWord(NULL, "SecureMMAP", "CryptoModule", 0);
- for(i = 0; i < ModulesCount; i++) {
- if (uid == Modules[i]->cryptor->uid && bEncoding)
- ListView_SetCheckState(hwndList, i, 1);
+ for (i = 0; i < ModulesCount; i++) {
+ if (uid == Modules[i]->cryptor->uid && bEncoding)
+ ListView_SetCheckState(hwndList, i, 1);
- item.mask = LVIF_IMAGE;
- item.iItem = i;
- item.iSubItem = 0;
- item.iImage = ( CryptoEngine == Modules[i]->cryptor && bEncoding ) ? 0 : 1;
+ item.mask = LVIF_IMAGE;
+ item.iItem = i;
+ item.iSubItem = 0;
+ item.iImage = ( CryptoEngine == Modules[i]->cryptor && bEncoding ) ? 0 : 1;
- ListView_SetItem( hwndList, &item );
- }
+ ListView_SetItem( hwndList, &item );
+ }
- return TRUE;
+ return TRUE;
- }
- break;
+ }
+ break;
}
return FALSE;
}
+
UINT oldLangID = 0;
void LanguageChanged(HWND hDlg)
{
@@ -358,83 +357,62 @@ BOOL CALLBACK DlgStdInProc(HWND hDlg, UINT uMsg,WPARAM wParam,LPARAM lParam)
{
HICON hIcon = 0;
TCHAR tszHeaderTxt[256];
- TCHAR* tszDbName;
- switch(uMsg)
- {
+
+ switch(uMsg) {
case WM_INITDIALOG:
- {
- HWND hwndCtrl;
- TranslateDialogDefault(hDlg);
-
- hIcon = LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_ICON2));
- SendMessage(GetDlgItem(hDlg, IDC_HEADERBAR), WM_SETICON, 0, (LPARAM)hIcon);
-
- if (!wrongPass)
- {
- tszDbName = mir_a2t((char*)lParam);
- mir_sntprintf(tszHeaderTxt, SIZEOF(tszHeaderTxt), _T("%s\n%s"), TranslateT("Please type in your password for"), tszDbName);
- SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), tszHeaderTxt);
- mir_free(tszDbName);
- }
- else
- {
- if (wrongPass > 2)
- {
- hwndCtrl = GetDlgItem(hDlg, IDC_USERPASS);
- EnableWindow(hwndCtrl, FALSE);
- hwndCtrl = GetDlgItem(hDlg, IDOK);
- EnableWindow(hwndCtrl, FALSE);
- SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), TranslateT("Too many errors!"));
- }
- else
- {
- SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), TranslateT("Password is not correct!"));
- }
+ TranslateDialogDefault(hDlg);
+
+ hIcon = LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_ICON2));
+ SendMessage(GetDlgItem(hDlg, IDC_HEADERBAR), WM_SETICON, 0, (LPARAM)hIcon);
+
+ if (!wrongPass) {
+ mir_sntprintf(tszHeaderTxt, SIZEOF(tszHeaderTxt), _T("%s\n%s"), TranslateT("Please type in your password for"), (TCHAR*)lParam);
+ SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), tszHeaderTxt);
+ }
+ else {
+ if (wrongPass > 2) {
+ HWND hwndCtrl = GetDlgItem(hDlg, IDC_USERPASS);
+ EnableWindow(hwndCtrl, FALSE);
+ hwndCtrl = GetDlgItem(hDlg, IDOK);
+ EnableWindow(hwndCtrl, FALSE);
+ SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), TranslateT("Too many errors!"));
}
- oldLangID = 0;
- SetTimer(hDlg,1,200,NULL);
- LanguageChanged(hDlg);
- return TRUE;
+ else SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), TranslateT("Password is not correct!"));
}
+ oldLangID = 0;
+ SetTimer(hDlg,1,200,NULL);
+ LanguageChanged(hDlg);
+ return TRUE;
case WM_CTLCOLORSTATIC:
- {
- if ((HWND)lParam == GetDlgItem(hDlg, IDC_LANG))
- {
- SetTextColor((HDC)wParam, GetSysColor(COLOR_HIGHLIGHTTEXT));
- SetBkMode((HDC)wParam, TRANSPARENT);
- return (BOOL)GetSysColorBrush(COLOR_HIGHLIGHT);
- }
-
- return FALSE;
+ if ((HWND)lParam == GetDlgItem(hDlg, IDC_LANG)) {
+ SetTextColor((HDC)wParam, GetSysColor(COLOR_HIGHLIGHTTEXT));
+ SetBkMode((HDC)wParam, TRANSPARENT);
+ return (BOOL)GetSysColorBrush(COLOR_HIGHLIGHT);
}
+ return FALSE;
case WM_COMMAND:
- {
- UINT uid = LOWORD(wParam);
-
- if (uid == IDOK){
- if (!GetWindowLongPtr(hDlg,GWLP_USERDATA))
- {
- encryptKeyLength = GetDlgItemTextA(hDlg, IDC_USERPASS, encryptKey, 254);
- EndDialog(hDlg,IDOK);
- }else{
-
- }
- }else if (uid == IDCANCEL){
- EndDialog(hDlg,IDCANCEL);
+ switch( LOWORD(wParam)) {
+ case IDOK:
+ if (!GetWindowLongPtr(hDlg,GWLP_USERDATA)) {
+ encryptKeyLength = GetDlgItemTextA(hDlg, IDC_USERPASS, encryptKey, 254);
+ EndDialog(hDlg,IDOK);
}
+ break;
+
+ case IDCANCEL:
+ EndDialog(hDlg,IDCANCEL);
}
+ break;
+
case WM_TIMER:
- {
- LanguageChanged(hDlg);
- return FALSE;
- }
+ LanguageChanged(hDlg);
+ return FALSE;
+
case WM_DESTROY:
- {
- KillTimer(hDlg, 1);
- DestroyIcon(hIcon);
- }
+ KillTimer(hDlg, 1);
+ DestroyIcon(hIcon);
}
return FALSE;
@@ -444,81 +422,69 @@ BOOL CALLBACK DlgStdNewPass(HWND hDlg, UINT uMsg,WPARAM wParam,LPARAM lParam)
{
HICON hIcon = 0;
- switch(uMsg)
- {
+ switch(uMsg) {
case WM_INITDIALOG:
- {
- TranslateDialogDefault(hDlg);
+ TranslateDialogDefault(hDlg);
- hIcon = LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_ICON2));
- SendMessage(GetDlgItem(hDlg, IDC_HEADERBAR), WM_SETICON, 0, (LPARAM)hIcon);
+ hIcon = LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_ICON2));
+ SendMessage(GetDlgItem(hDlg, IDC_HEADERBAR), WM_SETICON, 0, (LPARAM)hIcon);
- SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), TranslateT("Please enter your new password"));
+ SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), TranslateT("Please enter your new password"));
- oldLangID = 0;
- SetTimer(hDlg,1,200,NULL);
- LanguageChanged(hDlg);
-
- return TRUE;
- }
+ oldLangID = 0;
+ SetTimer(hDlg,1,200,NULL);
+ LanguageChanged(hDlg);
+ return TRUE;
case WM_CTLCOLORSTATIC:
- {
- if ((HWND)lParam == GetDlgItem(hDlg, IDC_LANG))
- {
- SetTextColor((HDC)wParam, GetSysColor(COLOR_HIGHLIGHTTEXT));
- SetBkMode((HDC)wParam, TRANSPARENT);
- return (BOOL)GetSysColorBrush(COLOR_HIGHLIGHT);
- }
-
- return FALSE;
+ if ((HWND)lParam == GetDlgItem(hDlg, IDC_LANG)) {
+ SetTextColor((HDC)wParam, GetSysColor(COLOR_HIGHLIGHTTEXT));
+ SetBkMode((HDC)wParam, TRANSPARENT);
+ return (BOOL)GetSysColorBrush(COLOR_HIGHLIGHT);
}
+ return FALSE;
case WM_COMMAND:
{
UINT uid = LOWORD(wParam);
-
- if (uid == IDOK){
- if (!GetWindowLongPtr(hDlg,GWLP_USERDATA))
- {
+ if (uid == IDOK) {
+ if (!GetWindowLongPtr(hDlg,GWLP_USERDATA)) {
char pass1[255], pass2[255];
if (GetDlgItemTextA(hDlg, IDC_USERPASS1, pass1, 254) < 3){
SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), TranslateT("Password is too short!"));
SendMessage(GetDlgItem(hDlg, IDC_HEADERBAR), WM_NCPAINT, 0, 0);
SetDlgItemTextA(hDlg,IDC_USERPASS1,"");
SetDlgItemTextA(hDlg,IDC_USERPASS2,"");
- }else{
-
+ }
+ else {
GetDlgItemTextA(hDlg, IDC_USERPASS2, pass2, 254);
if (!strcmp(pass1, pass2)) {
encryptKeyLength = strlen(pass1);
strcpy(encryptKey, pass1);
EndDialog(hDlg,IDOK);
- }else{
+ }
+ else {
SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), TranslateT("Passwords do not match!"));
SendMessage(GetDlgItem(hDlg, IDC_HEADERBAR), WM_NCPAINT, 0, 0);
SetDlgItemTextA(hDlg,IDC_USERPASS1,"");
SetDlgItemTextA(hDlg,IDC_USERPASS2,"");
}
}
- }else{
-
}
- }else if (uid == IDCANCEL){
- EndDialog(hDlg,IDCANCEL);
}
+ else if (uid == IDCANCEL)
+ EndDialog(hDlg,IDCANCEL);
}
+ break;
+
case WM_TIMER:
- {
- LanguageChanged(hDlg);
- return FALSE;
- }
+ LanguageChanged(hDlg);
+ return FALSE;
+
case WM_DESTROY:
- {
- KillTimer(hDlg, 1);
- DestroyIcon(hIcon);
- return FALSE;
- }
+ KillTimer(hDlg, 1);
+ DestroyIcon(hIcon);
+ return FALSE;
}
return FALSE;
}
@@ -529,65 +495,61 @@ BOOL CALLBACK DlgChangePass(HWND hDlg, UINT uMsg,WPARAM wParam,LPARAM lParam)
{
HICON hIcon = 0;
- switch(uMsg)
- {
+ switch(uMsg) {
case WM_INITDIALOG:
- {
- TranslateDialogDefault(hDlg);
+ TranslateDialogDefault(hDlg);
- hIcon = LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_ICON2));
- SendMessage(GetDlgItem(hDlg, IDC_HEADERBAR), WM_SETICON, 0, (LPARAM)hIcon);
- SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), TranslateT("Change password"));
+ hIcon = LoadIcon(g_hInst, MAKEINTRESOURCE(IDI_ICON2));
+ SendMessage(GetDlgItem(hDlg, IDC_HEADERBAR), WM_SETICON, 0, (LPARAM)hIcon);
+ SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), TranslateT("Change password"));
- newPass = (char*)lParam;
- oldLangID = 0;
- SetTimer(hDlg,1,200,NULL);
- LanguageChanged(hDlg);
+ newPass = (char*)lParam;
+ oldLangID = 0;
+ SetTimer(hDlg,1,200,NULL);
+ LanguageChanged(hDlg);
- return TRUE;
- }
+ return TRUE;
case WM_CTLCOLORSTATIC:
- {
- if ((HWND)lParam == GetDlgItem(hDlg, IDC_LANG))
- {
- SetTextColor((HDC)wParam, GetSysColor(COLOR_HIGHLIGHTTEXT));
- SetBkMode((HDC)wParam, TRANSPARENT);
- return (BOOL)GetSysColorBrush(COLOR_HIGHLIGHT);
- }
-
- return FALSE;
+ if ((HWND)lParam == GetDlgItem(hDlg, IDC_LANG)) {
+ SetTextColor((HDC)wParam, GetSysColor(COLOR_HIGHLIGHTTEXT));
+ SetBkMode((HDC)wParam, TRANSPARENT);
+ return (BOOL)GetSysColorBrush(COLOR_HIGHLIGHT);
}
+ return FALSE;
+
case WM_COMMAND:
{
UINT uid = LOWORD(wParam);
+ if (uid == IDOK) {
+ char pass1[255], pass2[255], oldpass[255];
+ GetDlgItemTextA(hDlg, IDC_OLDPASS, oldpass, 254);
+ if (strcmp(oldpass, encryptKey)) {
+ SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), TranslateT("Wrong password!"));
+ SendMessage(GetDlgItem(hDlg, IDC_HEADERBAR), WM_NCPAINT, 0, 0);
+ break;
+ }
+ if (GetDlgItemTextA(hDlg, IDC_NEWPASS1, pass1, 254) < 3){
+ SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), TranslateT("Password is too short!"));
+ SendMessage(GetDlgItem(hDlg, IDC_HEADERBAR), WM_NCPAINT, 0, 0);
- if (uid == IDOK){
- char pass1[255], pass2[255], oldpass[255];
- GetDlgItemTextA(hDlg, IDC_OLDPASS, oldpass, 254);
- if (strcmp(oldpass, encryptKey)) {
- SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), TranslateT("Wrong password!"));
- SendMessage(GetDlgItem(hDlg, IDC_HEADERBAR), WM_NCPAINT, 0, 0);
- break;
+ }
+ else {
+ GetDlgItemTextA(hDlg, IDC_NEWPASS2, pass2, 254);
+ if (!strcmp(pass1, pass2)) {
+ strcpy(newPass, pass1);
+ EndDialog(hDlg,IDOK);
}
- if (GetDlgItemTextA(hDlg, IDC_NEWPASS1, pass1, 254) < 3){
- SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), TranslateT("Password is too short!"));
+ else {
+ SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), TranslateT("Passwords do not match!"));
SendMessage(GetDlgItem(hDlg, IDC_HEADERBAR), WM_NCPAINT, 0, 0);
-
- }else{
- GetDlgItemTextA(hDlg, IDC_NEWPASS2, pass2, 254);
- if (!strcmp(pass1, pass2)) {
- strcpy(newPass, pass1);
- EndDialog(hDlg,IDOK);
- }else{
- SetWindowText(GetDlgItem(hDlg, IDC_HEADERBAR), TranslateT("Passwords do not match!"));
- SendMessage(GetDlgItem(hDlg, IDC_HEADERBAR), WM_NCPAINT, 0, 0);
- }
}
- }else if (uid == IDCANCEL){
+ }
+ }
+ else if (uid == IDCANCEL)
EndDialog(hDlg,IDCANCEL);
- }else if (uid == IDREMOVE){
+ else if (uid == IDREMOVE) {
char oldpass[255];
GetDlgItemTextA(hDlg, IDC_OLDPASS, oldpass, 254);
if (strcmp(oldpass, encryptKey)) {
@@ -598,16 +560,15 @@ BOOL CALLBACK DlgChangePass(HWND hDlg, UINT uMsg,WPARAM wParam,LPARAM lParam)
EndDialog(hDlg, IDREMOVE);
}
}
+ break;
+
case WM_TIMER:
- {
- LanguageChanged(hDlg);
- return FALSE;
- }
+ LanguageChanged(hDlg);
+ return FALSE;
+
case WM_DESTROY:
- {
- KillTimer(hDlg, 1);
- return FALSE;
- }
+ KillTimer(hDlg, 1);
+ return FALSE;
}
return FALSE;
}
diff --git a/plugins/Dbx_mmap_SA/security.cpp b/plugins/Dbx_mmap_SA/security.cpp
index 618476e12f..50b23f4312 100644
--- a/plugins/Dbx_mmap_SA/security.cpp
+++ b/plugins/Dbx_mmap_SA/security.cpp
@@ -20,7 +20,7 @@ CryptoModule* Modules[100];
void zero_fill(BYTE * pBuf, size_t bufSize)
{
size_t i;
- for(i = 0; i < bufSize; i++)
+ for (i = 0; i < bufSize; i++)
pBuf[i] = 0;
}
@@ -65,7 +65,7 @@ void UnloadSecurity()
if (CryptoEngine) CryptoEngine->FreeKey(key);
- for(i = 0; i < ModulesCount; i++)
+ for (i = 0; i < ModulesCount; i++)
{
FreeLibrary(Modules[i]->hLib);
free(Modules[i]);
@@ -148,7 +148,7 @@ int CDdxMmap::CheckPassword(WORD checkWord, TCHAR *szDBName)
{
int i;
int Found = 0;
- for(i = 0; i < ModulesCount; i++) {
+ for (i = 0; i < ModulesCount; i++) {
if (dbHeader.cryptorUID == Modules[i]->cryptor->uid){
CryptoEngine = Modules[i]->cryptor;
Found = 1;
@@ -204,7 +204,7 @@ int SelectEncoder()
}
else{
int Found = 0;
- for(i = 0; i < ModulesCount; i++) {
+ for (i = 0; i < ModulesCount; i++) {
if (Modules[i]->cryptor->uid == uid){
CryptoEngine = Modules[i]->cryptor;
Found = 1;