summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-11-19 18:01:14 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-11-19 18:01:14 +0000
commitd6e05cc3bca53565d9ca65377ab8b0b6190774b3 (patch)
tree76040facd4d0b82162069a19cae8f7f024bf1f65 /plugins
parent2ef414538760079fa2955fca1a2c03d610459fa8 (diff)
preparing to the transparent cyphering: end of MS_DB_CRYPT_ENCODESTRING/MS_DB_CRYPT_DECODESTRING
git-svn-id: http://svn.miranda-ng.org/main/trunk@6938 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/BossKeyPlus/src/BossKey.cpp4
-rw-r--r--plugins/BossKeyPlus/src/Options.cpp289
-rw-r--r--plugins/CrashDumper/src/ui.cpp2
-rw-r--r--plugins/CrashDumper/src/upload.cpp2
-rw-r--r--plugins/Db3x_mmap/src/dbsettings.cpp79
-rw-r--r--plugins/DbEditorPP/src/settinglist.cpp32
-rw-r--r--plugins/Dbx_mmap_SA/src/commonheaders.h5
-rw-r--r--plugins/Dbx_tree/src/Compatibility.cpp515
-rw-r--r--plugins/Exchange/src/MirandaExchange.cpp46
-rw-r--r--plugins/Exchange/src/MirandaExchange.h2
-rw-r--r--plugins/Exchange/src/dlg_handlers.cpp706
-rw-r--r--plugins/Exchange/src/emails.cpp212
-rw-r--r--plugins/FTPFileYM/src/mir_db.cpp22
-rw-r--r--plugins/FTPFileYM/src/mir_db.h3
-rw-r--r--plugins/FTPFileYM/src/serverlist.cpp8
-rw-r--r--plugins/NewsAggregator/Src/Authentication.cpp6
-rw-r--r--plugins/NewsAggregator/Src/Options.cpp81
-rw-r--r--plugins/SecureIM/src/commonheaders.cpp2
-rw-r--r--plugins/SecureIM/src/commonheaders.h3
-rw-r--r--plugins/SecureIM/src/crypt_dll.cpp52
-rw-r--r--plugins/SecureIM/src/main.cpp8
-rw-r--r--plugins/SecureIM/src/options.cpp2
-rw-r--r--plugins/SecureIM/src/svcs_menu.cpp2
-rw-r--r--plugins/VersionInfo/src/dlgHandlers.cpp1
-rw-r--r--plugins/Watrack/lastfm/i_last_opt.inc9
-rw-r--r--plugins/Watrack/myshows/i_myshows_opt.inc10
26 files changed, 895 insertions, 1208 deletions
diff --git a/plugins/BossKeyPlus/src/BossKey.cpp b/plugins/BossKeyPlus/src/BossKey.cpp
index a208c2e40f..dd20160964 100644
--- a/plugins/BossKeyPlus/src/BossKey.cpp
+++ b/plugins/BossKeyPlus/src/BossKey.cpp
@@ -421,13 +421,11 @@ LRESULT CALLBACK ListenWndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
if (g_wMask & OPT_REQPASS){ //password request
DBVARIANT dbVar = {0};
- if (!db_get_s(NULL,MOD_NAME,"password",&dbVar))
- {
+ if (!db_get_s(NULL,MOD_NAME,"password",&dbVar)) {
g_fPassRequested = true;
strncpy(g_password, dbVar.pszVal, MAXPASSLEN);
db_free(&dbVar);
- CallService(MS_DB_CRYPT_DECODESTRING, MAXPASSLEN+1, ( LPARAM )g_password );
int res = DialogBox(g_hInstance,(MAKEINTRESOURCE(IDD_PASSDIALOGNEW)),GetForegroundWindow(), DlgStdInProc);
diff --git a/plugins/BossKeyPlus/src/Options.cpp b/plugins/BossKeyPlus/src/Options.cpp
index 68d5916204..e19d31454b 100644
--- a/plugins/BossKeyPlus/src/Options.cpp
+++ b/plugins/BossKeyPlus/src/Options.cpp
@@ -23,30 +23,14 @@ bool g_fOptionsOpen;
bool g_fReqRass;
extern HGENMENU g_hMenuItem;
-//void Disable_ChildWindows(HWND hwndParent)
-//{
-// if (hwndParent != NULL)
-// {
-// HWND hWorkWnd = GetWindow(hwndParent,GW_CHILD); // first child
-// while (hWorkWnd != NULL)
-// {
-// EnableWindow(hWorkWnd,false);
-// hWorkWnd = GetNextWindow(hWorkWnd,GW_HWNDNEXT);
-// }
-// }
-//}
-
-
INT_PTR CALLBACK MainOptDlg(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam)
{
static bool s_fRedraw;
- switch (msg)
- {
- case WM_INITDIALOG:
+ switch (msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
{
- TranslateDialogDefault(hwndDlg);
-
g_fOptionsOpen = true;
s_fRedraw = false;
@@ -57,10 +41,7 @@ INT_PTR CALLBACK MainOptDlg(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam)
DBVARIANT dbVar;
- if (!db_get_s(NULL,MOD_NAME,"password",&dbVar))
- {
- CallService(MS_DB_CRYPT_DECODESTRING, strlen( dbVar.pszVal )+1, ( LPARAM )dbVar.pszVal );
-
+ if (!db_get_s(NULL,MOD_NAME,"password",&dbVar)) {
SetDlgItemTextA(hwndDlg,IDC_MAINOPT_PASS,dbVar.pszVal);
db_free(&dbVar);
}
@@ -82,87 +63,77 @@ INT_PTR CALLBACK MainOptDlg(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam)
SendMessage(hwndDlg,WM_USER + 50,0,0);
s_fRedraw = true;
- return true;
- } break;
- case WM_NOTIFY:
- {
- NMHDR* nmhdr = (NMHDR*)lParam;
- switch (nmhdr->code)
- {
- case PSN_APPLY:
- {
- WORD wMask = 0;
- // we apply changes here
- // this plugin ain't that big, no need for a seperate routine
-
- // write down status type
- if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_CHANGESTATUSBOX) == BST_CHECKED)
- {
- db_set_b(NULL,MOD_NAME,"stattype",(BYTE)SendDlgItemMessage(hwndDlg,IDC_MAINOPT_CHGSTS,CB_GETCURSEL,0,0));
-
- // status msg, if needed
- if (IsWindowEnabled(GetDlgItem(hwndDlg,IDC_MAINOPT_STATMSG))) // meaning we should save it
- {
- TCHAR tszMsg[1025];
- GetDlgItemText(hwndDlg,IDC_MAINOPT_STATMSG,tszMsg,1024);
- if (tszMsg[0] != 0)
- db_set_ts(NULL,MOD_NAME,"statmsg",tszMsg);
- else // delete current setting
- db_unset(NULL,MOD_NAME,"statmsg");
- }
- wMask |= OPT_CHANGESTATUS;
- }
-
- // checkbox
- if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_REQPASS) == BST_CHECKED)
- {
- char szPass[MAXPASSLEN+1];
- GetDlgItemTextA(hwndDlg,IDC_MAINOPT_PASS,szPass,MAXPASSLEN+1);
- if (szPass[0] != 0){
- CallService(MS_DB_CRYPT_ENCODESTRING, MAXPASSLEN+1, ( LPARAM )szPass );
- db_set_s(NULL,MOD_NAME,"password",szPass);
- wMask |= OPT_REQPASS;
- }
- }
- if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_SETONLINEBACK) == BST_CHECKED) wMask |= OPT_SETONLINEBACK;
- if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_DISABLESNDS) == BST_CHECKED) wMask |= OPT_DISABLESNDS;
- if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_ONLINEONLY) == BST_CHECKED) wMask |= OPT_ONLINEONLY;
- if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_USEDEFMSG) == BST_CHECKED) wMask |= OPT_USEDEFMSG;
- if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_TRAYICON) == BST_CHECKED) wMask |= OPT_TRAYICON;
-
- db_set_w(NULL,MOD_NAME,"optsmask",wMask);
- g_wMask = wMask;
-
- return true;
- } break;
+ }
+ return true;
+
+ case WM_NOTIFY:
+ switch (((NMHDR*)lParam)->code) {
+ case PSN_APPLY:
+ WORD wMask = 0;
+ // we apply changes here
+ // this plugin ain't that big, no need for a seperate routine
+
+ // write down status type
+ if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_CHANGESTATUSBOX) == BST_CHECKED) {
+ db_set_b(NULL,MOD_NAME,"stattype",(BYTE)SendDlgItemMessage(hwndDlg,IDC_MAINOPT_CHGSTS,CB_GETCURSEL,0,0));
+
+ // status msg, if needed
+ if (IsWindowEnabled(GetDlgItem(hwndDlg,IDC_MAINOPT_STATMSG))) { // meaning we should save it
+ TCHAR tszMsg[1025];
+ GetDlgItemText(hwndDlg,IDC_MAINOPT_STATMSG,tszMsg,1024);
+ if (tszMsg[0] != 0)
+ db_set_ts(NULL,MOD_NAME,"statmsg",tszMsg);
+ else // delete current setting
+ db_unset(NULL,MOD_NAME,"statmsg");
+ }
+ wMask |= OPT_CHANGESTATUS;
}
- } break;
- case WM_USER+50: // we're told to checkout the selection state of the combobox, and enable/disable accordingly
+
+ // checkbox
+ if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_REQPASS) == BST_CHECKED) {
+ char szPass[MAXPASSLEN+1];
+ GetDlgItemTextA(hwndDlg,IDC_MAINOPT_PASS,szPass,MAXPASSLEN+1);
+ if (szPass[0] != 0){
+ db_set_s(NULL,MOD_NAME,"password",szPass);
+ wMask |= OPT_REQPASS;
+ }
+ }
+ if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_SETONLINEBACK) == BST_CHECKED) wMask |= OPT_SETONLINEBACK;
+ if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_DISABLESNDS) == BST_CHECKED) wMask |= OPT_DISABLESNDS;
+ if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_ONLINEONLY) == BST_CHECKED) wMask |= OPT_ONLINEONLY;
+ if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_USEDEFMSG) == BST_CHECKED) wMask |= OPT_USEDEFMSG;
+ if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_TRAYICON) == BST_CHECKED) wMask |= OPT_TRAYICON;
+
+ db_set_w(NULL,MOD_NAME,"optsmask",wMask);
+ g_wMask = wMask;
+ return true;
+ }
+ break;
+
+ case WM_USER+50: // we're told to checkout the selection state of the combobox, and enable/disable accordingly
{
BYTE bSelection = (BYTE)SendDlgItemMessage(hwndDlg,IDC_MAINOPT_CHGSTS,CB_GETCURSEL,0,0);
WORD wMode = STATUS_ARR_TO_ID[bSelection];
- if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_USEDEFMSG) == BST_CHECKED)
- {
+ if (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_USEDEFMSG) == BST_CHECKED) {
TCHAR *ptszDefMsg = GetDefStatusMsg(wMode, 0);
SetDlgItemText(hwndDlg, IDC_MAINOPT_STATMSG, ptszDefMsg);
if(ptszDefMsg)
mir_free(ptszDefMsg);
}
- else
- {
+ else {
DBVARIANT dbVar;
SendDlgItemMessage(hwndDlg,IDC_MAINOPT_STATMSG,EM_LIMITTEXT,1024,0);
- if (!db_get_ts(NULL,MOD_NAME,"statmsg",&dbVar))
- {
+ if (!db_get_ts(NULL,MOD_NAME,"statmsg",&dbVar)) {
SetDlgItemText(hwndDlg,IDC_MAINOPT_STATMSG,dbVar.ptszVal);
db_free(&dbVar);
}
}
EnableWindow(GetDlgItem(hwndDlg,IDC_MAINOPT_STATMSG),(IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_CHANGESTATUSBOX) == BST_CHECKED) && (IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_USEDEFMSG) != BST_CHECKED));
ShowWindow(GetDlgItem(hwndDlg, IDC_MAINOPT_VARHELP), IsWindowEnabled(GetDlgItem(hwndDlg,IDC_MAINOPT_STATMSG)) && ServiceExists(MS_VARS_FORMATSTRING));
- return true;
- } break;
- case WM_USER+60:
+ }
+ return true;
+
+ case WM_USER+60:
{
bool fEnable = IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_CHANGESTATUSBOX) == BST_CHECKED;
EnableWindow(GetDlgItem(hwndDlg,IDC_MAINOPT_CHGSTS),fEnable);
@@ -170,89 +141,71 @@ INT_PTR CALLBACK MainOptDlg(HWND hwndDlg,UINT msg,WPARAM wParam,LPARAM lParam)
EnableWindow(GetDlgItem(hwndDlg,IDC_MAINOPT_ONLINEONLY),fEnable);
EnableWindow(GetDlgItem(hwndDlg,IDC_MAINOPT_USEDEFMSG),fEnable);
EnableWindow(GetDlgItem(hwndDlg,IDC_MAINOPT_PASS),IsDlgButtonChecked(hwndDlg,IDC_MAINOPT_REQPASS) == BST_CHECKED);
- return true;
- } break;
- case WM_COMMAND:
- {
- switch (HIWORD(wParam))
- {
- case CBN_SELCHANGE:
- {
- // check the type
- // if type doesn't require a msg, we don't use one
- if (LOWORD(wParam) == IDC_MAINOPT_CHGSTS)
- {
- SendMessage(hwndDlg,WM_USER + 50,0,0);
- }
- SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0);
- return 0;
- } break;
- case BN_CLICKED:
- {
- switch(LOWORD(wParam))
- {
- case IDC_MAINOPT_DISABLESNDS:
- case IDC_MAINOPT_SETONLINEBACK:
- case IDC_MAINOPT_ONLINEONLY:
- case IDC_MAINOPT_TRAYICON:
- {
- SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0);
- return true;
- } break;
- case IDC_MAINOPT_USEDEFMSG:
- {
- SendMessage(hwndDlg,WM_USER + 50,0,0);
- SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0);
- return true;
- } break;
- case IDC_MAINOPT_CHANGESTATUSBOX:
- {
- SendMessage(hwndDlg,WM_USER + 60,0,0);
- SendMessage(hwndDlg,WM_USER + 50,0,0);
- SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0);
- return true;
- } break;
- case IDC_MAINOPT_REQPASS:
- {
- SendMessage(hwndDlg,WM_USER + 60,0,0);
- SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0);
- return true;
- } break;
- case IDC_MAINOPT_VARHELP:
- {
- variables_showhelp(hwndDlg, IDC_MAINOPT_STATMSG, VHF_INPUT|VHF_HELP, 0, 0);
- SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0);
- return true;
- } break;
- case IDC_MAINOPT_LNK_HOTKEY:
- {
- OPENOPTIONSDIALOG ood = {0};
- ood.cbSize = sizeof(ood);
- ood.pszGroup = "Customize";
- ood.pszPage = "Hotkeys";
- Options_Open(&ood);
- return (true);
- } break;
- }
- return 0;
- } break;
- case EN_UPDATE:
- {
- switch( LOWORD( wParam )) {
- case IDC_MAINOPT_STATMSG:
- case IDC_MAINOPT_PASS:
- if (s_fRedraw)
- SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0);
- }
- } break;
- default:break;
+ }
+ return true;
+
+ case WM_COMMAND:
+ switch (HIWORD(wParam)) {
+ case CBN_SELCHANGE:
+ if (LOWORD(wParam) == IDC_MAINOPT_CHGSTS)
+ SendMessage(hwndDlg,WM_USER + 50,0,0);
+
+ SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0);
+ return 0;
+
+ case BN_CLICKED:
+ switch(LOWORD(wParam)) {
+ case IDC_MAINOPT_DISABLESNDS:
+ case IDC_MAINOPT_SETONLINEBACK:
+ case IDC_MAINOPT_ONLINEONLY:
+ case IDC_MAINOPT_TRAYICON:
+ SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0);
+ return true;
+
+ case IDC_MAINOPT_USEDEFMSG:
+ SendMessage(hwndDlg,WM_USER + 50,0,0);
+ SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0);
+ return true;
+
+ case IDC_MAINOPT_CHANGESTATUSBOX:
+ SendMessage(hwndDlg,WM_USER + 60,0,0);
+ SendMessage(hwndDlg,WM_USER + 50,0,0);
+ SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0);
+ return true;
+
+ case IDC_MAINOPT_REQPASS:
+ SendMessage(hwndDlg,WM_USER + 60,0,0);
+ SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0);
+ return true;
+
+ case IDC_MAINOPT_VARHELP:
+ variables_showhelp(hwndDlg, IDC_MAINOPT_STATMSG, VHF_INPUT|VHF_HELP, 0, 0);
+ SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0);
+ return true;
+
+ case IDC_MAINOPT_LNK_HOTKEY:
+ OPENOPTIONSDIALOG ood = {0};
+ ood.cbSize = sizeof(ood);
+ ood.pszGroup = "Customize";
+ ood.pszPage = "Hotkeys";
+ Options_Open(&ood);
+ return (true);
}
- } break;
- case WM_DESTROY:
- {
- g_fOptionsOpen = false;
return 0;
- } break;
+
+ case EN_UPDATE:
+ switch( LOWORD( wParam )) {
+ case IDC_MAINOPT_STATMSG:
+ case IDC_MAINOPT_PASS:
+ if (s_fRedraw)
+ SendMessage(GetParent(hwndDlg),PSM_CHANGED,(WPARAM)hwndDlg,0);
+ }
+ }
+ break;
+
+ case WM_DESTROY:
+ g_fOptionsOpen = false;
+ return 0;
}
return(false);
}
diff --git a/plugins/CrashDumper/src/ui.cpp b/plugins/CrashDumper/src/ui.cpp
index d8a616c370..66da7e6b6c 100644
--- a/plugins/CrashDumper/src/ui.cpp
+++ b/plugins/CrashDumper/src/ui.cpp
@@ -205,7 +205,6 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
db_free(&dbv);
}
if (db_get_s(NULL, PluginName, "Password", &dbv) == 0) {
- CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal)+1, (LPARAM)dbv.pszVal);
SetDlgItemTextA(hwndDlg, IDC_PASSWORD, dbv.pszVal);
db_free(&dbv);
}
@@ -227,7 +226,6 @@ INT_PTR CALLBACK DlgProcOptions(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
db_set_s(NULL, PluginName, "Username", szSetting);
GetDlgItemTextA(hwndDlg, IDC_PASSWORD, szSetting, SIZEOF(szSetting));
- CallService(MS_DB_CRYPT_ENCODESTRING, SIZEOF(szSetting), (LPARAM)szSetting);
db_set_s(NULL, PluginName, "Password", szSetting);
db_set_b(NULL, PluginName, "UploadChanged",
diff --git a/plugins/CrashDumper/src/upload.cpp b/plugins/CrashDumper/src/upload.cpp
index da280a1959..dfe664396e 100644
--- a/plugins/CrashDumper/src/upload.cpp
+++ b/plugins/CrashDumper/src/upload.cpp
@@ -46,8 +46,6 @@ void GetLoginStr(char* user, size_t szuser, char* pass)
else user[0] = 0;
if (db_get_s(NULL, PluginName, "Password", &dbv) == 0) {
- CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal)+1, (LPARAM)dbv.pszVal);
-
BYTE hash[16];
mir_md5_state_t context;
diff --git a/plugins/Db3x_mmap/src/dbsettings.cpp b/plugins/Db3x_mmap/src/dbsettings.cpp
index e00cd92c93..d0ea542bb5 100644
--- a/plugins/Db3x_mmap/src/dbsettings.cpp
+++ b/plugins/Db3x_mmap/src/dbsettings.cpp
@@ -37,6 +37,41 @@ DWORD __forceinline GetSettingValueLength(PBYTE pSetting)
#define MoveAlong(n) {int x = n; pBlob += (x); ofsBlobPtr += (x); bytesRemaining -= (x);}
#define VLT(n) ((n == DBVT_UTF8)?DBVT_ASCIIZ:n)
+static bool isEncrypted(LPCSTR szModule, LPCSTR szSetting)
+{
+ if (!_strnicmp(szSetting, "password", 8)) return true;
+ if (!strcmp(szSetting, "NLProxyAuthPassword")) return true;
+ if (!strcmp(szSetting, "FileProxyPassword")) return true;
+ if (!strcmp(szSetting, "TokenSecret")) return true;
+
+ if (!strcmp(szModule, "SecureIM")) {
+ if (!strcmp(szSetting, "pgp")) return true;
+ if (!strcmp(szSetting, "pgpPrivKey")) return true;
+ }
+ return false;
+}
+
+//VERY VERY VERY BASIC ENCRYPTION FUNCTION
+
+static void Encrypt(char *msg, BOOL up)
+{
+ int jump = (up) ? 5 : -5;
+ for (int i = 0; msg[i]; i++)
+ msg[i] = msg[i] + jump;
+}
+
+__forceinline void EncodeString(LPSTR buf)
+{
+ Encrypt(buf, TRUE);
+}
+
+__forceinline void DecodeString(LPSTR buf)
+{
+ Encrypt(buf, FALSE);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
int CDb3Base::GetContactSettingWorker(HANDLE hContact,DBCONTACTGETSETTING *dbcgs,int isStatic)
{
DWORD ofsModuleName,ofsContact,ofsSettingsGroup,ofsBlobPtr;
@@ -92,6 +127,8 @@ int CDb3Base::GetContactSettingWorker(HANDLE hContact,DBCONTACTGETSETTING *dbcgs
dbcgs->pValue->pszVal = (char*)mir_alloc(strlen(pCachedValue->pszVal)+1);
strcpy(dbcgs->pValue->pszVal,pCachedValue->pszVal);
}
+ if (isEncrypted(dbcgs->szModule, dbcgs->szSetting))
+ DecodeString(dbcgs->pValue->pszVal);
}
else memcpy( dbcgs->pValue, pCachedValue, sizeof( DBVARIANT ));
@@ -114,6 +151,7 @@ int CDb3Base::GetContactSettingWorker(HANDLE hContact,DBCONTACTGETSETTING *dbcgs
ofsSettingsGroup = GetSettingsGroupOfsByModuleNameOfs(&dbc,ofsContact,ofsModuleName);
if (ofsSettingsGroup) {
+ bool bEncrypted = false;
ofsBlobPtr = ofsSettingsGroup+offsetof(DBContactSettings,blob);
pBlob = DBRead(ofsBlobPtr,sizeof(DBContactSettings),&bytesRemaining);
while (pBlob[0]) {
@@ -135,6 +173,7 @@ int CDb3Base::GetContactSettingWorker(HANDLE hContact,DBCONTACTGETSETTING *dbcgs
case DBVT_DWORD: DecodeCopyMemory(&(dbcgs->pValue->dVal), (PDWORD)(pBlob+1), 4); break;
case DBVT_UTF8:
case DBVT_ASCIIZ:
+ bEncrypted = isEncrypted(dbcgs->szModule, dbcgs->szSetting);
NeedBytes(3+*(PWORD)(pBlob+1));
if (isStatic) {
dbcgs->pValue->cchVal--;
@@ -164,13 +203,18 @@ int CDb3Base::GetContactSettingWorker(HANDLE hContact,DBCONTACTGETSETTING *dbcgs
}
/**** add to cache **********************/
- if ( dbcgs->pValue->type != DBVT_BLOB ) {
- DBVARIANT* pCachedValue = m_cache->GetCachedValuePtr( hContact, szCachedSettingName, 1 );
- if ( pCachedValue != NULL ) {
+ if (dbcgs->pValue->type != DBVT_BLOB && !bEncrypted) {
+ DBVARIANT* pCachedValue = m_cache->GetCachedValuePtr(hContact, szCachedSettingName, 1);
+ if (pCachedValue != NULL) {
m_cache->SetCachedVariant(dbcgs->pValue, pCachedValue);
log3("set cached [%08p] %s (%p)", hContact, szCachedSettingName, pCachedValue);
}
}
+
+ // don't cache decrypted values
+ if (dbcgs->pValue->type == DBVT_UTF8 || dbcgs->pValue->type == DBVT_ASCIIZ)
+ if (bEncrypted)
+ DecodeString(dbcgs->pValue->pszVal);
return 0;
}
NeedBytes(1);
@@ -181,8 +225,7 @@ int CDb3Base::GetContactSettingWorker(HANDLE hContact,DBCONTACTGETSETTING *dbcgs
} }
/**** add missing setting to cache **********************/
- if ( dbcgs->pValue->type != DBVT_BLOB )
- {
+ if ( dbcgs->pValue->type != DBVT_BLOB ) {
DBVARIANT* pCachedValue = m_cache->GetCachedValuePtr( hContact, szCachedSettingName, 1 );
if ( pCachedValue != NULL ) {
pCachedValue->type = DBVT_DELETED;
@@ -400,7 +443,7 @@ STDMETHODIMP_(BOOL) CDb3Base::WriteContactSetting(HANDLE hContact, DBCONTACTWRIT
char* szCachedSettingName = m_cache->GetCachedSetting(tmp.szModule, tmp.szSetting, moduleNameLen, settingNameLen);
log3("set [%08p] %s (%p)", hContact, szCachedSettingName, szCachedSettingName);
- if ( tmp.value.type != DBVT_BLOB ) {
+ if (tmp.value.type != DBVT_BLOB && !isEncrypted(dbcws->szModule, dbcws->szSetting)) {
DBVARIANT *pCachedValue = m_cache->GetCachedValuePtr(hContact, szCachedSettingName, 1);
if ( pCachedValue != NULL ) {
bool bIsIdentical = false;
@@ -410,7 +453,7 @@ STDMETHODIMP_(BOOL) CDb3Base::WriteContactSetting(HANDLE hContact, DBCONTACTWRIT
case DBVT_WORD: bIsIdentical = pCachedValue->wVal == tmp.value.wVal; break;
case DBVT_DWORD: bIsIdentical = pCachedValue->dVal == tmp.value.dVal; break;
case DBVT_UTF8:
- case DBVT_ASCIIZ: bIsIdentical = strcmp( pCachedValue->pszVal, tmp.value.pszVal ) == 0; break;
+ case DBVT_ASCIIZ: bIsIdentical = strcmp(pCachedValue->pszVal, tmp.value.pszVal) == 0; break;
}
if ( bIsIdentical )
return 0;
@@ -479,11 +522,10 @@ STDMETHODIMP_(BOOL) CDb3Base::WriteContactSetting(HANDLE hContact, DBCONTACTWRIT
NeedBytes(3);
if (pBlob[0] != tmp.value.type || ((pBlob[0] == DBVT_ASCIIZ || pBlob[0] == DBVT_UTF8) && *(PWORD)(pBlob+1) != strlen(tmp.value.pszVal)) || (pBlob[0] == DBVT_BLOB && *(PWORD)(pBlob+1) != tmp.value.cpbVal)) {
//bin it
- int nameLen,valLen;
DWORD ofsSettingToCut;
NeedBytes(3);
- nameLen = 1+settingNameLen;
- valLen = 1+GetSettingValueLength(pBlob);
+ int nameLen = 1+settingNameLen;
+ int valLen = 1 + GetSettingValueLength(pBlob);
ofsSettingToCut = ofsBlobPtr-nameLen;
MoveAlong(valLen);
NeedBytes(1);
@@ -501,12 +543,16 @@ STDMETHODIMP_(BOOL) CDb3Base::WriteContactSetting(HANDLE hContact, DBCONTACTWRIT
//replace existing setting at pBlob
MoveAlong(1); //skip data type
switch(tmp.value.type) {
- case DBVT_BYTE: DBWrite(ofsBlobPtr,&tmp.value.bVal,1); break;
- case DBVT_WORD: EncodeDBWrite(ofsBlobPtr,&tmp.value.wVal,2); break;
+ case DBVT_BYTE: DBWrite(ofsBlobPtr,&tmp.value.bVal,1); break;
+ case DBVT_WORD: EncodeDBWrite(ofsBlobPtr,&tmp.value.wVal,2); break;
case DBVT_DWORD: EncodeDBWrite(ofsBlobPtr,&tmp.value.dVal,4); break;
+ case DBVT_BLOB: EncodeDBWrite(ofsBlobPtr + 2, tmp.value.pbVal, tmp.value.cpbVal); break;
case DBVT_UTF8:
- case DBVT_ASCIIZ: EncodeDBWrite(ofsBlobPtr+2,tmp.value.pszVal,(int)strlen(tmp.value.pszVal)); break;
- case DBVT_BLOB: EncodeDBWrite(ofsBlobPtr+2,tmp.value.pbVal,tmp.value.cpbVal); break;
+ case DBVT_ASCIIZ:
+ if (isEncrypted(dbcws->szModule, dbcws->szSetting))
+ EncodeString(tmp.value.pszVal);
+ EncodeDBWrite(ofsBlobPtr+2,tmp.value.pszVal,(int)strlen(tmp.value.pszVal));
+ break;
}
//quit
DBFlush(1);
@@ -577,7 +623,10 @@ STDMETHODIMP_(BOOL) CDb3Base::WriteContactSetting(HANDLE hContact, DBCONTACTWRIT
case DBVT_DWORD: EncodeDBWrite(ofsBlobPtr,&tmp.value.dVal,4); MoveAlong(4); break;
case DBVT_UTF8:
case DBVT_ASCIIZ:
- { int len = (int)strlen(tmp.value.pszVal);
+ {
+ int len = (int)strlen(tmp.value.pszVal);
+ if (isEncrypted(dbcws->szModule, dbcws->szSetting))
+ EncodeString(tmp.value.pszVal);
DBWrite(ofsBlobPtr,&len,2);
EncodeDBWrite(ofsBlobPtr+2,tmp.value.pszVal,len);
MoveAlong(2+len);
diff --git a/plugins/DbEditorPP/src/settinglist.cpp b/plugins/DbEditorPP/src/settinglist.cpp
index 1d87461333..db3f939418 100644
--- a/plugins/DbEditorPP/src/settinglist.cpp
+++ b/plugins/DbEditorPP/src/settinglist.cpp
@@ -1076,12 +1076,8 @@ void SettingsListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here
///////////////////////// convert to submenu
case MENU_VIEWDECRYPT:
if (!db_get(hContact,module,setting,&dbv) && dbv.type == DBVT_ASCIIZ) {
- if (lstrcmpA(setting, "LoginPassword")) {
- char *text = mir_strdup(dbv.pszVal);
- CallService(MS_DB_CRYPT_DECODESTRING, (WPARAM)lstrlenA(dbv.pszVal)+1, (LPARAM)text);
- msg(text, Translate("Decoded string.."));
- mir_free(text);
- }
+ if (lstrcmpA(setting, "LoginPassword"))
+ msg(dbv.pszVal, Translate("Decoded string.."));
else {
char *str = mir_strdup(dbv.pszVal);
char *str1 = str;
@@ -1100,32 +1096,20 @@ void SettingsListRightClick(HWND hwnd, WPARAM wParam,LPARAM lParam) // hwnd here
break;
case MENU_VIEWENCRYPT:
- if (!db_get(hContact,module,setting,&dbv) && dbv.type == DBVT_ASCIIZ) {
- char *text = mir_tstrdup(dbv.pszVal);
- CallService(MS_DB_CRYPT_ENCODESTRING, (WPARAM)strlen(dbv.pszVal)+1, (LPARAM)text);
- msg(text, Translate("Encoded string.."));
- mir_free(text);
- }
+ if (!db_get(hContact,module,setting,&dbv) && dbv.type == DBVT_ASCIIZ)
+ msg(dbv.pszVal, Translate("Encoded string.."));
db_free(&dbv);
break;
case MENU_DECRYPT:
- if (!db_get(hContact,module,setting,&dbv) && dbv.type == DBVT_ASCIIZ) {
- char *text = mir_tstrdup(dbv.pszVal);
- CallService(MS_DB_CRYPT_DECODESTRING, (WPARAM)strlen(dbv.pszVal)+1, (LPARAM)text);
- db_set_s(hContact,module,setting,text);
- mir_free(text);
- }
+ if (!db_get_s(hContact,module,setting,&dbv))
+ db_set_s(hContact,module,setting,dbv.pszVal);
db_free(&dbv);
break;
case MENU_ENCRYPT:
- if (!db_get(hContact,module,setting,&dbv) && dbv.type == DBVT_ASCIIZ) {
- char *text = mir_tstrdup(dbv.pszVal);
- CallService(MS_DB_CRYPT_ENCODESTRING, (WPARAM)strlen(dbv.pszVal)+1, (LPARAM)text);
- db_set_s(hContact,module,setting,text);
- mir_free(text);
- }
+ if (!db_get_s(hContact,module,setting,&dbv))
+ db_set_s(hContact,module,setting,dbv.pszVal);
db_free(&dbv);
break;
diff --git a/plugins/Dbx_mmap_SA/src/commonheaders.h b/plugins/Dbx_mmap_SA/src/commonheaders.h
index cfee1a77ae..877f0ff65d 100644
--- a/plugins/Dbx_mmap_SA/src/commonheaders.h
+++ b/plugins/Dbx_mmap_SA/src/commonheaders.h
@@ -59,11 +59,6 @@ extern HGENMENU hSetPwdMenu;
#endif
//global procedures
-//int InitSkin();
-void EncodeCopyMemory(void * dst, void * src, size_t size );
-void DecodeCopyMemory(void * dst, void * src, size_t size );
-void EncodeDBWrite(DWORD ofs, void * src, size_t size);
-void DecodeDBWrite(DWORD ofs, void * src, size_t size);
struct DlgStdInProcParam
{
diff --git a/plugins/Dbx_tree/src/Compatibility.cpp b/plugins/Dbx_tree/src/Compatibility.cpp
index 23cca177e5..921b772370 100644
--- a/plugins/Dbx_tree/src/Compatibility.cpp
+++ b/plugins/Dbx_tree/src/Compatibility.cpp
@@ -153,6 +153,43 @@ STDMETHODIMP_(HANDLE) CDataBase::FindNextContact(HANDLE hContact, const char* sz
return NULL;
}
+/////////////////////////////////////////////////////////////////////////////////////////
+
+static bool isEncrypted(LPCSTR szModule, LPCSTR szSetting)
+{
+ if (!_strnicmp(szSetting, "password", 8)) return true;
+ if (!strcmp(szSetting, "NLProxyAuthPassword")) return true;
+ if (!strcmp(szSetting, "FileProxyPassword")) return true;
+ if (!strcmp(szSetting, "TokenSecret")) return true;
+
+ if (!strcmp(szModule, "SecureIM")) {
+ if (!strcmp(szSetting, "pgp")) return true;
+ if (!strcmp(szSetting, "pgpPrivKey")) return true;
+ }
+ return false;
+}
+
+//VERY VERY VERY BASIC ENCRYPTION FUNCTION
+
+static void Encrypt(char *msg, BOOL up)
+{
+ int jump = (up) ? 5 : -5;
+ for (int i = 0; msg[i]; i++)
+ msg[i] = msg[i] + jump;
+}
+
+__forceinline void EncodeString(LPSTR buf)
+{
+ Encrypt(buf, TRUE);
+}
+
+__forceinline void DecodeString(LPSTR buf)
+{
+ Encrypt(buf, FALSE);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
STDMETHODIMP_(BOOL) CDataBase::GetContactSetting(HANDLE hContact, DBCONTACTGETSETTING *dbcgs)
{
dbcgs->pValue->type = 0;
@@ -181,67 +218,61 @@ STDMETHODIMP_(BOOL) CDataBase::GetContactSetting(HANDLE hContact, DBCONTACTGETSE
if (DBSettingRead(reinterpret_cast<WPARAM>(&set), 0) == DBT_INVALIDPARAM)
return -1;
- switch (set.Type)
- {
- case DBT_ST_ANSI:
- {
- dbcgs->pValue->type = DBVT_ASCIIZ;
- dbcgs->pValue->pszVal = set.Value.pAnsi;
- dbcgs->pValue->cchVal = set.Value.Length - 1;
- } break;
- case DBT_ST_UTF8:
- {
- dbcgs->pValue->type = DBVT_WCHAR;
- dbcgs->pValue->pwszVal = mir_utf8decodeW(set.Value.pUTF8);
- if (dbcgs->pValue->pwszVal)
- dbcgs->pValue->cchVal = static_cast<uint32_t>(wcslen(dbcgs->pValue->pwszVal));
- else
- dbcgs->pValue->cchVal = 0;
- mir_free(set.Value.pUTF8);
- } break;
- case DBT_ST_WCHAR:
- {
- dbcgs->pValue->type = DBVT_WCHAR;
- dbcgs->pValue->pwszVal = set.Value.pWide;
- dbcgs->pValue->cchVal = set.Value.Length - 1;
- } break;
- case DBT_ST_BLOB:
- {
- dbcgs->pValue->type = DBVT_BLOB;
- dbcgs->pValue->pbVal = set.Value.pBlob;
- dbcgs->pValue->cpbVal = set.Value.Length;
- } break;
- case DBT_ST_BOOL:
- {
- dbcgs->pValue->type = DBVT_BYTE;
- dbcgs->pValue->bVal = (uint8_t)set.Value.Bool;
- } break;
- case DBT_ST_BYTE: case DBT_ST_CHAR:
- {
- dbcgs->pValue->type = DBVT_BYTE;
- dbcgs->pValue->bVal = set.Value.Byte;
- } break;
- case DBT_ST_SHORT: case DBT_ST_WORD:
- {
- dbcgs->pValue->type = DBVT_WORD;
- dbcgs->pValue->wVal = set.Value.Word;
- } break;
- case DBT_ST_INT: case DBT_ST_DWORD:
- {
- dbcgs->pValue->type = DBVT_DWORD;
- dbcgs->pValue->dVal = set.Value.DWord;
- } break;
- case DBT_ST_INT64: case DBT_ST_QWORD:
- case DBT_ST_DOUBLE: case DBT_ST_FLOAT:
- {
- dbcgs->pValue->type = DBVT_BLOB;
- dbcgs->pValue->cpbVal = sizeof(set.Value);
- dbcgs->pValue->pbVal = reinterpret_cast<BYTE*>(mir_alloc(sizeof(set.Value)));
- memcpy(dbcgs->pValue->pbVal, &set.Value, sizeof(set.Value));
- } break;
-
- default:
- return -1;
+ switch (set.Type) {
+ case DBT_ST_ANSI:
+ dbcgs->pValue->type = DBVT_ASCIIZ;
+ dbcgs->pValue->pszVal = set.Value.pAnsi;
+ dbcgs->pValue->cchVal = set.Value.Length - 1;
+ if (isEncrypted(dbcgs->szModule, dbcgs->szSetting))
+ DecodeString(dbcgs->pValue->pszVal);
+ break;
+ case DBT_ST_UTF8:
+ if (isEncrypted(dbcgs->szModule, dbcgs->szSetting))
+ DecodeString(set.Value.pUTF8);
+ dbcgs->pValue->type = DBVT_WCHAR;
+ dbcgs->pValue->pwszVal = mir_utf8decodeW(set.Value.pUTF8);
+ if (dbcgs->pValue->pwszVal)
+ dbcgs->pValue->cchVal = static_cast<uint32_t>(wcslen(dbcgs->pValue->pwszVal));
+ else
+ dbcgs->pValue->cchVal = 0;
+ mir_free(set.Value.pUTF8);
+ break;
+ case DBT_ST_WCHAR:
+ dbcgs->pValue->type = DBVT_WCHAR;
+ dbcgs->pValue->pwszVal = set.Value.pWide;
+ dbcgs->pValue->cchVal = set.Value.Length - 1;
+ break;
+ case DBT_ST_BLOB:
+ dbcgs->pValue->type = DBVT_BLOB;
+ dbcgs->pValue->pbVal = set.Value.pBlob;
+ dbcgs->pValue->cpbVal = set.Value.Length;
+ break;
+ case DBT_ST_BOOL:
+ dbcgs->pValue->type = DBVT_BYTE;
+ dbcgs->pValue->bVal = (uint8_t)set.Value.Bool;
+ break;
+ case DBT_ST_BYTE: case DBT_ST_CHAR:
+ dbcgs->pValue->type = DBVT_BYTE;
+ dbcgs->pValue->bVal = set.Value.Byte;
+ break;
+ case DBT_ST_SHORT: case DBT_ST_WORD:
+ dbcgs->pValue->type = DBVT_WORD;
+ dbcgs->pValue->wVal = set.Value.Word;
+ break;
+ case DBT_ST_INT: case DBT_ST_DWORD:
+ dbcgs->pValue->type = DBVT_DWORD;
+ dbcgs->pValue->dVal = set.Value.DWord;
+ break;
+ case DBT_ST_INT64: case DBT_ST_QWORD:
+ case DBT_ST_DOUBLE: case DBT_ST_FLOAT:
+ dbcgs->pValue->type = DBVT_BLOB;
+ dbcgs->pValue->cpbVal = sizeof(set.Value);
+ dbcgs->pValue->pbVal = reinterpret_cast<BYTE*>(mir_alloc(sizeof(set.Value)));
+ memcpy(dbcgs->pValue->pbVal, &set.Value, sizeof(set.Value));
+ break;
+
+ default:
+ return -1;
}
return 0;
@@ -272,9 +303,7 @@ STDMETHODIMP_(BOOL) CDataBase::GetContactSettingStr(HANDLE hContact, DBCONTACTGE
set.cbSize = sizeof(set);
set.Descriptor = &desc;
-
- switch (dbcgs->pValue->type)
- {
+ switch (dbcgs->pValue->type) {
case DBVT_ASCIIZ: set.Type = DBT_ST_ANSI; break;
case DBVT_BLOB: set.Type = DBT_ST_BLOB; break;
case DBVT_UTF8: set.Type = DBT_ST_UTF8; break;
@@ -284,69 +313,65 @@ STDMETHODIMP_(BOOL) CDataBase::GetContactSettingStr(HANDLE hContact, DBCONTACTGE
if (DBSettingRead(reinterpret_cast<WPARAM>(&set), 0) == DBT_INVALIDPARAM)
return -1;
- switch (set.Type)
- {
- case DBT_ST_ANSI:
- {
- dbcgs->pValue->type = DBVT_ASCIIZ;
- dbcgs->pValue->pszVal = set.Value.pAnsi;
+ switch (set.Type) {
+ case DBT_ST_ANSI:
+ dbcgs->pValue->type = DBVT_ASCIIZ;
+ dbcgs->pValue->pszVal = set.Value.pAnsi;
+ dbcgs->pValue->cchVal = set.Value.Length - 1;
+ if (isEncrypted(dbcgs->szModule, dbcgs->szSetting))
+ DecodeString(dbcgs->pValue->pszVal);
+ break;
+ case DBT_ST_UTF8:
+ dbcgs->pValue->type = DBVT_UTF8;
+ dbcgs->pValue->pszVal = set.Value.pUTF8;
+ dbcgs->pValue->cchVal = set.Value.Length - 1;
+ if (isEncrypted(dbcgs->szModule, dbcgs->szSetting))
+ DecodeString(dbcgs->pValue->pszVal);
+ break;
+ case DBT_ST_WCHAR:
+ if (dbcgs->pValue->type == DBVT_WCHAR) {
+ dbcgs->pValue->pwszVal = set.Value.pWide;
dbcgs->pValue->cchVal = set.Value.Length - 1;
- } break;
- case DBT_ST_UTF8:
- {
+ }
+ else {
dbcgs->pValue->type = DBVT_UTF8;
- dbcgs->pValue->pszVal = set.Value.pUTF8;
- dbcgs->pValue->cchVal = set.Value.Length - 1;
- } break;
- case DBT_ST_WCHAR:
- {
- if (dbcgs->pValue->type == DBVT_WCHAR)
- {
- dbcgs->pValue->pwszVal = set.Value.pWide;
- dbcgs->pValue->cchVal = set.Value.Length - 1;
- } else {
- dbcgs->pValue->type = DBVT_UTF8;
- dbcgs->pValue->pszVal = mir_utf8encodeW(set.Value.pWide);
- dbcgs->pValue->cchVal = static_cast<uint32_t>(strlen(dbcgs->pValue->pszVal));
- mir_free(set.Value.pWide);
- }
- } break;
- case DBT_ST_BLOB:
- {
- dbcgs->pValue->type = DBVT_BLOB;
- dbcgs->pValue->pbVal = set.Value.pBlob;
- dbcgs->pValue->cpbVal = set.Value.Length;
- } break;
- case DBT_ST_BOOL:
- {
- dbcgs->pValue->type = DBVT_BYTE;
- dbcgs->pValue->bVal = (uint8_t)set.Value.Bool;
- } break;
- case DBT_ST_BYTE: case DBT_ST_CHAR:
- {
- dbcgs->pValue->type = DBVT_BYTE;
- dbcgs->pValue->bVal = set.Value.Byte;
- } break;
- case DBT_ST_SHORT: case DBT_ST_WORD:
- {
- dbcgs->pValue->type = DBVT_WORD;
- dbcgs->pValue->wVal = set.Value.Word;
- } break;
- case DBT_ST_INT: case DBT_ST_DWORD:
- {
- dbcgs->pValue->type = DBVT_DWORD;
- dbcgs->pValue->dVal = set.Value.DWord;
- } break;
- case DBT_ST_INT64: case DBT_ST_QWORD:
- case DBT_ST_DOUBLE: case DBT_ST_FLOAT:
- {
- dbcgs->pValue->type = DBVT_BLOB;
- dbcgs->pValue->cpbVal = sizeof(set.Value);
- dbcgs->pValue->pbVal = reinterpret_cast<BYTE*>(mir_alloc(sizeof(set.Value)));
- memcpy(dbcgs->pValue->pbVal, &set.Value, sizeof(set.Value));
- } break;
- default:
- return -1;
+ dbcgs->pValue->pszVal = mir_utf8encodeW(set.Value.pWide);
+ dbcgs->pValue->cchVal = static_cast<uint32_t>(strlen(dbcgs->pValue->pszVal));
+ if (isEncrypted(dbcgs->szModule, dbcgs->szSetting))
+ DecodeString(dbcgs->pValue->pszVal);
+ mir_free(set.Value.pWide);
+ }
+ break;
+ case DBT_ST_BLOB:
+ dbcgs->pValue->type = DBVT_BLOB;
+ dbcgs->pValue->pbVal = set.Value.pBlob;
+ dbcgs->pValue->cpbVal = set.Value.Length;
+ break;
+ case DBT_ST_BOOL:
+ dbcgs->pValue->type = DBVT_BYTE;
+ dbcgs->pValue->bVal = (uint8_t)set.Value.Bool;
+ break;
+ case DBT_ST_BYTE: case DBT_ST_CHAR:
+ dbcgs->pValue->type = DBVT_BYTE;
+ dbcgs->pValue->bVal = set.Value.Byte;
+ break;
+ case DBT_ST_SHORT: case DBT_ST_WORD:
+ dbcgs->pValue->type = DBVT_WORD;
+ dbcgs->pValue->wVal = set.Value.Word;
+ break;
+ case DBT_ST_INT: case DBT_ST_DWORD:
+ dbcgs->pValue->type = DBVT_DWORD;
+ dbcgs->pValue->dVal = set.Value.DWord;
+ break;
+ case DBT_ST_INT64: case DBT_ST_QWORD:
+ case DBT_ST_DOUBLE: case DBT_ST_FLOAT:
+ dbcgs->pValue->type = DBVT_BLOB;
+ dbcgs->pValue->cpbVal = sizeof(set.Value);
+ dbcgs->pValue->pbVal = reinterpret_cast<BYTE*>(mir_alloc(sizeof(set.Value)));
+ memcpy(dbcgs->pValue->pbVal, &set.Value, sizeof(set.Value));
+ break;
+ default:
+ return -1;
}
return 0;
@@ -381,92 +406,86 @@ STDMETHODIMP_(BOOL) CDataBase::GetContactSettingStatic(HANDLE hContact, DBCONTAC
return -1;
}
- switch (set.Type)
- {
- case DBT_ST_ANSI:
- {
- if (dbcgs->pValue->cchVal < set.Value.Length)
- {
- memcpy(dbcgs->pValue->pszVal, set.Value.pAnsi, dbcgs->pValue->cchVal);
- dbcgs->pValue->pszVal[dbcgs->pValue->cchVal - 1] = 0;
- } else {
- memcpy(dbcgs->pValue->pszVal, set.Value.pAnsi, set.Value.Length);
- }
- dbcgs->pValue->type = DBVT_ASCIIZ;
- dbcgs->pValue->cchVal = set.Value.Length - 1;
+ switch (set.Type) {
+ case DBT_ST_ANSI:
+ if (dbcgs->pValue->cchVal < set.Value.Length) {
+ memcpy(dbcgs->pValue->pszVal, set.Value.pAnsi, dbcgs->pValue->cchVal);
+ dbcgs->pValue->pszVal[dbcgs->pValue->cchVal - 1] = 0;
+ }
+ else memcpy(dbcgs->pValue->pszVal, set.Value.pAnsi, set.Value.Length);
+
+ dbcgs->pValue->type = DBVT_ASCIIZ;
+ dbcgs->pValue->cchVal = set.Value.Length - 1;
+ if (isEncrypted(dbcgs->szModule, dbcgs->szSetting))
+ DecodeString(dbcgs->pValue->pszVal);
+
+ mir_free(set.Value.pAnsi);
+ break;
+ case DBT_ST_UTF8:
+ set.Value.pUTF8 = mir_utf8decode(set.Value.pUTF8, NULL);
+ set.Value.Length = static_cast<uint32_t>(strlen(set.Value.pUTF8));
+
+ if (dbcgs->pValue->cchVal < set.Value.Length) {
+ memcpy(dbcgs->pValue->pszVal, set.Value.pUTF8, dbcgs->pValue->cchVal);
+ dbcgs->pValue->pszVal[dbcgs->pValue->cchVal - 1] = 0;
+ }
+ else memcpy(dbcgs->pValue->pszVal, set.Value.pUTF8, set.Value.Length);
- mir_free(set.Value.pAnsi);
- } break;
- case DBT_ST_UTF8:
- {
- set.Value.pUTF8 = mir_utf8decode(set.Value.pUTF8, NULL);
- set.Value.Length = static_cast<uint32_t>(strlen(set.Value.pUTF8));
-
- if (dbcgs->pValue->cchVal < set.Value.Length)
- {
- memcpy(dbcgs->pValue->pszVal, set.Value.pUTF8, dbcgs->pValue->cchVal);
- dbcgs->pValue->pszVal[dbcgs->pValue->cchVal - 1] = 0;
- } else {
- memcpy(dbcgs->pValue->pszVal, set.Value.pUTF8, set.Value.Length);
- }
- dbcgs->pValue->type = DBVT_ASCIIZ;
- dbcgs->pValue->cchVal = set.Value.Length - 1;
+ dbcgs->pValue->type = DBVT_ASCIIZ;
+ dbcgs->pValue->cchVal = set.Value.Length - 1;
+ if (isEncrypted(dbcgs->szModule, dbcgs->szSetting))
+ DecodeString(dbcgs->pValue->pszVal);
- mir_free(set.Value.pUTF8);
- } break;
- case DBT_ST_WCHAR:
+ mir_free(set.Value.pUTF8);
+ break;
+ case DBT_ST_WCHAR:
{
- char * tmp = mir_u2a(set.Value.pWide);
+ char *tmp = mir_u2a(set.Value.pWide);
WORD l = static_cast<WORD>(strlen(tmp));
mir_free(set.Value.pWide);
- if (dbcgs->pValue->cchVal < l + 1)
- {
+ if (dbcgs->pValue->cchVal < l + 1) {
memcpy(dbcgs->pValue->pszVal, tmp, dbcgs->pValue->cchVal);
dbcgs->pValue->pszVal[l] = 0;
- } else {
- memcpy(dbcgs->pValue->pszVal, tmp, l + 1);
}
+ else memcpy(dbcgs->pValue->pszVal, tmp, l + 1);
+
dbcgs->pValue->type = DBVT_ASCIIZ;
dbcgs->pValue->cchVal = l;
+ if (isEncrypted(dbcgs->szModule, dbcgs->szSetting))
+ DecodeString(dbcgs->pValue->pszVal);
mir_free(tmp);
- } break;
- case DBT_ST_BLOB:
- {
- if (dbcgs->pValue->cchVal < set.Value.Length)
- {
- memcpy(dbcgs->pValue->pbVal, set.Value.pBlob, dbcgs->pValue->cchVal);
- } else {
- memcpy(dbcgs->pValue->pbVal, set.Value.pBlob, set.Value.Length);
- }
- dbcgs->pValue->type = DBVT_BLOB;
- dbcgs->pValue->cchVal = set.Value.Length;
-
- mir_free(set.Value.pBlob);
- } break;
- case DBT_ST_BOOL:
- {
- dbcgs->pValue->type = DBVT_BYTE;
- dbcgs->pValue->bVal = set.Value.Bool ? TRUE : FALSE;
- } break;
- case DBT_ST_BYTE: case DBT_ST_CHAR:
- {
- dbcgs->pValue->type = DBVT_BYTE;
- dbcgs->pValue->bVal = set.Value.Byte;
- } break;
- case DBT_ST_SHORT: case DBT_ST_WORD:
- {
- dbcgs->pValue->type = DBVT_WORD;
- dbcgs->pValue->wVal = set.Value.Word;
- } break;
- case DBT_ST_INT: case DBT_ST_DWORD:
- {
- dbcgs->pValue->type = DBVT_DWORD;
- dbcgs->pValue->dVal = set.Value.DWord;
- } break;
- default:
- return -1;
+ }
+ break;
+ case DBT_ST_BLOB:
+ if (dbcgs->pValue->cchVal < set.Value.Length)
+ memcpy(dbcgs->pValue->pbVal, set.Value.pBlob, dbcgs->pValue->cchVal);
+ else
+ memcpy(dbcgs->pValue->pbVal, set.Value.pBlob, set.Value.Length);
+
+ dbcgs->pValue->type = DBVT_BLOB;
+ dbcgs->pValue->cchVal = set.Value.Length;
+ mir_free(set.Value.pBlob);
+ break;
+ case DBT_ST_BOOL:
+ dbcgs->pValue->type = DBVT_BYTE;
+ dbcgs->pValue->bVal = set.Value.Bool ? TRUE : FALSE;
+ break;
+ case DBT_ST_BYTE: case DBT_ST_CHAR:
+ dbcgs->pValue->type = DBVT_BYTE;
+ dbcgs->pValue->bVal = set.Value.Byte;
+ break;
+ case DBT_ST_SHORT: case DBT_ST_WORD:
+ dbcgs->pValue->type = DBVT_WORD;
+ dbcgs->pValue->wVal = set.Value.Word;
+ break;
+ case DBT_ST_INT: case DBT_ST_DWORD:
+ dbcgs->pValue->type = DBVT_DWORD;
+ dbcgs->pValue->dVal = set.Value.DWord;
+ break;
+ default:
+ return -1;
}
return 0;
@@ -474,12 +493,11 @@ STDMETHODIMP_(BOOL) CDataBase::GetContactSettingStatic(HANDLE hContact, DBCONTAC
STDMETHODIMP_(BOOL) CDataBase::FreeVariant(DBVARIANT *dbv)
{
- if ((dbv->type == DBVT_BLOB) && (dbv->pbVal))
- {
+ if (dbv->type == DBVT_BLOB && dbv->pbVal) {
mir_free(dbv->pbVal);
dbv->pbVal = 0;
- } else if ((dbv->type & DBVTF_VARIABLELENGTH) && (dbv->pszVal))
- {
+ }
+ else if ((dbv->type & DBVTF_VARIABLELENGTH) && (dbv->pszVal)) {
mir_free(dbv->pszVal);
dbv->pszVal = NULL;
}
@@ -506,72 +524,66 @@ STDMETHODIMP_(BOOL) CDataBase::WriteContactSetting(HANDLE hContact, DBCONTACTWRI
set.cbSize = sizeof(set);
set.Descriptor = &desc;
- switch (dbcws->value.type)
- {
- case DBVT_ASCIIZ:
- {
- set.Type = DBT_ST_ANSI;
- set.Value.pAnsi = dbcws->value.pszVal;
- } break;
- case DBVT_UTF8:
+ switch (dbcws->value.type) {
+ case DBVT_ASCIIZ:
+ set.Type = DBT_ST_ANSI;
+ set.Value.pAnsi = dbcws->value.pszVal;
+ if (isEncrypted(dbcws->szModule, dbcws->szSetting))
+ EncodeString(dbcws->value.pszVal);
+ break;
+ case DBVT_UTF8:
+ if (isEncrypted(dbcws->szModule, dbcws->szSetting))
+ EncodeString(dbcws->value.pszVal);
{
wchar_t * tmp = mir_utf8decodeW(dbcws->value.pszVal);
- if (tmp == 0)
- {
+ if (tmp == 0) {
if (IsDebuggerPresent())
{
DebugBreak();
#ifdef _DEBUG
- } else {
+ }
+ else {
LOG(logWARNING, _T("Trying to write malformed UTF8 setting \"%hs\" in module \"%hs\""), dbcws->szSetting, dbcws->szModule);
CLogger::Instance().ShowMessage();
#endif
}
return -1;
- } else {
- mir_free(tmp);
}
-
- set.Type = DBT_ST_UTF8;
- set.Value.pUTF8 = dbcws->value.pszVal;
- } break;
- case DBVT_WCHAR:
- {
- set.Type = DBT_ST_WCHAR;
- set.Value.pWide = dbcws->value.pwszVal;
- } break;
- case DBVT_BLOB:
- {
- set.Type = DBT_ST_BLOB;
- set.Value.pBlob = dbcws->value.pbVal;
- set.Value.Length = dbcws->value.cpbVal;
- } break;
- case DBVT_BYTE:
- {
- set.Type = DBT_ST_BYTE;
- set.Value.Byte = dbcws->value.bVal;
- } break;
- case DBVT_WORD:
- {
- set.Type = DBT_ST_WORD;
- set.Value.Word = dbcws->value.wVal;
- } break;
- case DBVT_DWORD:
- {
- set.Type = DBT_ST_DWORD;
- set.Value.DWord = dbcws->value.dVal;
- } break;
- default:
- {
- return -1;
+ else mir_free(tmp);
}
+
+ set.Type = DBT_ST_UTF8;
+ set.Value.pUTF8 = dbcws->value.pszVal;
+ break;
+ case DBVT_WCHAR:
+ set.Type = DBT_ST_WCHAR;
+ set.Value.pWide = dbcws->value.pwszVal;
+ break;
+ case DBVT_BLOB:
+ set.Type = DBT_ST_BLOB;
+ set.Value.pBlob = dbcws->value.pbVal;
+ set.Value.Length = dbcws->value.cpbVal;
+ break;
+ case DBVT_BYTE:
+ set.Type = DBT_ST_BYTE;
+ set.Value.Byte = dbcws->value.bVal;
+ break;
+ case DBVT_WORD:
+ set.Type = DBT_ST_WORD;
+ set.Value.Word = dbcws->value.wVal;
+ break;
+ case DBVT_DWORD:
+ set.Type = DBT_ST_DWORD;
+ set.Value.DWord = dbcws->value.dVal;
+ break;
+ default:
+ return -1;
}
if (DBSettingWrite(reinterpret_cast<WPARAM>(&set), 0) == DBT_INVALIDPARAM)
return -1;
- if (dbcws->value.type == DBVT_WCHAR)
- {
+ if (dbcws->value.type == DBVT_WCHAR) {
dbcws->value.type = DBVT_UTF8;
wchar_t * tmp = dbcws->value.pwszVal;
dbcws->value.pszVal = mir_utf8encodeW(dbcws->value.pwszVal);
@@ -579,9 +591,8 @@ STDMETHODIMP_(BOOL) CDataBase::WriteContactSetting(HANDLE hContact, DBCONTACTWRI
mir_free(dbcws->value.pszVal);
dbcws->value.type = DBVT_WCHAR;
dbcws->value.pwszVal = tmp;
- } else {
- NotifyEventHooks(hSettingChangeEvent, (WPARAM)hContact, (LPARAM)dbcws);
}
+ else NotifyEventHooks(hSettingChangeEvent, (WPARAM)hContact, (LPARAM)dbcws);
return 0;
}
diff --git a/plugins/Exchange/src/MirandaExchange.cpp b/plugins/Exchange/src/MirandaExchange.cpp
index fcca1f5c1c..9c2dabe005 100644
--- a/plugins/Exchange/src/MirandaExchange.cpp
+++ b/plugins/Exchange/src/MirandaExchange.cpp
@@ -59,23 +59,23 @@ HRESULT HrMAPIFindDefaultMsgStore( // RETURNS: return code
// Get the list of available message stores from MAPI
hrT = MAPICALL(lplhSession)->GetMsgStoresTable( 0, &lpTable);
- if(!FAILED(hrT))
+ if (!FAILED(hrT))
{
// Get the row count for the message recipient table
hrT = MAPICALL(lpTable)->GetRowCount(0, &cRows);
- if(!FAILED(hrT))
+ if (!FAILED(hrT))
{
// Set the columns to return
hrT = MAPICALL(lpTable)->SetColumns((LPSPropTagArray)&rgPropTagArray, 0);
- if(!FAILED(hrT))
+ if (!FAILED(hrT))
{
// Go to the beginning of the recipient table for the envelope
hrT = MAPICALL(lpTable)->SeekRow( BOOKMARK_BEGINNING, 0, NULL);
- if(!FAILED(hrT))
+ if (!FAILED(hrT))
{
// Read all the rows of the table
hrT = MAPICALL(lpTable)->QueryRows( cRows, 0, &lpRows);
- if(SUCCEEDED(hrT) && (lpRows != NULL) && (lpRows->cRows == 0))
+ if (SUCCEEDED(hrT) && (lpRows != NULL) && (lpRows->cRows == 0))
{
FreeProws(lpRows);
lpRows = NULL;
@@ -86,18 +86,18 @@ HRESULT HrMAPIFindDefaultMsgStore( // RETURNS: return code
}
}
- if( !FAILED(hrT) )
+ if ( !FAILED(hrT) )
{
bool bGetOut = false;
for(i = 0; (i < cRows) && (!bGetOut); i++)
{
- if(lpRows->aRow[i].lpProps[0].Value.b == TRUE)
+ if (lpRows->aRow[i].lpProps[0].Value.b == TRUE)
{
cbeid = lpRows->aRow[i].lpProps[1].Value.bin.cb;
sc = MAPIAllocateBuffer(cbeid, (void **)&lpeid);
- if(FAILED(sc))
+ if (FAILED(sc))
{
cbeid = 0;
lpeid = NULL;
@@ -113,7 +113,7 @@ HRESULT HrMAPIFindDefaultMsgStore( // RETURNS: return code
}
}
- if(lpRows != NULL)
+ if (lpRows != NULL)
{
FreeProws(lpRows);
}
@@ -228,7 +228,7 @@ CMirandaExchange::~CMirandaExchange()
m_lpMDB = NULL;
}
- if( NULL!= m_lpMAPISession )
+ if ( NULL!= m_lpMAPISession )
{
m_lpMAPISession->Logoff(NULL,NULL,NULL);
UlRelease(m_lpMAPISession );
@@ -448,12 +448,12 @@ HRESULT CMirandaExchange::InitializeAndLogin( LPCTSTR szUsername, LPCTSTR szPass
LPMDB lpMDB = NULL;
MAPIINIT_0 mapiInit = { MAPI_INIT_VERSION , MAPI_MULTITHREAD_NOTIFICATIONS };
- if( !m_bNoInitAgain) {
+ if ( !m_bNoInitAgain) {
m_bNoInitAgain = true;
hr = MAPIInitialize( &mapiInit) ;
}
- if( SUCCEEDED(hr)) {
+ if ( SUCCEEDED(hr)) {
TCHAR szPIDandName[128];
TCHAR szPID[20];
@@ -694,7 +694,7 @@ HRESULT CMirandaExchange::LogOFF()
m_lpMDB = NULL;
}
- if( NULL!= m_lpMAPISession )
+ if ( NULL!= m_lpMAPISession )
{
m_lpMAPISession->Logoff( NULL, NULL, NULL );
m_lpMAPISession->Release();
@@ -788,7 +788,7 @@ HRESULT CMirandaExchange::CheckInFolder( LPMAPIFOLDER lpFolder )
CMAPIInterface<LPMAPITABLE> lpMessageTable;
hr = lpFolder->GetContentsTable( 0, &lpMessageTable );
- if( HR_FAILED( hr ) )
+ if ( HR_FAILED( hr ) )
{
return -1;
}
@@ -808,7 +808,7 @@ HRESULT CMirandaExchange::CheckInFolder( LPMAPIFOLDER lpFolder )
//////////////////////////////////////////////////////////////////////////
- if( HR_FAILED( hr ) )
+ if ( HR_FAILED( hr ) )
{
return -1;
}
@@ -823,21 +823,21 @@ HRESULT CMirandaExchange::CheckInFolder( LPMAPIFOLDER lpFolder )
if ( !(lpRowsR->aRow[ i ].lpProps[ 1 ].Value.l & MSGFLAG_READ) )
{
- if( !FAILED(lpRowsR->aRow[i].lpProps[2].Value.err) )
+ if ( !FAILED(lpRowsR->aRow[i].lpProps[2].Value.err) )
{
szSenderName = lpRowsR->aRow[i].lpProps[2].Value.lpszW;
}
if ( NULL == szSenderName)
{
- if( !FAILED(lpRowsR->aRow[i].lpProps[3].Value.err))
+ if ( !FAILED(lpRowsR->aRow[i].lpProps[3].Value.err))
{
szSenderName = lpRowsR->aRow[i].lpProps[3].Value.lpszW;
}
}
- if( !FAILED(lpRowsR->aRow[i].lpProps[4].Value.err) )
+ if ( !FAILED(lpRowsR->aRow[i].lpProps[4].Value.err) )
{
szSubject = lpRowsR->aRow[i].lpProps[4].Value.lpszW;
}
@@ -887,7 +887,7 @@ HRESULT CMirandaExchange::CheckInFolder( LPMAPIFOLDER lpFolder )
lpRowProp = lpRow->aRow[i].lpProps;
CMAPIInterface<LPMAPIFOLDER> lpSubFolder = NULL;
hr = CallOpenEntry( m_lpMDB, NULL, NULL, NULL, lpRowProp[IENTRYID].Value.bin.cb, (LPENTRYID)lpRowProp[IENTRYID].Value.bin.lpb, MAPI_BEST_ACCESS, NULL, (LPUNKNOWN*)&lpSubFolder );
- if( !FAILED(hr) )
+ if ( !FAILED(hr) )
{
hr = CheckInFolder( lpSubFolder );
//if (FAILED(hr) ){//Log("failed checkinfolder for %s\n",lpRowProp[IDISPNAME].Value.lpszA );}
@@ -917,7 +917,7 @@ HRESULT CMirandaExchange::OpenTheMessage( LPTSTR szEntryID )
DWORD dwLength = 512 ;
DWORD dwType = REG_SZ;
- if( RegOpenKeyEx(HKEY_CLASSES_ROOT,
+ if ( RegOpenKeyEx(HKEY_CLASSES_ROOT,
_T("mailto\\shell\\open\\command"),
0,
KEY_ALL_ACCESS | KEY_EXECUTE | KEY_QUERY_VALUE ,
@@ -927,7 +927,7 @@ HRESULT CMirandaExchange::OpenTheMessage( LPTSTR szEntryID )
LONG lResult = RegQueryValueEx( hTheKey, NULL, NULL, (LPDWORD)&dwType, (LPBYTE)szRegValue, &dwLength);
RegCloseKey( hTheKey );
- if( lResult != ERROR_SUCCESS )
+ if ( lResult != ERROR_SUCCESS )
{
hRes = E_FAIL;
}
@@ -936,7 +936,7 @@ HRESULT CMirandaExchange::OpenTheMessage( LPTSTR szEntryID )
TCHAR* szTheEnd = _tcsstr( szRegValue,_T(".EXE") );
- if( NULL != szTheEnd )
+ if ( NULL != szTheEnd )
{
szRegValue[ _tcslen(szRegValue) - _tcslen(szTheEnd) +5 ] = _T('\0');
_tcscat( szRegValue, _T(" /recycle") );
@@ -951,7 +951,7 @@ HRESULT CMirandaExchange::OpenTheMessage( LPTSTR szEntryID )
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_SHOWNORMAL;
- if( CreateProcess ( NULL,
+ if ( CreateProcess ( NULL,
szRegValue,
NULL,
NULL,
diff --git a/plugins/Exchange/src/MirandaExchange.h b/plugins/Exchange/src/MirandaExchange.h
index 17edac4a92..9644e69fdb 100644
--- a/plugins/Exchange/src/MirandaExchange.h
+++ b/plugins/Exchange/src/MirandaExchange.h
@@ -175,7 +175,7 @@ public:
// DESTRUCTOR logs off of the MAPI session and releases the session handle.
~CMAPISession()
{
- if( m_ptr)
+ if ( m_ptr)
m_ptr->Logoff( 0L, 0L, 0L);
}
};
diff --git a/plugins/Exchange/src/dlg_handlers.cpp b/plugins/Exchange/src/dlg_handlers.cpp
index 9a8095eba6..631febea78 100644
--- a/plugins/Exchange/src/dlg_handlers.cpp
+++ b/plugins/Exchange/src/dlg_handlers.cpp
@@ -30,182 +30,117 @@ INT_PTR CALLBACK DlgProcOptions(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lPara
{
static int bInitializing; //true when dialog is being created
- switch (msg)
+ switch (msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hWnd);
{
- case WM_INITDIALOG:
- {
- TCHAR buffer[4096];
- char apassword[1024];
- long port;
- long interval;
- int bCheck;
- int portCheck;
- int retries;
- bInitializing = 1;
- DBVARIANT dbv = {0};
-
-
- dbv.type = DBVT_ASCIIZ;
-
- TranslateDialogDefault(hWnd);
-
- bCheck = db_get_b(NULL, ModuleName, "Check", 1);
- GetStringFromDatabase("Username", _T(""), buffer, sizeof(buffer));
- SetWindowText(GetDlgItem(hWnd, IDC_USER_EDIT), buffer);
- GetStringFromDatabase("Password", _T(""), buffer, sizeof(buffer));
- strcpy(apassword,mir_t2a(buffer));
- CallService(MS_DB_CRYPT_DECODESTRING, sizeof(apassword), (LPARAM) apassword);
- SetWindowText(GetDlgItem(hWnd, IDC_PASSWORD_EDIT), mir_a2t(apassword));
- GetStringFromDatabase("Server", _T(""), buffer, sizeof(buffer));
- SetWindowText(GetDlgItem(hWnd, IDC_SERVER_EDIT), buffer);
-
- port = db_get_dw(NULL, ModuleName, "Port", EXCHANGE_PORT);
- //_itoa(port, buffer, 10);
- //SetWindowText(GetDlgItem(hWnd, IDC_PORT_EDIT), buffer);
- SetDlgItemInt(hWnd,IDC_PORT_EDIT,port,FALSE);
-
- interval = db_get_dw(NULL, ModuleName, "Interval", DEFAULT_INTERVAL);
- //_itoa(interval, buffer, 10);
- //SetWindowText(GetDlgItem(hWnd, IDC_INTERVAL_EDIT), buffer);
- SetDlgItemInt(hWnd,IDC_INTERVAL_EDIT,interval,FALSE);
-
- CheckDlgButton(hWnd, IDC_RECONNECT, (db_get_b(NULL, ModuleName, "Reconnect", 0)) ? BST_CHECKED : BST_UNCHECKED);
-
- interval = db_get_dw(NULL, ModuleName, "ReconnectInterval", DEFAULT_RECONNECT_INTERVAL);
- //_itoa(interval, buffer, 10);
- //SetWindowText(GetDlgItem(hWnd, IDC_RECONNECT_INTERVAL), buffer);
- SetDlgItemInt(hWnd,IDC_RECONNECT_INTERVAL,interval,FALSE);
- CheckDlgButton(hWnd, IDC_USE_POPUPS, (BOOL) db_get_b(NULL, ModuleName, "UsePopups", 0) ? BST_CHECKED : BST_UNCHECKED);
- EnableWindow(GetDlgItem(hWnd, IDC_USE_POPUPS), ServiceExists(MS_POPUP_ADDPOPUP)); //disable the popups checkbox if no popup module is present
-
- CheckDlgButton(hWnd, IDC_CHECK_EMAILS, (bCheck) ? BST_CHECKED : BST_UNCHECKED);
- EnableWindow(GetDlgItem(hWnd, IDC_INTERVAL_EDIT), bCheck);
-
- portCheck = (BOOL) db_get_b(NULL, ModuleName, "UsePortCheck", 1);
- CheckDlgButton(hWnd, IDC_USE_PORTCHECK, (portCheck) ? BST_CHECKED : BST_UNCHECKED);
- EnableWindow(GetDlgItem(hWnd, IDC_PORT_EDIT), portCheck);
-
- //_itoa(db_get_b(NULL, ModuleName, "MaxRetries", MAX_EXCHANGE_CONNECT_RETRIES), buffer, 10);
- //SetWindowText(GetDlgItem(hWnd, IDC_MAX_RETRIES), buffer);
- retries=db_get_b(NULL, ModuleName, "MaxRetries", MAX_EXCHANGE_CONNECT_RETRIES);
- SetDlgItemInt(hWnd,IDC_MAX_RETRIES,retries,FALSE);
-
- EnableWindow(GetDlgItem(hWnd, IDC_RECONNECT_INTERVAL), IsDlgButtonChecked(hWnd, IDC_RECONNECT));
-
- bInitializing = 0;
-
- return TRUE;
- }
-
- case WM_COMMAND:
- {
- switch (LOWORD(wParam))
- {
- case IDC_USER_EDIT:
- case IDC_PASSWORD_EDIT:
- case IDC_SERVER_EDIT:
- case IDC_PORT_EDIT:
- case IDC_INTERVAL_EDIT:
- case IDC_RECONNECT_INTERVAL:
- case IDC_MAX_RETRIES:
- {
- if ((!bInitializing) && (HIWORD(wParam) == EN_CHANGE))// || (HIWORD(wParam) == CBN_SELENDOK))
- {
- SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0);
- }
-
- break;
- }
- case IDC_USE_POPUPS:
- case IDC_CHECK_EMAILS:
- case IDC_RECONNECT:
- case IDC_USE_PORTCHECK:
- {
- int portCheck = IsDlgButtonChecked(hWnd, IDC_USE_PORTCHECK);
- SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0);
-
- EnableWindow(GetDlgItem(hWnd, IDC_INTERVAL_EDIT), IsDlgButtonChecked(hWnd, IDC_CHECK_EMAILS));
- EnableWindow(GetDlgItem(hWnd, IDC_RECONNECT_INTERVAL), IsDlgButtonChecked(hWnd, IDC_RECONNECT));
- EnableWindow(GetDlgItem(hWnd, IDC_PORT_EDIT), portCheck);
- //EnableWindow(GetDlgItem(hWnd, IDC_MAX_RETRIES), portCheck);
-
- break;
- }
- }
-
- break;
- }
-
- case WM_NOTIFY:
- {
- switch(((LPNMHDR)lParam)->idFrom)
- {
- case 0:
- {
- switch (((LPNMHDR)lParam)->code)
- {
- case PSN_APPLY:
- {
- TCHAR buffer[4096];
- char apassword[1024];
- long port = 0;
- long interval = DEFAULT_INTERVAL;
- int bCheck = IsDlgButtonChecked(hWnd, IDC_CHECK_EMAILS);
- int retries = MAX_EXCHANGE_CONNECT_RETRIES;
-
- db_set_b(NULL, ModuleName, "Check", bCheck);
- GetWindowText(GetDlgItem(hWnd, IDC_USER_EDIT), buffer, sizeof(buffer));
- db_set_ts(NULL, ModuleName, "Username", buffer);
- GetWindowText(GetDlgItem(hWnd, IDC_PASSWORD_EDIT), buffer, sizeof(buffer));
- strcpy(apassword,mir_t2a(buffer));
-
- CallService(MS_DB_CRYPT_ENCODESTRING, sizeof(apassword), (LPARAM) apassword);
-
- db_set_ts(NULL, ModuleName, "Password", mir_a2t(apassword));
-
- GetWindowText(GetDlgItem(hWnd, IDC_SERVER_EDIT), buffer, sizeof(buffer));
- db_set_ts(NULL, ModuleName, "Server", buffer);
- GetWindowText(GetDlgItem(hWnd, IDC_PORT_EDIT), buffer, sizeof(buffer));
- //port = atoi(buffer);
- //db_set_dw(NULL, ModuleName, "Port", port);
- db_set_dw(NULL, ModuleName, "Port", GetDlgItemInt(hWnd,IDC_PORT_EDIT,NULL,FALSE));
-
- //GetWindowText(GetDlgItem(hWnd, IDC_INTERVAL_EDIT), buffer, sizeof(buffer));
- //interval = atoi(buffer);
- interval=GetDlgItemInt(hWnd,IDC_INTERVAL_EDIT,NULL,FALSE);
- db_set_dw(NULL, ModuleName, "Interval", interval);
-
- db_set_b(NULL, ModuleName, "Reconnect", IsDlgButtonChecked(hWnd, IDC_RECONNECT));
-
- GetWindowText(GetDlgItem(hWnd, IDC_RECONNECT_INTERVAL), buffer, sizeof(buffer));
- //interval = atoi(buffer);
- interval=GetDlgItemInt(hWnd,IDC_RECONNECT_INTERVAL,NULL,FALSE);
- db_set_dw(NULL, ModuleName, "ReconnectInterval", interval);
-
- db_set_b(NULL, ModuleName, "UsePopups", IsDlgButtonChecked(hWnd, IDC_USE_POPUPS));
- db_set_b(NULL, ModuleName, "UsePortCheck", IsDlgButtonChecked(hWnd, IDC_USE_PORTCHECK));
-
- //GetWindowText(GetDlgItem(hWnd, IDC_MAX_RETRIES), buffer, sizeof(buffer));
- //retries = atoi(buffer);
- retries=GetDlgItemInt(hWnd,IDC_MAX_RETRIES,NULL,FALSE);
- db_set_b(NULL, ModuleName, "MaxRetries", retries);
-
-
- exchangeServer.Reconnect(); //login info may be changed
- UpdateTimers(); //interval might get changed
-
- break;
- }
- }
-
- break;
- }
- }
-
- break;
+ bInitializing = 1;
+ DBVARIANT dbv = {0};
+ dbv.type = DBVT_ASCIIZ;
+
+ int bCheck = db_get_b(NULL, ModuleName, "Check", 1);
+
+ TCHAR buffer[4096];
+ GetStringFromDatabase("Username", _T(""), buffer, SIZEOF(buffer));
+ SetWindowText(GetDlgItem(hWnd, IDC_USER_EDIT), buffer);
+
+ GetStringFromDatabase("Password", _T(""), buffer, SIZEOF(buffer));
+ SetWindowText(GetDlgItem(hWnd, IDC_PASSWORD_EDIT), buffer);
+
+ GetStringFromDatabase("Server", _T(""), buffer, sizeof(buffer));
+ SetWindowText(GetDlgItem(hWnd, IDC_SERVER_EDIT), buffer);
+
+ SetDlgItemInt(hWnd, IDC_PORT_EDIT, db_get_dw(NULL, ModuleName, "Port", EXCHANGE_PORT), FALSE);
+
+ SetDlgItemInt(hWnd, IDC_INTERVAL_EDIT, db_get_dw(NULL, ModuleName, "Interval", DEFAULT_INTERVAL), FALSE);
+
+ CheckDlgButton(hWnd, IDC_RECONNECT, (db_get_b(NULL, ModuleName, "Reconnect", 0)) ? BST_CHECKED : BST_UNCHECKED);
+
+ SetDlgItemInt(hWnd, IDC_RECONNECT_INTERVAL, db_get_dw(NULL, ModuleName, "ReconnectInterval", DEFAULT_RECONNECT_INTERVAL), FALSE);
+ CheckDlgButton(hWnd, IDC_USE_POPUPS, (BOOL) db_get_b(NULL, ModuleName, "UsePopups", 0) ? BST_CHECKED : BST_UNCHECKED);
+ EnableWindow(GetDlgItem(hWnd, IDC_USE_POPUPS), ServiceExists(MS_POPUP_ADDPOPUP)); //disable the popups checkbox if no popup module is present
+
+ CheckDlgButton(hWnd, IDC_CHECK_EMAILS, (bCheck) ? BST_CHECKED : BST_UNCHECKED);
+ EnableWindow(GetDlgItem(hWnd, IDC_INTERVAL_EDIT), bCheck);
+
+ int portCheck = db_get_b(NULL, ModuleName, "UsePortCheck", 1);
+ CheckDlgButton(hWnd, IDC_USE_PORTCHECK, (portCheck) ? BST_CHECKED : BST_UNCHECKED);
+ EnableWindow(GetDlgItem(hWnd, IDC_PORT_EDIT), portCheck);
+
+ int retries = db_get_b(NULL, ModuleName, "MaxRetries", MAX_EXCHANGE_CONNECT_RETRIES);
+ SetDlgItemInt(hWnd,IDC_MAX_RETRIES,retries,FALSE);
+
+ EnableWindow(GetDlgItem(hWnd, IDC_RECONNECT_INTERVAL), IsDlgButtonChecked(hWnd, IDC_RECONNECT));
+
+ bInitializing = 0;
+ }
+ return TRUE;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDC_USER_EDIT:
+ case IDC_PASSWORD_EDIT:
+ case IDC_SERVER_EDIT:
+ case IDC_PORT_EDIT:
+ case IDC_INTERVAL_EDIT:
+ case IDC_RECONNECT_INTERVAL:
+ case IDC_MAX_RETRIES:
+ if ((!bInitializing) && (HIWORD(wParam) == EN_CHANGE))// || (HIWORD(wParam) == CBN_SELENDOK))
+ SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0);
+ break;
+
+ case IDC_USE_POPUPS:
+ case IDC_CHECK_EMAILS:
+ case IDC_RECONNECT:
+ case IDC_USE_PORTCHECK:
+ int portCheck = IsDlgButtonChecked(hWnd, IDC_USE_PORTCHECK);
+ SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0);
+
+ EnableWindow(GetDlgItem(hWnd, IDC_INTERVAL_EDIT), IsDlgButtonChecked(hWnd, IDC_CHECK_EMAILS));
+ EnableWindow(GetDlgItem(hWnd, IDC_RECONNECT_INTERVAL), IsDlgButtonChecked(hWnd, IDC_RECONNECT));
+ EnableWindow(GetDlgItem(hWnd, IDC_PORT_EDIT), portCheck);
+ break;
+ }
+ break;
+
+ case WM_NOTIFY:
+ switch(((LPNMHDR)lParam)->idFrom) {
+ case 0:
+ switch (((LPNMHDR)lParam)->code) {
+ case PSN_APPLY:
+ db_set_b(NULL, ModuleName, "Check", IsDlgButtonChecked(hWnd, IDC_CHECK_EMAILS));
+
+ TCHAR buffer[4096];
+ GetWindowText(GetDlgItem(hWnd, IDC_USER_EDIT), buffer, SIZEOF(buffer));
+ db_set_ts(NULL, ModuleName, "Username", buffer);
+
+ GetWindowText(GetDlgItem(hWnd, IDC_PASSWORD_EDIT), buffer, SIZEOF(buffer));
+ db_set_ts(NULL, ModuleName, "Password", buffer);
+
+ GetWindowText(GetDlgItem(hWnd, IDC_SERVER_EDIT), buffer, SIZEOF(buffer));
+ db_set_ts(NULL, ModuleName, "Server", buffer);
+
+ GetWindowText(GetDlgItem(hWnd, IDC_PORT_EDIT), buffer, SIZEOF(buffer));
+ db_set_dw(NULL, ModuleName, "Port", GetDlgItemInt(hWnd,IDC_PORT_EDIT,NULL,FALSE));
+
+ db_set_dw(NULL, ModuleName, "Interval", GetDlgItemInt(hWnd,IDC_INTERVAL_EDIT,NULL,FALSE));
+ db_set_dw(NULL, ModuleName, "ReconnectInterval", GetDlgItemInt(hWnd,IDC_RECONNECT_INTERVAL,NULL,FALSE));
+
+ db_set_b(NULL, ModuleName, "Reconnect", IsDlgButtonChecked(hWnd, IDC_RECONNECT));
+
+ db_set_b(NULL, ModuleName, "UsePopups", IsDlgButtonChecked(hWnd, IDC_USE_POPUPS));
+ db_set_b(NULL, ModuleName, "UsePortCheck", IsDlgButtonChecked(hWnd, IDC_USE_PORTCHECK));
+
+ db_set_b(NULL, ModuleName, "MaxRetries", GetDlgItemInt(hWnd,IDC_MAX_RETRIES,NULL,FALSE));
+
+ exchangeServer.Reconnect(); //login info may be changed
+ UpdateTimers(); //interval might get changed
}
+ }
+
+ break;
}
-
+
return 0;
}
@@ -219,276 +154,195 @@ void AddAnchorWindowToDeferList(HDWP &hdWnds, HWND window, RECT *rParent, WINDOW
int CALLBACK ListSubclassProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch (msg)
- {
- case WM_KEYUP:
- {
- if (wParam == VK_ESCAPE)
- {
- SendMessage(GetParent(hWnd), WM_CLOSE, 0, 0);
- }
-
- break;
- }
-
- case WM_SYSKEYDOWN:
- {
- if (wParam == 'X')
- {
- SendMessage(GetParent(hWnd), WM_CLOSE, 0, 0);
- }
-
- break;
- }
-
- case WM_LBUTTONDBLCLK:
- {
- int count = ListView_GetItemCount(hWnd);
- for (int i = 0; i < count; i++)
- {
- if (ListView_GetItemState(hWnd, i, LVIS_SELECTED))
- {
- TCHAR emailID[4096]; //uhh
- ListView_GetItemText(hWnd, i, 2, emailID, sizeof(emailID));
- exchangeServer.OpenMessage(emailID);
- }
- }
-
- break;
- }
+ switch (msg) {
+ case WM_KEYUP:
+ if (wParam == VK_ESCAPE)
+ SendMessage(GetParent(hWnd), WM_CLOSE, 0, 0);
+
+ break;
+
+ case WM_SYSKEYDOWN:
+ if (wParam == 'X')
+ SendMessage(GetParent(hWnd), WM_CLOSE, 0, 0);
+
+ break;
+
+ case WM_LBUTTONDBLCLK:
+ int count = ListView_GetItemCount(hWnd);
+ for (int i = 0; i < count; i++) {
+ if (ListView_GetItemState(hWnd, i, LVIS_SELECTED)) {
+ TCHAR emailID[4096]; //uhh
+ ListView_GetItemText(hWnd, i, 2, emailID, sizeof(emailID));
+ exchangeServer.OpenMessage(emailID);
+ }
}
-
+ break;
+ }
+
return CallWindowProc(OldListProc, hWnd, msg, wParam, lParam);
}
INT_PTR CALLBACK DlgProcEmails(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch (msg)
+ switch (msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hWnd);
{
- case WM_INITDIALOG:
- {
- TranslateDialogDefault(hWnd);
-
- SendMessage(hWnd, WM_SETICON, ICON_SMALL, (LPARAM) hiMailIcon);
-
- LVCOLUMN col = {0};
- HWND hList = GetDlgItem(hWnd, IDC_EMAILS_LIST);
- OldListProc = (WNDPROC) SetWindowLong(hList, GWLP_WNDPROC, (LONG) ListSubclassProc);
- ListView_SetExtendedListViewStyle(hList, LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES);
- col.mask = LVCF_TEXT | LVCF_WIDTH;
- col.cx = 100;
- col.pszText = TranslateT("Entry ID");
- col.cchTextMax = _tcslen(col.pszText) + 1;
- ListView_InsertColumn(hList, 0, &col);
- col.pszText = TranslateT("Subject");
- col.cx = 300;
- col.cchTextMax = _tcslen(col.pszText) + 1;
- ListView_InsertColumn(hList, 0, &col);
- col.cx = 200;
- col.iSubItem = 1;
- col.pszText = TranslateT("Sender");
- col.cchTextMax = _tcslen(col.pszText) + 1;
- ListView_InsertColumn(hList, 0, &col);
-
- return TRUE;
- }
-
- case WM_DESTROY:
- {
- hEmailsDlg = NULL;
-
- break;
- }
-
- case WM_CLOSE:
- {
- //ShowWindow(hWnd, SW_HIDE);
- DestroyWindow(hWnd); //close the window - no need to keep it in memory
- //SavePosition(hWnd);
-
- break;
- }
-
- case EXM_UPDATE_EMAILS:
- {
- HWND hList = GetDlgItem(hWnd, IDC_EMAILS_LIST);
- ListView_DeleteAllItems(hList);
- int count = GetWindowLong(hWnd, GWLP_USERDATA);
+ SendMessage(hWnd, WM_SETICON, ICON_SMALL, (LPARAM)hiMailIcon);
+
+ LVCOLUMN col = {0};
+ HWND hList = GetDlgItem(hWnd, IDC_EMAILS_LIST);
+ OldListProc = (WNDPROC) SetWindowLong(hList, GWLP_WNDPROC, (LONG) ListSubclassProc);
+ ListView_SetExtendedListViewStyle(hList, LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES);
+ col.mask = LVCF_TEXT | LVCF_WIDTH;
+ col.cx = 100;
+ col.pszText = TranslateT("Entry ID");
+ col.cchTextMax = (int)_tcslen(col.pszText) + 1;
+ ListView_InsertColumn(hList, 0, &col);
+ col.pszText = TranslateT("Subject");
+ col.cx = 300;
+ col.cchTextMax = (int)_tcslen(col.pszText) + 1;
+ ListView_InsertColumn(hList, 0, &col);
+ col.cx = 200;
+ col.iSubItem = 1;
+ col.pszText = TranslateT("Sender");
+ col.cchTextMax = (int)_tcslen(col.pszText) + 1;
+ ListView_InsertColumn(hList, 0, &col);
+ }
+ return TRUE;
+
+ case WM_DESTROY:
+ hEmailsDlg = NULL;
+ break;
+
+ case WM_CLOSE:
+ DestroyWindow(hWnd); //close the window - no need to keep it in memory
+ break;
+
+ case EXM_UPDATE_EMAILS:
+ {
+ HWND hList = GetDlgItem(hWnd, IDC_EMAILS_LIST);
+ ListView_DeleteAllItems(hList);
+ int count = GetWindowLong(hWnd, GWLP_USERDATA);
+ LVITEM item = {0};
+ TEmailHeader email = {0};
+ email.cbSize = sizeof(TEmailHeader);
+ TCHAR sender[1024] = _T("");
+ TCHAR subject[1024] = _T("");
+ //char buffer[4096];
+ email.cSender = sizeof(sender);
+ email.cSubject = sizeof(subject);
+ email.szSender = sender;
+ email.szSubject = subject;
+ item.mask = LVIF_TEXT;
+
+ for (int i = 0; i < count; i++)
+ {
+ exchangeServer.GetEmailHeader(i, &email);
+ item.iItem = i;
+ item.iSubItem = 0;
+ item.pszText = email.szSender;
+ ListView_InsertItem(hList, &item);
+ ListView_SetItemText(hList, i, 1, email.szSubject);
+ ListView_SetItemText(hList, i, 2, mir_a2t(email.emailID));
+ }
+ SetFocus(hList);
+ }
+ break;
+
+ case WM_SHOWWINDOW:
+ if (wParam)
+ SendMessage(hWnd, EXM_UPDATE_EMAILS, 0, 0);
+ break;
+
+ case WM_KEYUP:
+ if (wParam == VK_ESCAPE)
+ SendMessage(hWnd, WM_CLOSE, 0, 0);
+ break;
+
+ case WM_SYSKEYDOWN:
+ if (wParam == 'X')
+ SendMessage(hWnd, WM_CLOSE, 0, 0);
+ break;
+
+ case WM_WINDOWPOSCHANGING:
+ {
+ HDWP hdWnds = BeginDeferWindowPos(3);
+ RECT rParent;
+ WINDOWPOS *wndPos = (WINDOWPOS *) lParam;
+
+ if ((!wndPos) || (wndPos->flags & SWP_NOSIZE))
+ break;
+
+ GetWindowRect(hWnd, &rParent);
+ if (wndPos->cx < MIN_EMAILS_WIDTH)
+ wndPos->cx = MIN_EMAILS_WIDTH;
+ if (wndPos->cy < MIN_EMAILS_HEIGHT)
+ wndPos->cy = MIN_EMAILS_HEIGHT;
+
+ AddAnchorWindowToDeferList(hdWnds, GetDlgItem(hWnd, IDC_EMAILS_LIST), &rParent, wndPos, ANCHOR_ALL);
+ AddAnchorWindowToDeferList(hdWnds, GetDlgItem(hWnd, IDC_CLOSE), &rParent, wndPos, ANCHOR_BOTTOM | ANCHOR_RIGHT);
+ AddAnchorWindowToDeferList(hdWnds, GetDlgItem(hWnd, IDC_MARK_READ), &rParent, wndPos, ANCHOR_BOTTOM | ANCHOR_LEFT);
+
+ EndDeferWindowPos(hdWnds);
+ }
+ break;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDC_CLOSE:
+ SendMessage(hWnd, WM_CLOSE, 0, 0);
+ break;
+
+ case IDC_MARK_READ:
+ HWND hList = GetDlgItem(hWnd, IDC_EMAILS_LIST);
+ int count = ListView_GetItemCount(hList);
+ for (int i = 0; i < count; i++) {
+ if (ListView_GetCheckState(hList, i)) {
+ TCHAR emailID[2048]; //uhh ohh
LVITEM item = {0};
- TEmailHeader email = {0};
- email.cbSize = sizeof(TEmailHeader);
- TCHAR sender[1024] = _T("");
- TCHAR subject[1024] = _T("");
- //char buffer[4096];
- email.cSender = sizeof(sender);
- email.cSubject = sizeof(subject);
- email.szSender = sender;
- email.szSubject = subject;
+ item.iItem = i;
item.mask = LVIF_TEXT;
-
- for (int i = 0; i < count; i++)
- {
- exchangeServer.GetEmailHeader(i, &email);
- item.iItem = i;
- item.iSubItem = 0;
- item.pszText = email.szSender;
- ListView_InsertItem(hList, &item);
- ListView_SetItemText(hList, i, 1, email.szSubject);
- ListView_SetItemText(hList, i, 2, mir_a2t(email.emailID));
- }
- SetFocus(hList);
-
- break;
- }
-
- case WM_SHOWWINDOW:
- {
- if (wParam)
- {
- SendMessage(hWnd, EXM_UPDATE_EMAILS, 0, 0);
- }
-
- break;
- }
-
- case WM_KEYUP:
- {
- if (wParam == VK_ESCAPE)
- {
- SendMessage(hWnd, WM_CLOSE, 0, 0);
- }
-
- break;
+ item.iSubItem = 2;
+ item.cchTextMax = sizeof(emailID);
+ item.pszText = emailID;
+ ListView_GetItem(hList, &item);
+ exchangeServer.MarkEmailAsRead(emailID);
}
-
- case WM_SYSKEYDOWN:
- {
- if (wParam == 'X')
- {
- SendMessage(hWnd, WM_CLOSE, 0, 0);
- }
-
- break;
- }
-
- case WM_WINDOWPOSCHANGING:
- {
- HDWP hdWnds = BeginDeferWindowPos(3);
- RECT rParent;
- WINDOWPOS *wndPos = (WINDOWPOS *) lParam;
-
- if ((!wndPos) || (wndPos->flags & SWP_NOSIZE))
- {
- break;
- }
- GetWindowRect(hWnd, &rParent);
- if (wndPos->cx < MIN_EMAILS_WIDTH)
- {
- wndPos->cx = MIN_EMAILS_WIDTH;
- }
- if (wndPos->cy < MIN_EMAILS_HEIGHT)
- {
- wndPos->cy = MIN_EMAILS_HEIGHT;
- }
- AddAnchorWindowToDeferList(hdWnds, GetDlgItem(hWnd, IDC_EMAILS_LIST), &rParent, wndPos, ANCHOR_ALL);
- AddAnchorWindowToDeferList(hdWnds, GetDlgItem(hWnd, IDC_CLOSE), &rParent, wndPos, ANCHOR_BOTTOM | ANCHOR_RIGHT);
- AddAnchorWindowToDeferList(hdWnds, GetDlgItem(hWnd, IDC_MARK_READ), &rParent, wndPos, ANCHOR_BOTTOM | ANCHOR_LEFT);
-
- EndDeferWindowPos(hdWnds);
-
- break;
- }
-
- case WM_COMMAND:
- {
- switch (LOWORD(wParam))
- {
- case IDC_CLOSE:
- {
- SendMessage(hWnd, WM_CLOSE, 0, 0);
- //HWND hList = GetDlgItem(hWnd, IDC_EMAILS_LIST);
- //ListView_SetItemState(hList, -1, LVIS_SELECTED, LVIS_SELECTED);
- //SetFocus(hList);
-
- break;
- }
-
- case IDC_MARK_READ:
- {
- HWND hList = GetDlgItem(hWnd, IDC_EMAILS_LIST);
- int count = ListView_GetItemCount(hList);
- for (int i = 0; i < count; i++)
- {
- if (ListView_GetCheckState(hList, i))
- {
- //char sender[1024]; //nooo
- TCHAR emailID[2048]; //uhh ohh
- LVITEM item = {0};
- item.iItem = i;
- item.mask = LVIF_TEXT;
- //item.pszText = sender;
- //item.cchTextMax = sizeof(sender);
- //ListView_GetItem(hList, &item);
-
- item.iSubItem = 2;
- item.cchTextMax = sizeof(emailID);
- item.pszText = emailID;
- ListView_GetItem(hList, &item);
- exchangeServer.MarkEmailAsRead(emailID);
- }
- }
- count = exchangeServer.GetUnreadEmailsCount();
- if (count > 0)
- {
- SetWindowLong(hWnd, GWLP_USERDATA, count);
- SendMessage(hWnd, EXM_UPDATE_EMAILS, 0, 0);
- }
- else{
- SendMessage(hWnd, WM_CLOSE, 0, 0);
- }
-
- break;
- }
- }
-
- break;
- }
- default:
-
- break;
+ }
+ count = exchangeServer.GetUnreadEmailsCount();
+ if (count > 0)
+ {
+ SetWindowLong(hWnd, GWLP_USERDATA, count);
+ SendMessage(hWnd, EXM_UPDATE_EMAILS, 0, 0);
+ }
+ else SendMessage(hWnd, WM_CLOSE, 0, 0);
}
+ break;
+ }
+
return 0;
}
LRESULT CALLBACK DlgProcPopup(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- switch (msg)
- {
- case WM_COMMAND:
- {
- switch (HIWORD(wParam))
- {
- case STN_CLICKED:
- {
- //HWND hParent = FindWindow(MIRANDACLASS, NULL);
- //CreateDialog(hInstance, MAKEINTRESOURCE(IDD_EMAILS), hParent, DlgProcEmails);
- int count = (int) PUGetPluginData(hWnd);
- ShowEmailsWindow(count);
- PUDeletePopup(hWnd);
-
- break;
- }
- }
-
- break;
- }
- case WM_CONTEXTMENU:
- {
- PUDeletePopup(hWnd);
-
- break;
- }
+ switch (msg) {
+ case WM_COMMAND:
+ switch (HIWORD(wParam)) {
+ case STN_CLICKED:
+ {
+ int count = (int) PUGetPluginData(hWnd);
+ ShowEmailsWindow(count);
+ PUDeletePopup(hWnd);
+ break;
+ }
}
+ break;
+
+ case WM_CONTEXTMENU:
+ PUDeletePopup(hWnd);
+ break;
+ }
return DefWindowProc(hWnd, msg, wParam, lParam);
} \ No newline at end of file
diff --git a/plugins/Exchange/src/emails.cpp b/plugins/Exchange/src/emails.cpp
index 39dfa6d86a..25261a4ea2 100644
--- a/plugins/Exchange/src/emails.cpp
+++ b/plugins/Exchange/src/emails.cpp
@@ -35,60 +35,43 @@ CExchangeServer::~CExchangeServer()
int CExchangeServer::Connect(int bForceConnect)
{
int maxRetries = db_get_b(NULL, ModuleName, "MaxRetries", MAX_EXCHANGE_CONNECT_RETRIES);
- if (bForceConnect)
- {
+ if (bForceConnect) {
bTryConnect = 1;
cConnections = 0;
}
- if (cConnections >= maxRetries)
- {
+ if (cConnections >= maxRetries) {
bTryConnect = 0;
cConnections = 0;
_popupUtil("Maximum number of retries reached.\nPlugin will stop trying to connect automatically.");
}
+
if (bTryConnect)
- {
cConnections++;
- }
- if ((bTryConnect) && !IsServerAvailable())
- {
+ if ((bTryConnect) && !IsServerAvailable()) {
bTryConnect = 0;
_popupUtil("Server not available");
}
- if ((!IsConnected()) && (bTryConnect))
- {
- TCHAR user[1024]; //lovely
- TCHAR password[1024]; //i know
- char apassword[1024];
- TCHAR server[1024];
- int port;
-
- GetStringFromDatabase("Username", _T(""), user, _countof(user));
- if (ServiceExists(MS_UTILS_REPLACEVARS))
- {
- TCHAR *tmpUser = Utils_ReplaceVarsT(user);
-
- _tcsncpy(user, tmpUser, _countof(user));
- mir_free(tmpUser);
- }
-
- GetStringFromDatabase("Password", _T(""), password, _countof(password));
- strcpy(apassword,mir_t2a(password));
- CallService(MS_DB_CRYPT_DECODESTRING, sizeof(apassword), (LPARAM) apassword);
- _tcsncpy(password,mir_a2t(apassword),_countof(password));
- GetStringFromDatabase("Server", _T(""), server, _countof(server));
- port = db_get_dw(NULL, ModuleName, "Port", EXCHANGE_PORT);
- if (_tcslen(server) > 0) //only connect if there's a server to connect to
- {
- return DoConnect(user, password, server, port);
- }
- else {
- _popupUtil("Server is not configured...");
- }
- }
+ if ( !IsConnected() && bTryConnect) {
+ TCHAR user[1024]; //lovely
+ TCHAR password[1024]; //i know
+ TCHAR server[1024];
+
+ GetStringFromDatabase("Username", _T(""), user, _countof(user));
+ if (ServiceExists(MS_UTILS_REPLACEVARS))
+ _tcsncpy_s(user, _countof(user), VARST(user), _TRUNCATE);
+
+ GetStringFromDatabase("Password", _T(""), password, _countof(password));
+ GetStringFromDatabase("Server", _T(""), server, _countof(server));
+
+ int port = db_get_dw(NULL, ModuleName, "Port", EXCHANGE_PORT);
+ if (_tcslen(server) > 0) //only connect if there's a server to connect to
+ return DoConnect(user, password, server, port);
+
+ _popupUtil("Server is not configured...");
+ }
return -1; //0 on success, != 0 otherwise
}
@@ -151,44 +134,37 @@ void InitSocketAddr(sockaddr_in *addrServer, char *szServer)
hp = gethostbyname(szServer);
addrServer->sin_family = AF_INET;
if (hp == NULL)
- {
addrServer->sin_addr.s_addr = inet_addr(szServer);
- }
- else{
+ else
memcpy(&(addrServer->sin_addr), hp->h_addr, hp->h_length);
- }
+
int port = db_get_dw(NULL, ModuleName, "Port", EXCHANGE_PORT);
addrServer->sin_port = htons(port);
}
int CExchangeServer::IsServerAvailable()
{
- int check = db_get_b(NULL, ModuleName, "UsePortCheck", 1);
- if (check)
- {
- SOCKET sServer = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
- if (sServer == INVALID_SOCKET)
- {
- return 0; //server is not available
- }
- TCHAR szServer[1024];
- GetStringFromDatabase("Server", _T(""), szServer, sizeof(szServer));
- sockaddr_in addrServer;
- InitSocketAddr(&addrServer, mir_t2a(szServer));
- int res = connect(sServer, (sockaddr *) &addrServer, sizeof(addrServer));
- int bAvailable = 0;
- if (!res)
- {//if connected then close smtp connection by sending a quit message
- bAvailable = 1;
- char message[] = "quit\n";
- res = send(sServer, message, strlen(message), 0);
- }
- res = closesocket(sServer); //close the socket
- return bAvailable;
- }
- else{
- return 1; //if we're not using port check assume the server is available.
+ if (!db_get_b(NULL, ModuleName, "UsePortCheck", 1))
+ return 1;
+
+ SOCKET sServer = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+ if (sServer == INVALID_SOCKET)
+ return 0; //server is not available
+
+ TCHAR szServer[1024];
+ GetStringFromDatabase("Server", _T(""), szServer, sizeof(szServer));
+ sockaddr_in addrServer;
+ InitSocketAddr(&addrServer, mir_t2a(szServer));
+ int res = connect(sServer, (sockaddr *) &addrServer, sizeof(addrServer));
+ int bAvailable = 0;
+ if (!res) {
+ // if connected then close smtp connection by sending a quit message
+ bAvailable = 1;
+ char message[] = "quit\n";
+ send(sServer, message, strlen(message), 0);
}
+ res = closesocket(sServer); //close the socket
+ return bAvailable;
}
int CExchangeServer::GetUnreadEmailsCount()
@@ -220,42 +196,29 @@ int CExchangeServer::GetUnreadEmailsCount()
int CExchangeServer::GetEmailHeader(int iUnreadEmail, TEmailHeader *emailInfo)
{
if (!IsConnected())
- {
- //Connect();
return -1;
- }
+
if (emailInfo->cbSize != sizeof(TEmailHeader))
- {
return -1;
- }
#ifndef NO_EXCHANGE_TEST
- if(NULL!=m_HeadersKeeper[iUnreadEmail])
- {
+ if (NULL != m_HeadersKeeper[iUnreadEmail]) {
TCHAR* szSender = m_HeadersKeeper[iUnreadEmail]->m_szSender;
TCHAR* szSubject = m_HeadersKeeper[iUnreadEmail]->m_szSubject;
- if( NULL == szSender)
- {
+ if (NULL == szSender)
szSender = _T("");
- }
- if( NULL == szSubject)
- {
+ if (NULL == szSubject)
szSubject = _T("");
- }
emailInfo->szSender = szSender;
emailInfo->szSubject = szSubject;
emailInfo->emailID = (NULL!=m_HeadersKeeper[iUnreadEmail]->m_szEntryID)?m_HeadersKeeper[iUnreadEmail]->m_szEntryID:"";
}
- else {
- return -1;
- }
-
-
+ else return -1;
#else
emailInfo->szSender = "<sender>";
emailInfo->szSubject = "<subject>";
@@ -268,9 +231,7 @@ int CExchangeServer::GetEmailHeader(int iUnreadEmail, TEmailHeader *emailInfo)
int CExchangeServer::MarkEmailAsRead(TCHAR *emailID)
{
if (!IsConnected())
- {
return -1;
- }
#ifndef NO_EXCHANGE_TEST
MarkAsRead( emailID );
@@ -282,87 +243,50 @@ int CExchangeServer::MarkEmailAsRead(TCHAR *emailID)
int CExchangeServer::OpenMessage(TCHAR *emailID)
{
if (!IsConnected())
- {
return -1;
- }
#ifndef NO_EXCHANGE_TEST
OpenTheMessage( emailID );
#endif
-
return 0;
}
int CExchangeServer::Check(int bNoEmailsNotify)
{
-
int count = -1;
- if (IsConnected())
- {
- count = GetUnreadEmailsCount();
-
- if (count==-1)
- {
+ if (IsConnected()) {
+ count = GetUnreadEmailsCount();
+ if (count == -1) {
Reconnect();
if (IsConnected())
- {
count = GetUnreadEmailsCount();
- }
- else {
+ else
return -1;
- }
}
-
}
else {
Reconnect();
if (IsConnected())
- {
count = GetUnreadEmailsCount();
- }
- else {
+ else
return -1;
- }
if (count==-1)
- {
return -1;
- }
}
- if( ( (count > 0) || ((bNoEmailsNotify) && (count >= 0)) )&& (count!=-1))
- {
+ if (((count > 0) || ((bNoEmailsNotify) && (count >= 0))) && (count != -1)) {
TCHAR buffer[1024];
if (count != 1)
- {
mir_sntprintf(buffer,_countof(buffer), TranslateT("You have %d unread emails..."), count);
- }
- else {
+ else
mir_sntprintf(buffer, _countof(buffer),TranslateT("You have one unread email..."));
- }
ShowMessage(buffer, count);
- /*int i;
- TEmailHeader emailInfo = {0};
- char sender[1024];
- char subject[1024];
- emailInfo.cbSize = sizeof(emailInfo);
- emailInfo.szSender = sender;
- emailInfo.szSubject = subject;
- emailInfo.cSender = sizeof(sender);
- emailInfo.cSubject = sizeof(subject);
- for (i = 0; i < count; i++)
- {
- GetEmailHeader(i, &emailInfo);
- sprintf(buffer, "Unread email #%d:\nSender :%s\nSubject :%s", i + 1, sender, subject);
- ShowMessage(buffer);
- }*/
}
if (count==-1)
- {
_popupUtil("Cannot connect to Exchange server...");
- }
return count;
}
@@ -371,14 +295,9 @@ int ShowMessage(TCHAR *message, int cUnreadEmails)
{
int usePopups = ServiceExists(MS_POPUP_ADDPOPUP) ? db_get_b(NULL, ModuleName, "UsePopups", 0) : 0;
if (usePopups)
- {
return ShowPopupMessage(TranslateT("Exchange email"), message, cUnreadEmails);
- }
- else{
- return ShowMessageBoxMessage(TranslateT("Do you want to see the email headers?"), message, cUnreadEmails);
- }
-
- return 0;
+
+ return ShowMessageBoxMessage(TranslateT("Do you want to see the email headers?"), message, cUnreadEmails);
}
int ShowPopupMessage(TCHAR *title, TCHAR *message, int cUnreadEmails)
@@ -398,30 +317,21 @@ int ShowPopupMessage(TCHAR *title, TCHAR *message, int cUnreadEmails)
int ShowMessageBoxMessage(TCHAR *title, TCHAR *message, int cUnreadEmails)
{
if (MessageBox(0, message, title, MB_YESNO) == IDYES)
- {
ShowEmailsWindow(cUnreadEmails);
- }
-
return 0;
}
int ShowEmailsWindow(int cUnreadEmails)
{
- if (cUnreadEmails > 0) //show window only if there are unread emails
- {
+ if (cUnreadEmails > 0) { //show window only if there are unread emails
if (!hEmailsDlg)
- {
hEmailsDlg = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_EMAILS), NULL, DlgProcEmails);
- }
SetWindowLong(hEmailsDlg, GWLP_USERDATA, cUnreadEmails);
if (IsWindowVisible(hEmailsDlg))
- {
SendMessage(hEmailsDlg, EXM_UPDATE_EMAILS, 0, 0);
- }
- else {
+ else
ShowWindow(hEmailsDlg, SW_SHOW);
- }
}
return 0;
-} \ No newline at end of file
+}
diff --git a/plugins/FTPFileYM/src/mir_db.cpp b/plugins/FTPFileYM/src/mir_db.cpp
index 63e85cc056..13d1d645a7 100644
--- a/plugins/FTPFileYM/src/mir_db.cpp
+++ b/plugins/FTPFileYM/src/mir_db.cpp
@@ -53,14 +53,6 @@ int DB::setStringF(HANDLE hContact, char *szModule, char *szSetting, int id, TCH
return db_set_ts(hContact, szModule, formSet, stzValue);
}
-int DB::setCryptedString(HANDLE hContact, char *szModule, char *szSetting, char *szValue)
-{
- char buff[256];
- strcpy(buff, szValue);
- CallService(MS_DB_CRYPT_ENCODESTRING, (WPARAM)sizeof(buff), (LPARAM)buff);
- return db_set_s(hContact, szModule, szSetting, buff);
-}
-
int DB::getByteF(HANDLE hContact, char *szModule, char *szSetting, int id, int iErrorValue)
{
char formSet[256];
@@ -124,20 +116,6 @@ int DB::getStringF(HANDLE hContact, char *szModule, char *szSetting, int id, TCH
return getString(hContact, szModule, formSet, buff);
}
-int DB::getCryptedString(HANDLE hContact, char *szModule, char *szSetting, char *szValue)
-{
- char buff[256];
- if (!getAString(hContact, szModule, szSetting, buff))
- {
- CallService(MS_DB_CRYPT_DECODESTRING, (WPARAM)sizeof(buff), (LPARAM)buff);
- strcpy(szValue, buff);
- return 0;
- }
-
- szValue[0] = 0;
- return 1;
-}
-
int DB::deleteSettingF(HANDLE hContact, char *szModule, char *szSetting, int id)
{
char formSet[256];
diff --git a/plugins/FTPFileYM/src/mir_db.h b/plugins/FTPFileYM/src/mir_db.h
index 84f81b82bb..d46b16fb06 100644
--- a/plugins/FTPFileYM/src/mir_db.h
+++ b/plugins/FTPFileYM/src/mir_db.h
@@ -40,8 +40,5 @@ public:
static int getString(HANDLE hContact, char *szModule, char *szSetting, TCHAR *buff);
static int getStringF(HANDLE hContact, char *szModule, char *szSetting, int id, TCHAR *buff);
- static int setCryptedString(HANDLE hContact, char *szModule, char *szSetting, char *szValue);
- static int getCryptedString(HANDLE hContact, char *szModule, char *szSetting, char *szValue);
-
static int deleteSettingF(HANDLE hContact, char *szModule, char *szSetting, int id);
};
diff --git a/plugins/FTPFileYM/src/serverlist.cpp b/plugins/FTPFileYM/src/serverlist.cpp
index 79aea87d29..d199228675 100644
--- a/plugins/FTPFileYM/src/serverlist.cpp
+++ b/plugins/FTPFileYM/src/serverlist.cpp
@@ -46,7 +46,7 @@ void ServerList::saveToDb() const
char buff[256];
mir_snprintf(buff, sizeof(buff), "Password%d", opt.selected);
- DB::setCryptedString(0, MODULE, buff, ftp->szPass);
+ DB::setAStringF(0, MODULE, buff, opt.selected, ftp->szPass);
DB::setStringF(0, MODULE, "Name%d", opt.selected, ftp->stzName);
DB::setAStringF(0, MODULE, "Server%d", opt.selected, ftp->szServer);
@@ -64,14 +64,10 @@ void ServerList::saveToDb() const
ServerList::FTP::FTP(int index)
{
- char buff[256];
-
if (DB::getStringF(0, MODULE, "Name%d", index, this->stzName))
mir_sntprintf(this->stzName, SIZEOF(this->stzName), TranslateT("FTP Server %d"), index + 1);
- mir_snprintf(buff, sizeof(buff), "Password%d", index);
- DB::getCryptedString(0, MODULE, buff, this->szPass);
-
+ DB::getAStringF(0, MODULE, "Password%d", index, this->szPass);
DB::getAStringF(0, MODULE, "Server%d", index, this->szServer);
DB::getAStringF(0, MODULE, "User%d", index, this->szUser);
DB::getAStringF(0, MODULE, "Url%d", index, this->szUrl);
diff --git a/plugins/NewsAggregator/Src/Authentication.cpp b/plugins/NewsAggregator/Src/Authentication.cpp
index 4503fc7ef9..ce45f95cff 100644
--- a/plugins/NewsAggregator/Src/Authentication.cpp
+++ b/plugins/NewsAggregator/Src/Authentication.cpp
@@ -29,10 +29,7 @@ void CreateAuthString(char *auth, HANDLE hContact, HWND hwndDlg)
tlogin = mir_tstrdup(dbv.ptszVal);
db_free(&dbv);
}
- ptrA pwd(db_get_sa(hContact, MODULE, "Password"));
- if (pwd)
- CallService(MS_DB_CRYPT_DECODESTRING, strlen(pwd), pwd);
- tpass = mir_a2t(pwd);
+ tpass = db_get_tsa(hContact, MODULE, "Password");
}
else if (hwndDlg && IsDlgButtonChecked(hwndDlg, IDC_USEAUTH)) {
GetDlgItemText(hwndDlg, IDC_LOGIN, buf, SIZEOF(buf));
@@ -110,7 +107,6 @@ INT_PTR CALLBACK AuthenticationProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
else if (SelItem.hContact) {
db_set_b(SelItem.hContact, MODULE, "UseAuth", 1);
db_set_ts(SelItem.hContact, MODULE, "Login", username);
- CallService(MS_DB_CRYPT_ENCODESTRING, strlen(passw), (LPARAM)&passw);
db_set_s(SelItem.hContact, MODULE, "Password", passw);
}
EndDialog(hwndDlg, IDOK);
diff --git a/plugins/NewsAggregator/Src/Options.cpp b/plugins/NewsAggregator/Src/Options.cpp
index bcc128ab46..db787541dd 100644
--- a/plugins/NewsAggregator/Src/Options.cpp
+++ b/plugins/NewsAggregator/Src/Options.cpp
@@ -74,7 +74,6 @@ INT_PTR CALLBACK DlgProcAddFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
GetDlgItemText(hwndDlg, IDC_LOGIN, str, SIZEOF(str));
db_set_ts(hContact, MODULE, "Login", str);
GetDlgItemTextA(hwndDlg, IDC_PASSWORD, passw, SIZEOF(passw));
- CallService(MS_DB_CRYPT_ENCODESTRING, strlen(passw), (LPARAM)&passw);
db_set_s(hContact, MODULE, "Password", passw);
}
DeleteAllItems(hwndList);
@@ -157,45 +156,44 @@ INT_PTR CALLBACK DlgProcChangeFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
HANDLE hContact;
for (hContact = db_find_first(MODULE); hContact; hContact = db_find_next(hContact, MODULE)) {
- DBVARIANT dbNick = {0};
- if (db_get_ts(hContact, MODULE, "Nick", &dbNick))
+ ptrT dbNick( db_get_tsa(hContact, MODULE, "Nick"));
+ if (dbNick == NULL)
continue;
- else if (lstrcmp(dbNick.ptszVal, SelItem.nick) == 0) {
- db_free(&dbNick);
- DBVARIANT dbURL = {0};
- if (db_get_ts(hContact, MODULE, "URL", &dbURL))
- continue;
- else if (lstrcmp(dbURL.ptszVal, SelItem.url) == 0) {
- db_free(&dbURL);
- nSelItem->hContact = hContact;
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG)nSelItem);
- SetDlgItemText(hwndDlg, IDC_FEEDURL, SelItem.url);
- SetDlgItemText(hwndDlg, IDC_FEEDTITLE, SelItem.nick);
- SetDlgItemInt(hwndDlg, IDC_CHECKTIME, db_get_dw(hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME), TRUE);
- DBVARIANT dbMsg = {0};
- if (!db_get_ts(hContact, MODULE, "MsgFormat", &dbMsg)) {
- SetDlgItemText(hwndDlg, IDC_TAGSEDIT, dbMsg.ptszVal);
- db_free(&dbMsg);
- }
- if (db_get_b(hContact, MODULE, "UseAuth", 0)) {
- CheckDlgButton(hwndDlg, IDC_USEAUTH, BST_CHECKED);
- EnableWindow(GetDlgItem(hwndDlg, IDC_LOGIN), TRUE);
- EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), TRUE);
- DBVARIANT dbLogin = {0};
- if (!db_get_ts(hContact, MODULE, "Login", &dbLogin)) {
- SetDlgItemText(hwndDlg, IDC_LOGIN, dbLogin.ptszVal);
- db_free(&dbLogin);
- }
- ptrA pwd(db_get_sa(hContact, MODULE, "Password"));
- if (pwd)
- CallService(MS_DB_CRYPT_DECODESTRING, strlen(pwd), pwd);
- SetDlgItemTextA(hwndDlg, IDC_PASSWORD, pwd);
- }
- break;
+
+ if (lstrcmp(dbNick, SelItem.nick) != 0)
+ continue;
+
+ ptrT dbURL( db_get_tsa(hContact, MODULE, "URL"));
+ if (dbURL == NULL)
+ continue;
+
+ if (lstrcmp(dbURL, SelItem.url) != 0)
+ continue;
+
+ nSelItem->hContact = hContact;
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG)nSelItem);
+ SetDlgItemText(hwndDlg, IDC_FEEDURL, SelItem.url);
+ SetDlgItemText(hwndDlg, IDC_FEEDTITLE, SelItem.nick);
+ SetDlgItemInt(hwndDlg, IDC_CHECKTIME, db_get_dw(hContact, MODULE, "UpdateTime", DEFAULT_UPDATE_TIME), TRUE);
+
+ DBVARIANT dbMsg = {0};
+ if (!db_get_ts(hContact, MODULE, "MsgFormat", &dbMsg)) {
+ SetDlgItemText(hwndDlg, IDC_TAGSEDIT, dbMsg.ptszVal);
+ db_free(&dbMsg);
+ }
+ if (db_get_b(hContact, MODULE, "UseAuth", 0)) {
+ CheckDlgButton(hwndDlg, IDC_USEAUTH, BST_CHECKED);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_LOGIN), TRUE);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_PASSWORD), TRUE);
+ DBVARIANT dbLogin = {0};
+ if (!db_get_ts(hContact, MODULE, "Login", &dbLogin)) {
+ SetDlgItemText(hwndDlg, IDC_LOGIN, dbLogin.ptszVal);
+ db_free(&dbLogin);
}
- db_free(&dbURL);
+ ptrA pwd(db_get_sa(hContact, MODULE, "Password"));
+ SetDlgItemTextA(hwndDlg, IDC_PASSWORD, pwd);
}
- db_free(&dbNick);
+ break;
}
WindowList_Add(hChangeFeedDlgList, hwndDlg, hContact);
Utils_RestoreWindowPositionNoSize(hwndDlg, hContact, MODULE, "ChangeDlg");
@@ -235,10 +233,11 @@ INT_PTR CALLBACK DlgProcChangeFeedOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LP
db_set_ts(SelItem->hContact, MODULE, "MsgFormat", str);
if (IsDlgButtonChecked(hwndDlg, IDC_USEAUTH)) {
db_set_b(SelItem->hContact, MODULE, "UseAuth", 1);
+
GetDlgItemText(hwndDlg, IDC_LOGIN, str, SIZEOF(str));
db_set_ts(SelItem->hContact, MODULE, "Login", str);
+
GetDlgItemTextA(hwndDlg, IDC_PASSWORD, passw, SIZEOF(passw));
- CallService(MS_DB_CRYPT_ENCODESTRING, strlen(passw), (LPARAM)&passw);
db_set_s(SelItem->hContact, MODULE, "Password", passw);
}
else
@@ -353,9 +352,6 @@ INT_PTR CALLBACK DlgProcChangeFeedMenu(HWND hwndDlg, UINT msg, WPARAM wParam, LP
db_free(&dbv);
}
ptrA pwd(db_get_sa(hContact, MODULE, "Password"));
-
- if (pwd)
- CallService(MS_DB_CRYPT_DECODESTRING, strlen(pwd), pwd);
SetDlgItemTextA(hwndDlg, IDC_PASSWORD, pwd);
}
}
@@ -394,10 +390,11 @@ INT_PTR CALLBACK DlgProcChangeFeedMenu(HWND hwndDlg, UINT msg, WPARAM wParam, LP
db_set_ts(hContact, MODULE, "MsgFormat", str);
if (IsDlgButtonChecked(hwndDlg, IDC_USEAUTH)) {
db_set_b(hContact, MODULE, "UseAuth", 1);
+
GetDlgItemText(hwndDlg, IDC_LOGIN, str, SIZEOF(str));
db_set_ts(hContact, MODULE, "Login", str);
+
GetDlgItemTextA(hwndDlg, IDC_PASSWORD, passw, SIZEOF(passw));
- CallService(MS_DB_CRYPT_ENCODESTRING, strlen(passw), (LPARAM)&passw);
db_set_s(hContact, MODULE, "Password", passw);
}
else
diff --git a/plugins/SecureIM/src/commonheaders.cpp b/plugins/SecureIM/src/commonheaders.cpp
index 4f92e5a34c..97f2f5f13f 100644
--- a/plugins/SecureIM/src/commonheaders.cpp
+++ b/plugins/SecureIM/src/commonheaders.cpp
@@ -45,7 +45,6 @@ LPSTR myDBGetStringDecode(HANDLE hContact,const char *szModule,const char *szSet
size_t len = strlen(val)+64;
char *buf = (LPSTR)mir_alloc(len);
strncpy(buf,val,len); mir_free(val);
- CallService(MS_DB_CRYPT_DECODESTRING,(WPARAM)len,(LPARAM)buf);
return buf;
}
@@ -54,7 +53,6 @@ int myDBWriteStringEncode(HANDLE hContact,const char *szModule,const char *szSet
int len = (int)strlen(val)+64;
char *buf = (LPSTR)alloca(len);
strncpy(buf,val,len);
- CallService(MS_DB_CRYPT_ENCODESTRING,(WPARAM)len,(LPARAM)buf);
int ret = db_set_s(hContact,szModule,szSetting,buf);
return ret;
}
diff --git a/plugins/SecureIM/src/commonheaders.h b/plugins/SecureIM/src/commonheaders.h
index dc4797b7ce..1485484f3d 100644
--- a/plugins/SecureIM/src/commonheaders.h
+++ b/plugins/SecureIM/src/commonheaders.h
@@ -108,9 +108,6 @@ __forceinline int SendBroadcast(HANDLE hContact, int type, int result, HANDLE hP
return ProtoBroadcastAck( GetContactProto(hContact), hContact, type, result, hProcess, lParam);
}
-LPSTR myDBGetStringDecode(HANDLE,const char *,const char *);
-int myDBWriteStringEncode(HANDLE,const char *,const char *,const char *);
-
extern HANDLE hNetlibUser;
void InitNetlib();
void DeinitNetlib();
diff --git a/plugins/SecureIM/src/crypt_dll.cpp b/plugins/SecureIM/src/crypt_dll.cpp
index 05220acf99..f9b5325e2f 100644
--- a/plugins/SecureIM/src/crypt_dll.cpp
+++ b/plugins/SecureIM/src/crypt_dll.cpp
@@ -1,6 +1,5 @@
#include "commonheaders.h"
-
// generate KeyA pair and return public key
LPSTR InitKeyA(pUinKey ptr,int features)
{
@@ -11,8 +10,8 @@ LPSTR InitKeyA(pUinKey ptr,int features)
char *tmp = db_get_sa(ptr->hContact,MODULENAME,"PSK");
if (tmp) {
- cpp_init_keyp(ptr->cntx,tmp); // make pre-shared key from password
- mir_free(tmp);
+ cpp_init_keyp(ptr->cntx,tmp); // make pre-shared key from password
+ mir_free(tmp);
}
LPSTR pub_text = cpp_init_keya(ptr->cntx,features); // calculate public and private key & fill KeyA
@@ -24,8 +23,7 @@ LPSTR InitKeyA(pUinKey ptr,int features)
else
keysig = (LPSTR)SIG_KEYA;
}
- else
- if (isProtoSmallPackets(ptr->hContact))
+ else if (isProtoSmallPackets(ptr->hContact))
keysig = (LPSTR)SIG_KEY4;
else
keysig = (LPSTR)SIG_KEY3;
@@ -65,8 +63,8 @@ int InitKeyB(pUinKey ptr,LPCSTR key)
// store KeyX into context
-void InitKeyX(pUinKey ptr,BYTE *key) {
-
+void InitKeyX(pUinKey ptr,BYTE *key)
+{
if (!ptr->cntx)
ptr->cntx = cpp_create_context(isProtoSmallPackets(ptr->hContact)?CPP_MODE_BASE64:0);
@@ -75,8 +73,8 @@ void InitKeyX(pUinKey ptr,BYTE *key) {
// calculate secret key
-BOOL CalculateKeyX(pUinKey ptr,HANDLE hContact) {
-
+BOOL CalculateKeyX(pUinKey ptr,HANDLE hContact)
+{
int agr = cpp_calc_keyx(ptr->cntx);
if (agr) {
// do this only if key exchanged is ok
@@ -105,8 +103,8 @@ BOOL CalculateKeyX(pUinKey ptr,HANDLE hContact) {
// encrypt message
-LPSTR encrypt(pUinKey ptr, LPCSTR szEncMsg) {
-
+LPSTR encrypt(pUinKey ptr, LPCSTR szEncMsg)
+{
LPSTR szSig = (LPSTR) (ptr->offlineKey?SIG_ENOF:SIG_ENON);
int slen = (int)strlen(szSig);
@@ -121,30 +119,27 @@ LPSTR encrypt(pUinKey ptr, LPCSTR szEncMsg) {
// encode message
-LPSTR encodeMsg(pUinKey ptr, LPARAM lParam) {
-
+LPSTR encodeMsg(pUinKey ptr, LPARAM lParam)
+{
CCSDATA *pccsd = (CCSDATA *)lParam;
LPSTR szNewMsg = NULL;
LPSTR szOldMsg = (LPSTR) pccsd->lParam;
if (pccsd->wParam & PREF_UTF )
szNewMsg = encrypt(ptr,cpp_encodeU(ptr->cntx,szOldMsg));
- else
- if (pccsd->wParam & PREF_UNICODE )
+ else if (pccsd->wParam & PREF_UNICODE )
szNewMsg = encrypt(ptr,cpp_encodeW(ptr->cntx,(LPWSTR)(szOldMsg+strlen(szOldMsg)+1)));
else
szNewMsg = encrypt(ptr,cpp_encodeA(ptr->cntx,szOldMsg));
-// pccsd->wParam &= ~(PREF_UNICODE|PREF_UTF);
pccsd->wParam &= ~PREF_UNICODE;
-
return szNewMsg;
}
// decode message
-LPSTR decodeMsg(pUinKey ptr, LPARAM lParam, LPSTR szEncMsg) {
-
+LPSTR decodeMsg(pUinKey ptr, LPARAM lParam, LPSTR szEncMsg)
+{
CCSDATA *pccsd = (CCSDATA *)lParam;
PROTORECVEVENT *ppre = (PROTORECVEVENT *)pccsd->lParam;
@@ -152,7 +147,7 @@ LPSTR decodeMsg(pUinKey ptr, LPARAM lParam, LPSTR szEncMsg) {
LPSTR szOldMsg = (ppre->flags&PREF_UTF)?cpp_decodeU(ptr->cntx,szEncMsg):cpp_decode(ptr->cntx,szEncMsg);
if (szOldMsg == NULL) {
- ptr->decoded=false;
+ ptr->decoded = false;
switch(cpp_get_error(ptr->cntx)) {
case CPP_ERROR_BAD_LEN:
szNewMsg = mir_strdup(Translate(sim102));
@@ -160,10 +155,9 @@ LPSTR decodeMsg(pUinKey ptr, LPARAM lParam, LPSTR szEncMsg) {
case CPP_ERROR_BAD_CRC:
szNewMsg = mir_strdup(Translate(sim103));
break;
- default: {
+ default:
ptr->decoded=true;
- szNewMsg = mir_strdup(Translate(sim101));
- }
+ szNewMsg = mir_strdup(Translate(sim101));
break;
}
ppre->flags &= ~(PREF_UNICODE|PREF_UTF);
@@ -200,8 +194,8 @@ BOOL LoadKeyPGP(pUinKey ptr)
db_free(&dbv);
return r;
}
- else if (mode == 1) {
- LPSTR key = myDBGetStringDecode(ptr->hContact,MODULENAME,"pgp");
+ if (mode == 1) {
+ LPSTR key = db_get_sa(ptr->hContact,MODULENAME,"pgp");
if (key) {
pgp_set_key(ptr->cntx,key);
mir_free(key);
@@ -211,15 +205,15 @@ BOOL LoadKeyPGP(pUinKey ptr)
return 0;
}
-BOOL LoadKeyGPG(pUinKey ptr) {
-
+BOOL LoadKeyGPG(pUinKey ptr)
+{
LPSTR key = db_get_sa(ptr->hContact,MODULENAME,"gpg");
if (key) {
gpg_set_keyid(ptr->cntx,key);
mir_free(key);
- return 2;
+ return 2;
}
- return 0;
+ return 0;
}
// EOF
diff --git a/plugins/SecureIM/src/main.cpp b/plugins/SecureIM/src/main.cpp
index a08f3c3035..63f191d663 100644
--- a/plugins/SecureIM/src/main.cpp
+++ b/plugins/SecureIM/src/main.cpp
@@ -180,13 +180,13 @@ int onModulesLoaded(WPARAM, LPARAM)
if (bPGP) { //PGP
bPGPloaded = pgp_init();
bUseKeyrings = db_get_b(0,MODULENAME,"ukr",1);
- LPSTR priv = myDBGetStringDecode(0,MODULENAME,"pgpPrivKey");
+ LPSTR priv = db_get_sa(0,MODULENAME,"pgpPrivKey");
if (priv) {
bPGPprivkey = true;
if (bPGPloaded)
pgp_set_priv_key(priv);
mir_free(priv);
- }// if (priv)
+ }
if (bPGPloaded && bUseKeyrings) {
char PubRingPath[MAX_PATH], SecRingPath[MAX_PATH];
PubRingPath[0]='\0'; SecRingPath[0]='\0';
@@ -215,8 +215,8 @@ int onModulesLoaded(WPARAM, LPARAM)
}
}
}
- }// if (bPGPloaded && bUseKeyrings)
- }// if (bPGP)
+ }
+ }
Sent_NetLog("gpg_init");
diff --git a/plugins/SecureIM/src/options.cpp b/plugins/SecureIM/src/options.cpp
index 7e7d7aece5..432d0ccb4d 100644
--- a/plugins/SecureIM/src/options.cpp
+++ b/plugins/SecureIM/src/options.cpp
@@ -1319,7 +1319,7 @@ void ApplyPGPSettings(HWND hDlg)
if (priv) {
bPGPprivkey = true;
pgp_set_priv_key(priv);
- myDBWriteStringEncode(0,MODULENAME,"pgpPrivKey",priv);
+ db_set_s(0,MODULENAME,"pgpPrivKey",priv);
mir_free(priv);
db_unset(0,MODULENAME,"tpgpPrivKey");
}
diff --git a/plugins/SecureIM/src/svcs_menu.cpp b/plugins/SecureIM/src/svcs_menu.cpp
index f9a22638c3..b8fba61f48 100644
--- a/plugins/SecureIM/src/svcs_menu.cpp
+++ b/plugins/SecureIM/src/svcs_menu.cpp
@@ -88,7 +88,7 @@ INT_PTR __cdecl Service_PGPsetKey(WPARAM wParam, LPARAM lParam)
char *publ = LoadKeys(KeyPath,false);
if (publ) {
db_unset((HANDLE)wParam,MODULENAME,"pgp");
- myDBWriteStringEncode((HANDLE)wParam,MODULENAME,"pgp",publ);
+ db_set_s((HANDLE)wParam,MODULENAME,"pgp",publ);
db_set_b((HANDLE)wParam,MODULENAME,"pgp_mode",1);
db_set_s((HANDLE)wParam,MODULENAME,"pgp_abbr","(binary)");
mir_free(publ);
diff --git a/plugins/VersionInfo/src/dlgHandlers.cpp b/plugins/VersionInfo/src/dlgHandlers.cpp
index 375506347d..8a36de678c 100644
--- a/plugins/VersionInfo/src/dlgHandlers.cpp
+++ b/plugins/VersionInfo/src/dlgHandlers.cpp
@@ -299,7 +299,6 @@ INT_PTR CALLBACK DlgProcOpts(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
SetWindowText(GetDlgItem(hWnd, IDC_UPLOAD_USERNAME), buffer);
GetStringFromDatabase("UploadPassword", _T(""), buffer, SIZEOF(buffer));
- CallService(MS_DB_CRYPT_DECODESTRING, SIZEOF(buffer), (LPARAM) buffer);
SetWindowText(GetDlgItem(hWnd, IDC_UPLOAD_PASSWORD), buffer);
}
diff --git a/plugins/Watrack/lastfm/i_last_opt.inc b/plugins/Watrack/lastfm/i_last_opt.inc
index f18b590a87..a8fb4457af 100644
--- a/plugins/Watrack/lastfm/i_last_opt.inc
+++ b/plugins/Watrack/lastfm/i_last_opt.inc
@@ -10,12 +10,7 @@ procedure SaveOpt;
var
tmppass:array [0..255] of AnsiChar;
begin
- if lfm_password<>nil then
- begin
- StrCopy(tmppass,lfm_password);
- CallService(MS_DB_CRYPT_ENCODESTRING,StrLen(tmppass)+1,lparam(@tmppass));
- end;
- DBWriteString(0,PluginShort,optPassword,tmppass);
+ DBWriteString(0,PluginShort,optPassword,lfm_password);
DBWriteString(0,PluginShort,optLogin ,lfm_login);
DBWriteByte (0,PluginShort,optTries ,lfm_tries);
DBWriteByte (0,PluginShort,optScrobble,lfm_on and 1);
@@ -29,8 +24,6 @@ begin
lfm_on :=DBReadByte(0,PluginShort,optScrobble,0);
mFreeMem(lfm_login ); lfm_login :=DBReadString(0,PluginShort,optLogin);
mFreeMem(lfm_password); lfm_password:=DBReadString(0,PluginShort,optPassword);
- if lfm_password<>nil then
- CallService(MS_DB_CRYPT_DECODESTRING,StrLen(lfm_password)+1,lparam(lfm_password));
if (lfm_login=nil) or (lfm_password=nil) then
CallService(MS_POPUP_SHOWMESSAGEW,
wparam(TranslateW('Don''t forget to enter Login and Password to use Last.fm service')),
diff --git a/plugins/Watrack/myshows/i_myshows_opt.inc b/plugins/Watrack/myshows/i_myshows_opt.inc
index f3287aba05..f136c4c658 100644
--- a/plugins/Watrack/myshows/i_myshows_opt.inc
+++ b/plugins/Watrack/myshows/i_myshows_opt.inc
@@ -11,16 +11,10 @@ procedure SaveOpt;
var
tmppass:array [0..255] of AnsiChar;
begin
- if msh_password<>nil then
- begin
- StrCopy(tmppass,msh_password);
- CallService(MS_DB_CRYPT_ENCODESTRING,StrLen(tmppass)+1,LPARAM(@tmppass));
- end;
- DBWriteString(0,PluginShort,optPassword,tmppass);
+ DBWriteString(0,PluginShort,optPassword,msh_password);
DBWriteString(0,PluginShort,optLogin ,msh_login);
DBWriteByte (0,PluginShort,optTries ,msh_tries);
DBWriteByte (0,PluginShort,optScrobPos,msh_scrobpos);
-// DBWriteWord (0,PluginShort,optTries ,msh_timeout);
DBWriteByte (0,PluginShort,optScrobble,msh_on and 1);
end;
@@ -32,8 +26,6 @@ begin
msh_on :=DBReadByte(0,PluginShort,optScrobble,0);
mFreeMem(msh_login ); msh_login :=DBReadString(0,PluginShort,optLogin);
mFreeMem(msh_password); msh_password:=DBReadString(0,PluginShort,optPassword);
- if msh_password<>nil then
- CallService(MS_DB_CRYPT_DECODESTRING,StrLen(msh_password)+1,LPARAM(msh_password));
if (msh_login=nil) or (msh_password=nil) then
CallService(MS_POPUP_SHOWMESSAGEW,
WPARAM(TranslateW('Don''t forget to enter Login and Password to use MyShows service')),