diff options
author | George Hazan <ghazan@miranda.im> | 2021-04-04 21:05:17 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2021-04-04 21:05:17 +0300 |
commit | d18819b23a4d12d1ca49c40165962c2a51db0f74 (patch) | |
tree | b51dbc89d9ae4b1d8024a49644d8e92e9ad45f7f /protocols/WebView/src | |
parent | 0099dc67c8f511725f8e06762d1ced1d8aee0093 (diff) |
fixes #2835 (WebView: fix and remove "Disable main menu items" option)
Diffstat (limited to 'protocols/WebView/src')
-rw-r--r-- | protocols/WebView/src/main.cpp | 112 | ||||
-rw-r--r-- | protocols/WebView/src/resource.h | 1 | ||||
-rw-r--r-- | protocols/WebView/src/version.h | 2 | ||||
-rw-r--r-- | protocols/WebView/src/webview.cpp | 74 | ||||
-rw-r--r-- | protocols/WebView/src/webview.h | 4 | ||||
-rw-r--r-- | protocols/WebView/src/webview_alerts.cpp | 24 | ||||
-rw-r--r-- | protocols/WebView/src/webview_cleanup.cpp | 18 | ||||
-rw-r--r-- | protocols/WebView/src/webview_datawnd.cpp | 11 | ||||
-rw-r--r-- | protocols/WebView/src/webview_opts.cpp | 868 | ||||
-rw-r--r-- | protocols/WebView/src/webview_services.cpp | 16 | ||||
-rw-r--r-- | protocols/WebView/src/webview_ui.cpp | 850 |
11 files changed, 997 insertions, 983 deletions
diff --git a/protocols/WebView/src/main.cpp b/protocols/WebView/src/main.cpp index e7809efb1e..48411337cc 100644 --- a/protocols/WebView/src/main.cpp +++ b/protocols/WebView/src/main.cpp @@ -123,68 +123,60 @@ int CMPlugin::Load() //add sound event to options g_plugin.addSound("webviewalert", _A2W(MODULENAME), LPGENW("Alert event")); - //value is 1 if menu is disabled - g_plugin.setByte(MENU_IS_DISABLED_KEY, 1); - CMenuItem mi(&g_plugin); mi.flags = CMIF_UNICODE; - if ( g_plugin.getByte(MENU_OFF, 0)) { - //value is 0 if menu is enabled - g_plugin.setByte(MENU_IS_DISABLED_KEY, 0); - - mi.root = g_plugin.addRootMenu(MO_MAIN, _A2W(MODULENAME), 20200001); - Menu_ConfigureItem(mi.root, MCI_OPT_UID, "403BE07B-7954-4F3E-B318-4301571776B8"); - - /*DISABLE WEBVIEW*/ - SET_UID(mi, 0xdedeb697, 0xfc10, 0x4622, 0x8b, 0x97, 0x74, 0x39, 0x32, 0x68, 0xa7, 0x7b); - CreateServiceFunction("DisableWebview", AutoUpdateMCmd); - mi.hIcolibItem = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_SITE)); - if (g_plugin.getByte(DISABLE_AUTOUPDATE_KEY, 0)) - mi.name.w = LPGENW("Auto update disabled"); - else - mi.name.w = LPGENW("Auto update enabled"); - mi.pszService = "DisableWebview"; - hMenuItem1 = Menu_AddMainMenuItem(&mi); - - // Update all webview contacts - SET_UID(mi, 0xf324ede, 0xfdf, 0x498a, 0x8f, 0x49, 0x6d, 0x2a, 0x9f, 0xda, 0x58, 0x6); - CreateServiceFunction("UpdateAll", UpdateAllMenuCommand); - mi.position = 500090002; - mi.hIcolibItem = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_UPDATEALL)); - mi.name.w = LPGENW("Update all Webview sites"); - mi.pszService = "UpdateAll"; - Menu_AddMainMenuItem(&mi); - - // Mark All Webview Sites As Read - SET_UID(mi, 0x1fa5fa21, 0x2ee1, 0x4372, 0xae, 0x3e, 0x3b, 0x96, 0xac, 0xd, 0xe8, 0x49); - CreateServiceFunction("MarkAllSitesRead", MarkAllReadMenuCommand); - mi.position = 500090099; - mi.hIcolibItem = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_MARKALLREAD)); - mi.name.w = LPGENW("Mark all Webview sites as read"); - mi.pszService = "MarkAllSitesRead"; - Menu_AddMainMenuItem(&mi); - - // open cache directory - SET_UID(mi, 0xfed046a8, 0xaae5, 0x4cbe, 0xa8, 0xc, 0x3c, 0x50, 0x3e, 0x3e, 0x9b, 0x15); - CreateServiceFunction("OpenCacheFolder", OpenCacheDir); - mi.position = 500090099; - mi.hIcolibItem = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_FOLDER)); - mi.name.w = LPGENW("Open cache folder"); - mi.pszService = "OpenCacheFolder"; - Menu_AddMainMenuItem(&mi); - - // Countdown test - SET_UID(mi, 0xbb1a94a9, 0xca63, 0x4966, 0x98, 0x48, 0x8b, 0x3f, 0x9d, 0xac, 0x6a, 0x10); - CreateServiceFunction("Countdown", CountdownMenuCommand); - mi.flags |= CMIF_KEEPUNTRANSLATED; - wchar_t countername[100]; - mir_snwprintf(countername, TranslateT("%d minutes to update"), g_plugin.getDword(COUNTDOWN_KEY, 0)); - mi.position = 600090099; - mi.hIcolibItem = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_UPDATEALL)); - mi.name.w = countername; - mi.pszService = "Countdown"; - hMenuItemCountdown = Menu_AddMainMenuItem(&mi); - } + mi.root = g_plugin.addRootMenu(MO_MAIN, _A2W(MODULENAME), 20200001); + Menu_ConfigureItem(mi.root, MCI_OPT_UID, "403BE07B-7954-4F3E-B318-4301571776B8"); + + /*DISABLE WEBVIEW*/ + SET_UID(mi, 0xdedeb697, 0xfc10, 0x4622, 0x8b, 0x97, 0x74, 0x39, 0x32, 0x68, 0xa7, 0x7b); + CreateServiceFunction("DisableWebview", AutoUpdateMCmd); + mi.hIcolibItem = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_SITE)); + if (g_plugin.getByte(DISABLE_AUTOUPDATE_KEY, 0)) + mi.name.w = LPGENW("Auto update disabled"); + else + mi.name.w = LPGENW("Auto update enabled"); + mi.pszService = "DisableWebview"; + hMenuItem1 = Menu_AddMainMenuItem(&mi); + + // Update all webview contacts + SET_UID(mi, 0xf324ede, 0xfdf, 0x498a, 0x8f, 0x49, 0x6d, 0x2a, 0x9f, 0xda, 0x58, 0x6); + CreateServiceFunction("UpdateAll", UpdateAllMenuCommand); + mi.position = 500090002; + mi.hIcolibItem = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_UPDATEALL)); + mi.name.w = LPGENW("Update all Webview sites"); + mi.pszService = "UpdateAll"; + Menu_AddMainMenuItem(&mi); + + // Mark All Webview Sites As Read + SET_UID(mi, 0x1fa5fa21, 0x2ee1, 0x4372, 0xae, 0x3e, 0x3b, 0x96, 0xac, 0xd, 0xe8, 0x49); + CreateServiceFunction("MarkAllSitesRead", MarkAllReadMenuCommand); + mi.position = 500090099; + mi.hIcolibItem = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_MARKALLREAD)); + mi.name.w = LPGENW("Mark all Webview sites as read"); + mi.pszService = "MarkAllSitesRead"; + Menu_AddMainMenuItem(&mi); + + // open cache directory + SET_UID(mi, 0xfed046a8, 0xaae5, 0x4cbe, 0xa8, 0xc, 0x3c, 0x50, 0x3e, 0x3e, 0x9b, 0x15); + CreateServiceFunction("OpenCacheFolder", OpenCacheDir); + mi.position = 500090099; + mi.hIcolibItem = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_FOLDER)); + mi.name.w = LPGENW("Open cache folder"); + mi.pszService = "OpenCacheFolder"; + Menu_AddMainMenuItem(&mi); + + // Countdown test + SET_UID(mi, 0xbb1a94a9, 0xca63, 0x4966, 0x98, 0x48, 0x8b, 0x3f, 0x9d, 0xac, 0x6a, 0x10); + CreateServiceFunction("Countdown", CountdownMenuCommand); + mi.flags |= CMIF_KEEPUNTRANSLATED; + wchar_t countername[100]; + mir_snwprintf(countername, TranslateT("%d minutes to update"), g_plugin.getDword(COUNTDOWN_KEY, 0)); + mi.position = 600090099; + mi.hIcolibItem = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_UPDATEALL)); + mi.name.w = countername; + mi.pszService = "Countdown"; + hMenuItemCountdown = Menu_AddMainMenuItem(&mi); // contact menu mi.flags = CMIF_UNICODE; diff --git a/protocols/WebView/src/resource.h b/protocols/WebView/src/resource.h index d0203c7cab..96a41d2ff9 100644 --- a/protocols/WebView/src/resource.h +++ b/protocols/WebView/src/resource.h @@ -25,7 +25,6 @@ #define IDC_UPDATE_ONALERT 304 #define IDD_OPT 443 -#define IDC_DISABLEMENU 446 #define IDC_OPEN_WEBPAGE 447 #define IDC_TIME 450 diff --git a/protocols/WebView/src/version.h b/protocols/WebView/src/version.h index c2030de835..170f674bb8 100644 --- a/protocols/WebView/src/version.h +++ b/protocols/WebView/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 1 #define __RELEASE_NUM 3 -#define __BUILD_NUM 2 +#define __BUILD_NUM 3 #include <stdver.h> diff --git a/protocols/WebView/src/webview.cpp b/protocols/WebView/src/webview.cpp index 921306247a..f32d3defe9 100644 --- a/protocols/WebView/src/webview.cpp +++ b/protocols/WebView/src/webview.cpp @@ -42,7 +42,9 @@ int bpStatus; HGENMENU hMenuItem1; HGENMENU hMenuItemCountdown; -/*****************************************************************************/ +int OptInitialise(WPARAM wParam, LPARAM); + +///////////////////////////////////////////////////////////////////////////////////////// void ChangeMenuItem1() { // Enable or Disable auto updates @@ -55,7 +57,7 @@ void ChangeMenuItem1() Menu_ModifyItem(hMenuItem1, ptszName, LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_SITE))); } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// void ChangeMenuItemCountdown() { // countdown @@ -67,7 +69,7 @@ void ChangeMenuItemCountdown() Menu_ModifyItem(hMenuItemCountdown, countername, hIcon, CMIF_KEEPUNTRANSLATED); } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// static int CALLBACK EnumFontsProc(ENUMLOGFONTEX *lpelfe, NEWTEXTMETRICEX*, int, LPARAM lParam) { if (!IsWindow((HWND)lParam)) @@ -89,7 +91,7 @@ void FillFontListThread(void *param) ReleaseDC((HWND)param, hdc); } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// void TxtclrLoop() { for (auto &hContact : Contacts(MODULENAME)) { @@ -99,7 +101,7 @@ void TxtclrLoop() } } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// void BGclrLoop() { for (auto &hContact : Contacts(MODULENAME)) { @@ -110,7 +112,7 @@ void BGclrLoop() } } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// void StartUpdate(void*) { StartUpDelay = 1; @@ -122,7 +124,7 @@ void StartUpdate(void*) StartUpDelay = 0; } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// void ContactLoop(void*) { if (StartUpDelay == 0) { @@ -135,14 +137,14 @@ void ContactLoop(void*) WAlertPopup(NULL, TranslateT("All Webview sites have been updated.")); } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// INT_PTR MarkAllReadMenuCommand(WPARAM, LPARAM) { ChangeContactStatus(1); return 0; } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// void InitialiseGlobals(void) { Xposition = g_plugin.getDword(Xpos_WIN_KEY, 0); @@ -161,7 +163,7 @@ void InitialiseGlobals(void) WindowWidth = g_plugin.getDword(WIN_WIDTH_KEY, Def_win_width); } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// int Doubleclick(WPARAM wParam, LPARAM) { MCONTACT hContact = wParam; @@ -212,7 +214,7 @@ int Doubleclick(WPARAM wParam, LPARAM) return 1; } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// int SendToRichEdit(HWND hWindow, char *truncated, COLORREF rgbText, COLORREF rgbBack) { DBVARIANT dbv; @@ -260,7 +262,7 @@ int SendToRichEdit(HWND hWindow, char *truncated, COLORREF rgbText, COLORREF rgb return 1; } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// void CALLBACK timerfunc(HWND, UINT, UINT_PTR, DWORD) { g_plugin.setByte(HAS_CRASHED_KEY, 0); @@ -272,7 +274,7 @@ void CALLBACK timerfunc(HWND, UINT, UINT_PTR, DWORD) g_plugin.setDword(COUNTDOWN_KEY, 0); } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// void CALLBACK Countdownfunc(HWND, UINT, UINT_PTR, DWORD) { DWORD timetemp = g_plugin.getDword(COUNTDOWN_KEY, 100); @@ -286,27 +288,7 @@ void CALLBACK Countdownfunc(HWND, UINT, UINT_PTR, DWORD) ChangeMenuItemCountdown(); } -/*****************************************************************************/ - -int OptInitialise(WPARAM wParam, LPARAM) -{ - OPTIONSDIALOGPAGE odp = {}; - odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT); - odp.szGroup.a = LPGEN("Network"); - odp.szTitle.a = MODULENAME; - odp.pfnDlgProc = DlgProcOpt; - odp.flags = ODPF_BOLDGROUPS; - g_plugin.addOptions(wParam, &odp); - - // if popup service exists - odp.pszTemplate = MAKEINTRESOURCEA(IDD_POPUP); - odp.szGroup.a = LPGEN("Popups"); - odp.pfnDlgProc = DlgPopUpOpts; - g_plugin.addOptions(wParam, &odp); - return 0; -} - -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// void FontSettings(void) { g_lf.lfHeight = 16; @@ -325,7 +307,7 @@ void FontSettings(void) mir_wstrcpy(g_lf.lfFaceName, Def_font_face); } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// int ModulesLoaded(WPARAM, LPARAM) { hHookDisplayDataAlert = CreateHookableEvent(ME_DISPLAYDATA_ALERT); @@ -350,7 +332,7 @@ int ModulesLoaded(WPARAM, LPARAM) return 0; } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// INT_PTR DataWndMenuCommand(WPARAM wParam, LPARAM) { MCONTACT hContact = wParam; @@ -386,14 +368,14 @@ INT_PTR DataWndMenuCommand(WPARAM wParam, LPARAM) return 0; } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// INT_PTR UpdateAllMenuCommand(WPARAM, LPARAM) { mir_forkthread(ContactLoop); return 0; } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// INT_PTR AutoUpdateMCmd(WPARAM, LPARAM) { if (g_plugin.getByte(DISABLE_AUTOUPDATE_KEY, 0)) @@ -405,7 +387,7 @@ INT_PTR AutoUpdateMCmd(WPARAM, LPARAM) return 0; } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// INT_PTR AddContactMenuCommand(WPARAM, LPARAM) { db_set_s(0, "FindAdd", "LastSearched", MODULENAME); @@ -413,7 +395,7 @@ INT_PTR AddContactMenuCommand(WPARAM, LPARAM) return 0; } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// int OnTopMenuCommand(WPARAM, LPARAM, MCONTACT singlecontact) { int ontop = 0; @@ -432,7 +414,7 @@ int OnTopMenuCommand(WPARAM, LPARAM, MCONTACT singlecontact) return 0; } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// INT_PTR WebsiteMenuCommand(WPARAM wParam, LPARAM) { MCONTACT hContact = wParam; @@ -444,35 +426,35 @@ INT_PTR WebsiteMenuCommand(WPARAM wParam, LPARAM) return 0; } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// int UpdateMenuCommand(WPARAM, LPARAM, MCONTACT singlecontact) { mir_forkthread(GetData, (void*)singlecontact); return 0; } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// int ContactMenuItemUpdateData(WPARAM wParam, LPARAM lParam) { UpdateMenuCommand(wParam, lParam, wParam); return 0; } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// INT_PTR CntOptionsMenuCommand(WPARAM wParam, LPARAM) { DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CONTACT_OPT), nullptr, DlgProcContactOpt, wParam); return 0; } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// INT_PTR CntAlertMenuCommand(WPARAM wParam, LPARAM) { DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_ALRT_OPT), nullptr, DlgProcAlertOpt, wParam); return 0; } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// INT_PTR CountdownMenuCommand(WPARAM, LPARAM) { return 0; diff --git a/protocols/WebView/src/webview.h b/protocols/WebView/src/webview.h index e7bdd6c57b..bc2f52ed5d 100644 --- a/protocols/WebView/src/webview.h +++ b/protocols/WebView/src/webview.h @@ -26,7 +26,6 @@ #define MODULENAME "WebView" -#define MENU_OFF "DisableMenu" #define REFRESH_KEY "Refresh interval" #define ON_TOP_KEY "Always on top" #define OFFLINE_STATUS "OfflineOnBoot" @@ -37,7 +36,6 @@ #define HIDE_STATUS_ICON_KEY "Hide_Status_Icon" #define HAS_CRASHED_KEY "Has_Crashed" #define U_ALLSITE_KEY "UseAllTheWebsite" -#define MENU_IS_DISABLED_KEY "MainMenuReallyDisabled" #define UPDATE_ONALERT_KEY "WND_UPDATE_OALERY_ONLY" #define DISABLE_AUTOUPDATE_KEY "Disable_Auto_Update" #define RWSPACE_KEY "level_of_wspace_removal" @@ -125,7 +123,6 @@ void FillFontListThread(void *); INT_PTR CALLBACK DlgProcDisplayData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); INT_PTR CALLBACK DlgProcAlertOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); -INT_PTR CALLBACK DlgProcOpt(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); int DataWndAlertCommand(WPARAM wParam, LPARAM lParam); int PopupAlert(WPARAM wParam, LPARAM lParam); @@ -210,7 +207,6 @@ void EraseBlock(char *truncated); void EraseSymbols(char *truncated); int ProcessAlerts(MCONTACT hContact, char *truncated, char *tstr, char *contactname, int notpresent); -INT_PTR CALLBACK DlgPopUpOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam); INT_PTR CALLBACK DlgProcFind(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); int DataDialogResize(HWND hwndDlg, LPARAM lParam, UTILRESIZECONTROL * urc); int OptInitialise(WPARAM, LPARAM); diff --git a/protocols/WebView/src/webview_alerts.cpp b/protocols/WebView/src/webview_alerts.cpp index d03742bdb9..d811c57e89 100644 --- a/protocols/WebView/src/webview_alerts.cpp +++ b/protocols/WebView/src/webview_alerts.cpp @@ -23,7 +23,7 @@ #include "stdafx.h" #include "webview.h" -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// int CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { @@ -80,35 +80,35 @@ int CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) return DefWindowProc(hWnd, message, wParam, lParam); } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// int WDisplayDataAlert(MCONTACT hContact) { NotifyEventHooks(hHookDisplayDataAlert, hContact, 0); return 0; } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// int WAlertPopup(MCONTACT hContact, wchar_t *displaytext) { NotifyEventHooks(hHookAlertPopup, hContact, (LPARAM)displaytext); return 0; } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// int WErrorPopup(MCONTACT hContact, wchar_t *textdisplay) { NotifyEventHooks(hHookErrorPopup, hContact, (LPARAM)textdisplay); return 0; } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// int WAlertOSD(MCONTACT hContact, wchar_t *displaytext) { NotifyEventHooks(hHookAlertOSD, hContact, (LPARAM)displaytext); return 0; } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// int PopupAlert(WPARAM hContact, LPARAM lParam) { POPUPDATAW ppd; @@ -146,7 +146,7 @@ int PopupAlert(WPARAM hContact, LPARAM lParam) return 0; } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// int OSDAlert(WPARAM hContact, LPARAM lParam) { char contactname[255], newdisplaytext[2000]; @@ -171,7 +171,7 @@ int OSDAlert(WPARAM hContact, LPARAM lParam) return 0; } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// int ErrorMsgs(WPARAM wParam, LPARAM lParam) { MCONTACT hContact = wParam; @@ -194,7 +194,7 @@ int ErrorMsgs(WPARAM wParam, LPARAM lParam) return 0; } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// void SaveToFile(MCONTACT hContact, char *truncated) { char *mode; @@ -237,7 +237,7 @@ void SaveToFile(MCONTACT hContact, char *truncated) db_free(&dbv); } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// int ProcessAlerts(MCONTACT hContact, char *truncated, char *tstr, char *contactname, int notpresent) { char alertstring[255]; @@ -750,7 +750,7 @@ int ProcessAlerts(MCONTACT hContact, char *truncated, char *tstr, char *contactn return wasAlert; } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// int DataWndAlertCommand(WPARAM wParam, LPARAM) { MCONTACT hContact = wParam; @@ -774,7 +774,7 @@ int DataWndAlertCommand(WPARAM wParam, LPARAM) return 0; } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// void ReadFromFile(void *param) { MCONTACT hContact = (UINT_PTR)param; diff --git a/protocols/WebView/src/webview_cleanup.cpp b/protocols/WebView/src/webview_cleanup.cpp index af620f7351..801f6a8a34 100644 --- a/protocols/WebView/src/webview_cleanup.cpp +++ b/protocols/WebView/src/webview_cleanup.cpp @@ -363,7 +363,7 @@ char Characters[AMOUNT3] = '¦', '¯'}; -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// void CodetoSymbol(char *truncated) { int counter = 0; @@ -396,7 +396,7 @@ void CodetoSymbol(char *truncated) } // for } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// void EraseBlock(char *truncated) { int counter = 0; @@ -587,7 +587,7 @@ void EraseBlock(char *truncated) free(tempraw); } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// void EraseSymbols(char *truncated) { int counter = 0; @@ -628,7 +628,7 @@ void EraseSymbols(char *truncated) free(tempraw); } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// void NumSymbols(char *truncated) { int counter = 0; @@ -681,7 +681,7 @@ void NumSymbols(char *truncated) free(tempraw); } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// void FastTagFilter(char *truncated) { char *tempraw = (char*)malloc(MAXSIZE1); @@ -706,7 +706,7 @@ void FastTagFilter(char *truncated) free(tempraw); } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// void RemoveInvis(char *truncated, int AmountWspcRem) { int erase = 0; @@ -748,7 +748,7 @@ void RemoveInvis(char *truncated, int AmountWspcRem) free(tempraw); } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// void RemoveTabs(char *truncated) { char *tempraw = (char*)malloc(MAXSIZE1); @@ -763,7 +763,7 @@ void RemoveTabs(char *truncated) free(tempraw); } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// void Removewhitespace(char *truncated) { int counter2 = 0; @@ -783,7 +783,7 @@ void Removewhitespace(char *truncated) } // end for } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// void Filter(char *truncated) { char tempraw[MAXSIZE1]; diff --git a/protocols/WebView/src/webview_datawnd.cpp b/protocols/WebView/src/webview_datawnd.cpp index dc8b414547..c1e4df3798 100644 --- a/protocols/WebView/src/webview_datawnd.cpp +++ b/protocols/WebView/src/webview_datawnd.cpp @@ -23,7 +23,8 @@ #include "stdafx.h" #include "webview.h" -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// + INT_PTR CALLBACK DlgProcFind(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { static char Searchstr[128]; @@ -115,7 +116,7 @@ INT_PTR CALLBACK DlgProcFind(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara return FALSE; } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// static wchar_t tszSizeString[] = L"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; @@ -450,7 +451,7 @@ INT_PTR CALLBACK DlgProcDisplayData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA return FALSE; } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// int DataDialogResize(HWND, LPARAM, UTILRESIZECONTROL *urc) { @@ -466,7 +467,7 @@ int DataDialogResize(HWND, LPARAM, UTILRESIZECONTROL *urc) return RD_ANCHORX_LEFT | RD_ANCHORY_TOP; } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// void SavewinSettings(void) { @@ -486,7 +487,7 @@ void SavewinSettings(void) } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// void ValidatePosition(HWND) { RECT r; diff --git a/protocols/WebView/src/webview_opts.cpp b/protocols/WebView/src/webview_opts.cpp index 9d9a75830d..ebd445b6ac 100644 --- a/protocols/WebView/src/webview_opts.cpp +++ b/protocols/WebView/src/webview_opts.cpp @@ -23,60 +23,12 @@ #include "stdafx.h" #include "webview.h" -const wchar_t *szTrackerBarDescr[] = { - LPGENW("No whitespace removal"), - LPGENW("Minimal level of whitespace removal"), - LPGENW("Medium level of whitespace removal"), - LPGENW("Large level of whitespace removal"), - LPGENW("Remove all whitespace") -}; - -static char *fontSizes[] = { "8", "10", "14", "16", "18", "20", "24", "28" }; -static wchar_t *AlertTypes[] = { LPGENW("Popup plugin"), LPGENW("Log to file"), LPGENW("Open data display window"), LPGENW("Use OSD plugin") }; -static wchar_t *EventTypes[] = { LPGENW("A string is present"), LPGENW("The web page changes"), LPGENW("A specific part of web page changes") }; +static char *fontSizes[] = { "8", "10", "14", "16", "18", "20", "24", "28" }; #define M_FILLSCRIPTCOMBO (WM_USER+16) -wchar_t* FixButtonText(wchar_t *url, size_t len) -{ - wchar_t buttontext[256], stringbefore[256], newbuttontext[256]; - wcsncpy_s(buttontext, url, _TRUNCATE); - wcsncpy_s(newbuttontext, url, _TRUNCATE); - - if (wcschr(newbuttontext, '&') != nullptr) { - while (true) { - if (wcschr(newbuttontext, '&') == nullptr) - break; - - wcsncpy_s(buttontext, newbuttontext, _TRUNCATE); - wchar_t *stringafter = wcschr(buttontext, '&'); - int pos = (stringafter - buttontext); - int posbefore = (stringafter - buttontext) - 1; - int posafter = (stringafter - buttontext) + 1; - strdelw(stringafter, 1); - wcsncpy_s(stringbefore, pos, buttontext, _TRUNCATE); - mir_snwprintf(newbuttontext, L"%s!!%s", stringbefore, stringafter); - - posafter = 0; - posbefore = 0; - } - - while (true) { - if (wcschr(newbuttontext, '!') != nullptr) { - wchar_t *stringafter = wcschr(newbuttontext, '!'); - int pos = (stringafter - newbuttontext); - newbuttontext[pos] = '&'; - } - if (wcschr(newbuttontext, '!') == nullptr) - break; - } - } - - wcsncpy_s(url, len, newbuttontext, _TRUNCATE); - return url; -} +///////////////////////////////////////////////////////////////////////////////////////// -/*****************************************************************************/ static int CALLBACK EnumFontScriptsProc(ENUMLOGFONTEX * lpelfe, NEWTEXTMETRICEX*, int, LPARAM lParam) { if (SendMessage((HWND)lParam, CB_FINDSTRINGEXACT, -1, (LPARAM)lpelfe->elfScript) == CB_ERR) { @@ -87,11 +39,11 @@ static int CALLBACK EnumFontScriptsProc(ENUMLOGFONTEX * lpelfe, NEWTEXTMETRICEX* return TRUE; } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// // copied and modified from NewStatusNotify -INT_PTR CALLBACK DlgPopUpOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ +static INT_PTR CALLBACK DlgPopUpOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ char str[512]; DWORD BGColour = 0; DWORD TextColour = 0; @@ -252,785 +204,12 @@ INT_PTR CALLBACK DlgPopUpOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam) return FALSE; } -/*****************************************************************************/ -INT_PTR CALLBACK DlgProcAlertOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - HWND ParentHwnd; - DBVARIANT dbv; - int i; - int alertIndex = 0; - int eventIndex = 0; - static int test; - MCONTACT hContact; - - ParentHwnd = GetParent(hwndDlg); - - switch (msg) { - case WM_INITDIALOG: - test = 0; - TranslateDialogDefault(hwndDlg); - hContact = lParam; - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); - - SetWindowText(hwndDlg, TranslateT("Alert options")); - - SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_ALERT))); - - EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_APPLY), 0); - - if (!g_plugin.getWString(hContact, ALERT_STRING_KEY, &dbv)) { - SetDlgItemText(hwndDlg, IDC_ALERT_STRING, dbv.pwszVal); - db_free(&dbv); - } - if (!g_plugin.getWString(hContact, ALRT_S_STRING_KEY, &dbv)) { - SetDlgItemText(hwndDlg, IDC_START2, dbv.pwszVal); - db_free(&dbv); - } - if (!g_plugin.getWString(hContact, ALRT_E_STRING_KEY, &dbv)) { - SetDlgItemText(hwndDlg, IDC_END2, dbv.pwszVal); - db_free(&dbv); - } - CheckDlgButton(hwndDlg, IDC_ENABLE_ALERTS, g_plugin.getByte(hContact, ENABLE_ALERTS_KEY, 0) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_ADD_DATE_NAME, g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_24_HOUR, g_plugin.getByte(hContact, USE_24_HOUR_KEY, 0) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_ALWAYS_LOG, g_plugin.getByte(hContact, ALWAYS_LOG_KEY, 0) ? BST_CHECKED : BST_UNCHECKED); - - SetDlgItemText(hwndDlg, IDC_ALERT_TYPE, TranslateW(AlertTypes[g_plugin.getByte(hContact, ALRT_INDEX_KEY, 0)])); - SetDlgItemText(hwndDlg, IDC_EVENT_TYPE, TranslateW(EventTypes[g_plugin.getByte(hContact, EVNT_INDEX_KEY, 0)])); - - for (i = 0; i < _countof(AlertTypes); i++) - SendDlgItemMessage(hwndDlg, IDC_ALERT_TYPE, CB_ADDSTRING, 0, (LPARAM)TranslateW(AlertTypes[i])); - - for (i = 0; i < _countof(EventTypes); i++) - SendDlgItemMessage(hwndDlg, IDC_EVENT_TYPE, CB_ADDSTRING, 0, (LPARAM)TranslateW(EventTypes[i])); - - if (g_plugin.getByte(hContact, ENABLE_ALERTS_KEY, 0)) { - CheckDlgButton(hwndDlg, IDC_ENABLE_ALERTS, BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_ADD_DATE_NAME, BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_24_HOUR, BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_PREFIX, BST_UNCHECKED); - } - EnableWindow(GetDlgItem(hwndDlg, IDC_EVENT_TYPE), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); - EnableWindow(GetDlgItem(hwndDlg, IDC_ADD_DATE_NAME), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); - - if (IsDlgButtonChecked(hwndDlg, IDC_ADD_DATE_NAME)) { - EnableWindow(GetDlgItem(hwndDlg, IDC_PREFIX), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); - EnableWindow(GetDlgItem(hwndDlg, IDC_SUFFIX), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); - EnableWindow(GetDlgItem(hwndDlg, IDC_24_HOUR), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); - } - else { - EnableWindow(GetDlgItem(hwndDlg, IDC_PREFIX), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_SUFFIX), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_24_HOUR), 0); - } - - EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_TYPE), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); - EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); - EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); - EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); - EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); - EnableWindow(GetDlgItem(hwndDlg, IDC_START2), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); - EnableWindow(GetDlgItem(hwndDlg, IDC_END2), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); - EnableWindow(GetDlgItem(hwndDlg, IDC_ALWAYS_LOG), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); - EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); - - if (!g_plugin.getString(hContact, EVNT_INDEX_KEY, &dbv)) { - eventIndex = g_plugin.getByte(hContact, EVNT_INDEX_KEY, 0); - db_free(&dbv); - } - if (!g_plugin.getString(hContact, ALRT_INDEX_KEY, &dbv)) { - alertIndex = g_plugin.getByte(hContact, ALRT_INDEX_KEY, 0); - db_free(&dbv); - } - - // alerts - if (alertIndex == 0) // Popup - { - if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) { - EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 0); - } - } - else if (alertIndex == 1) // file - { - if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) { - EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 1); - EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 1); - EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 1); - EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 1); - } - } - else if (alertIndex == 2) // datawindow - { - if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) { - EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 0); - } - } - else if (alertIndex == 3) // osd - { - if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) { - EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 0); - } - } - - // events - if (eventIndex == 0) // string is present - { - if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) { - EnableWindow(GetDlgItem(hwndDlg, IDC_START2), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_END2), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), 1); - } - } - else if (eventIndex == 1) // webpage changed - { - if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) { - EnableWindow(GetDlgItem(hwndDlg, IDC_START2), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_END2), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), 0); - } - } - else if (eventIndex == 2) // part of page changed - { - if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) { - EnableWindow(GetDlgItem(hwndDlg, IDC_START2), 1); - EnableWindow(GetDlgItem(hwndDlg, IDC_END2), 1); - EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), 0); - } - } - - if (!g_plugin.getWString(hContact, FILE_KEY, &dbv)) { - SetDlgItemText(hwndDlg, IDC_FILENAME, dbv.pwszVal); - db_free(&dbv); - } - - CheckDlgButton(hwndDlg, IDC_APPEND, g_plugin.getByte(hContact, APPEND_KEY, 0) ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_SAVE_AS_RAW, g_plugin.getByte(hContact, SAVE_AS_RAW_KEY, 0) ? BST_CHECKED : BST_UNCHECKED); - - if (g_plugin.getByte(hContact, CONTACT_PREFIX_KEY, 1) == 1) - CheckRadioButton(hwndDlg, IDC_PREFIX, IDC_SUFFIX, IDC_PREFIX); - else - CheckRadioButton(hwndDlg, IDC_PREFIX, IDC_SUFFIX, IDC_SUFFIX); - - if (g_plugin.getByte(hContact, ALWAYS_LOG_KEY, 0)) { - if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) { - EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 1); - EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 1); - EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 1); - EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 1); - } - } - return TRUE; - - case WM_COMMAND: - switch (LOWORD(wParam)) { - case IDC_BROWSE: - { - wchar_t szFileName[MAX_PATH]; - GetDlgItemText(hwndDlg, IDC_FILENAME, szFileName, _countof(szFileName)); - - OPENFILENAME ofn = { 0 }; - ofn.lStructSize = sizeof(ofn); - ofn.hwndOwner = hwndDlg; - ofn.hInstance = nullptr; - ofn.lpstrFilter = L"TEXT Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0\0"; - ofn.lpstrFile = szFileName; - ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; - ofn.nMaxFile = _countof(szFileName); - ofn.nMaxFileTitle = MAX_PATH; - ofn.lpstrDefExt = L"txt"; - if (!GetSaveFileName(&ofn)) - break; - - SetDlgItemText(hwndDlg, IDC_FILENAME, szFileName); - EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_APPLY), 1); - } - break; - - case IDC_ADD_DATE_NAME: - EnableWindow(GetDlgItem(hwndDlg, IDC_PREFIX), (IsDlgButtonChecked(hwndDlg, IDC_ADD_DATE_NAME))); - EnableWindow(GetDlgItem(hwndDlg, IDC_SUFFIX), (IsDlgButtonChecked(hwndDlg, IDC_ADD_DATE_NAME))); - EnableWindow(GetDlgItem(hwndDlg, IDC_24_HOUR), (IsDlgButtonChecked(hwndDlg, IDC_ADD_DATE_NAME))); - EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_APPLY), 1); - break; - - case IDC_24_HOUR: - case IDC_SUFFIX: - case IDC_PREFIX: - EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_APPLY), 1); - break; - - case IDC_ALERT_STRING: - if (HIWORD(wParam) == EN_CHANGE) - test++; - if (test > 1) - EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_APPLY), 1); - break; - - case IDC_START2: - case IDC_END2: - if (HIWORD(wParam) == EN_CHANGE) - test++; - if (test > 3) - EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_APPLY), 1); - break; - - case IDC_APPEND: - EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_APPLY), 1); - break; - - case IDC_SAVE_AS_RAW: - EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_APPLY), 1); - break; - - case IDC_ENABLE_ALERTS: - hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - EnableWindow(GetDlgItem(hwndDlg, IDC_ADD_DATE_NAME), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); - - if (IsDlgButtonChecked(hwndDlg, IDC_ADD_DATE_NAME)) { - EnableWindow(GetDlgItem(hwndDlg, IDC_PREFIX), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); - EnableWindow(GetDlgItem(hwndDlg, IDC_SUFFIX), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); - EnableWindow(GetDlgItem(hwndDlg, IDC_24_HOUR), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); - } - else { - EnableWindow(GetDlgItem(hwndDlg, IDC_PREFIX), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_SUFFIX), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_24_HOUR), 0); - } - - EnableWindow(GetDlgItem(hwndDlg, IDC_EVENT_TYPE), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); - EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_TYPE), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); - EnableWindow(GetDlgItem(hwndDlg, IDC_ALWAYS_LOG), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); - - eventIndex = g_plugin.getByte(hContact, EVNT_INDEX_KEY, 0); - alertIndex = g_plugin.getByte(hContact, ALRT_INDEX_KEY, 0); - - if (eventIndex == 2) { // part of webpage changed - EnableWindow(GetDlgItem(hwndDlg, IDC_START2), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); - EnableWindow(GetDlgItem(hwndDlg, IDC_END2), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); - } - else { - EnableWindow(GetDlgItem(hwndDlg, IDC_START2), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_END2), 0); - } - - // //////// - if (alertIndex == 0) { // popup - if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) { - EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 0); - - if (eventIndex == 2) // part of webpage changed - EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), 0); - if (eventIndex == 1) // webpage changed - EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), 0); - if (eventIndex == 0) // string present - EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); - } - } - else if (alertIndex == 1) { // log to file - if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) { - EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 1); - EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 1); - EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 1); - EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 1); - - if (eventIndex == 1) // webpage changed - EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), 0); - if (eventIndex == 0) // string present - EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); - } - else { - EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 0); - } - } - else if (alertIndex == 2) { // display window - if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) { - EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 0); - - if (eventIndex == 1) // webpage changed - EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), 0); - if (eventIndex == 0) // string present - EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); - } - } - else if (alertIndex == 3) { // osd - if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) { - EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 0); - - if (eventIndex == 1) // webpage changed - EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), 0); - if (eventIndex == 0) // string present - EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); - } - } - - if (eventIndex == 0) // string present - EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); - - EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_APPLY), 1); - - if (IsDlgButtonChecked(hwndDlg, IDC_ALWAYS_LOG)) { - if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) { - EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 1); - EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 1); - EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 1); - EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 1); - } - else { - EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 0); - } - } - break; - - case IDC_ALWAYS_LOG: - EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), (IsDlgButtonChecked(hwndDlg, IDC_ALWAYS_LOG))); - EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), (IsDlgButtonChecked(hwndDlg, IDC_ALWAYS_LOG))); - EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), (IsDlgButtonChecked(hwndDlg, IDC_ALWAYS_LOG))); - EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), (IsDlgButtonChecked(hwndDlg, IDC_ALWAYS_LOG))); - break; - - case IDC_ALERT_TYPE: - if (HIWORD(wParam) == CBN_SELCHANGE || HIWORD(wParam) == CBN_EDITCHANGE) { - hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - alertIndex = SendDlgItemMessage(hwndDlg, IDC_ALERT_TYPE, CB_GETCURSEL, 0, 0); - - if (HIWORD(wParam) == CBN_SELCHANGE) { - g_plugin.setByte(hContact, ALRT_INDEX_KEY, alertIndex); - if (alertIndex == 0) { - // PopUp - EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 0); - } - else if (alertIndex == 1) { - // log to file - EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 1); - EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 1); - EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 1); - EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 1); - } - else if (alertIndex == 2) { - // data window - EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 0); - } - else if (alertIndex == 3) { - // OSD - EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 0); - } - - if (IsDlgButtonChecked(hwndDlg, IDC_ALWAYS_LOG)) { - EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), (IsDlgButtonChecked(hwndDlg, IDC_ALWAYS_LOG))); - EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), (IsDlgButtonChecked(hwndDlg, IDC_ALWAYS_LOG))); - EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), (IsDlgButtonChecked(hwndDlg, IDC_ALWAYS_LOG))); - EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), (IsDlgButtonChecked(hwndDlg, IDC_ALWAYS_LOG))); - } - } - EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_APPLY), 1); - } - break; +///////////////////////////////////////////////////////////////////////////////////////// - case IDC_EVENT_TYPE: - if (HIWORD(wParam) == CBN_SELCHANGE || HIWORD(wParam) == CBN_EDITCHANGE) { - hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - eventIndex = SendDlgItemMessage(hwndDlg, IDC_EVENT_TYPE, CB_GETCURSEL, 0, 0); - - if (HIWORD(wParam) == CBN_SELCHANGE) { - g_plugin.setByte(hContact, EVNT_INDEX_KEY, eventIndex); - if (eventIndex == 0) { - // event when string is present - EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), 1); - EnableWindow(GetDlgItem(hwndDlg, IDC_START2), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_END2), 0); - } - else if (eventIndex == 1) { - // event when web page changes - EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_START2), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_END2), 0); - } - else if (eventIndex == 2) { - // event when part of web page changes - EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_START2), 1); - EnableWindow(GetDlgItem(hwndDlg, IDC_END2), 1); - } - } - EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_APPLY), 1); - } - break; - - case IDC_ALERT_APPLY: - case IDC_OK2: - { - hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - - eventIndex = g_plugin.getByte(hContact, EVNT_INDEX_KEY, 0); - alertIndex = g_plugin.getByte(hContact, ALRT_INDEX_KEY, 0); - - g_plugin.setByte(hContact, ENABLE_ALERTS_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)); - g_plugin.setByte(hContact, APND_DATE_NAME_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_ADD_DATE_NAME)); - g_plugin.setByte(hContact, USE_24_HOUR_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_24_HOUR)); - g_plugin.setByte(hContact, ALWAYS_LOG_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_ALWAYS_LOG)); - - //if alerts is unticked delete the cache - if (!(IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))) - SiteDeleted(hContact, 0); - - if (eventIndex == 0) // string present - if (!(GetWindowTextLength(GetDlgItem(hwndDlg, IDC_ALERT_STRING)))) - if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) { - MessageBox(nullptr, TranslateT("You need to supply a search string."), _A2W(MODULENAME), MB_OK); - break; - } - - if (eventIndex == 2) // part of web page changed - if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) { - if (!(GetWindowTextLength(GetDlgItem(hwndDlg, IDC_START2)))) { - MessageBox(nullptr, TranslateT("You need to supply a start string."), _A2W(MODULENAME), MB_OK); - break; - } - if (!(GetWindowTextLength(GetDlgItem(hwndDlg, IDC_END2)))) { - MessageBox(nullptr, TranslateT("You need to supply an end string."), _A2W(MODULENAME), MB_OK); - break; - } - } - - if (alertIndex == 1) // log to file - if (!(GetWindowTextLength(GetDlgItem(hwndDlg, IDC_FILENAME)))) - if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) { - MessageBox(nullptr, TranslateT("You need to supply a file name and path."), _A2W(MODULENAME), MB_OK); - break; - } - - if (IsDlgButtonChecked(hwndDlg, IDC_ALWAYS_LOG)) - if (!(GetWindowTextLength(GetDlgItem(hwndDlg, IDC_FILENAME)))) - if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) { - MessageBox(nullptr, TranslateT("You need to supply a file name and path."), _A2W(MODULENAME), MB_OK); - break; - } - - wchar_t buf[MAX_PATH]; - GetDlgItemText(hwndDlg, IDC_FILENAME, buf, _countof(buf)); - g_plugin.setWString(hContact, FILE_KEY, buf); - - g_plugin.setByte(hContact, APPEND_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_APPEND)); - g_plugin.setByte(hContact, SAVE_AS_RAW_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SAVE_AS_RAW)); - - GetDlgItemText(hwndDlg, IDC_ALERT_STRING, buf, _countof(buf)); - g_plugin.setWString(hContact, ALERT_STRING_KEY, buf); - - GetDlgItemText(hwndDlg, IDC_START2, buf, _countof(buf)); - g_plugin.setWString(hContact, ALRT_S_STRING_KEY, buf); - - GetDlgItemText(hwndDlg, IDC_END2, buf, _countof(buf)); - g_plugin.setWString(hContact, ALRT_E_STRING_KEY, buf); - - g_plugin.setByte(hContact, CONTACT_PREFIX_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_PREFIX)); - - EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_APPLY), 0); - - if (LOWORD(wParam) == IDC_OK2) - EndDialog(hwndDlg, 1); - } - break; - - case IDC_ALERT_CANCEL: - case IDC_CANCEL: - EndDialog(hwndDlg, 0); - } - } - return FALSE; -} - -/*****************************************************************************/ - -INT_PTR CALLBACK DlgProcContactOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +static INT_PTR CALLBACK DlgProcOpt(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { + DWORD timerval, delaytime, oldcolor; DBVARIANT dbv; - wchar_t url[300]; - HWND ParentHwnd = GetParent(hwndDlg); - static int test; - static int test2; - MCONTACT hContact; - - switch (msg) { - case WM_INITDIALOG: - TranslateDialogDefault(hwndDlg); - - hContact = (MCONTACT)lParam; - - test = 0; - test2 = 0; - - SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)hContact); - - SetWindowText(hwndDlg, TranslateT("Contact options")); - - SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_OPTIONS))); - - EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_APPLY), 0); - - if (!g_plugin.getWString(hContact, URL_KEY, &dbv)) { - SetDlgItemText(hwndDlg, IDC_URL, dbv.pwszVal); - db_free(&dbv); - } - if (!g_plugin.getWString(hContact, START_STRING_KEY, &dbv)) { - SetDlgItemText(hwndDlg, IDC_START, dbv.pwszVal); - db_free(&dbv); - } - if (!g_plugin.getWString(hContact, END_STRING_KEY, &dbv)) { - SetDlgItemText(hwndDlg, IDC_END, dbv.pwszVal); - db_free(&dbv); - } - if (g_plugin.getWString(hContact, PRESERVE_NAME_KEY, &dbv)) { - db_free(&dbv); - db_get_ws(hContact, "CList", "MyHandle", &dbv); - g_plugin.setWString(hContact, PRESERVE_NAME_KEY, dbv.pwszVal); - db_free(&dbv); - } - if (!g_plugin.getWString(hContact, PRESERVE_NAME_KEY, &dbv)) { - SetDlgItemText(hwndDlg, IDC_SITE_NAME, dbv.pwszVal); - db_free(&dbv); - } - - CheckDlgButton(hwndDlg, IDC_CLEAN, g_plugin.getByte(hContact, CLEAR_DISPLAY_KEY, 0) ? BST_CHECKED : BST_UNCHECKED); - - SendDlgItemMessage(hwndDlg, IDC_RWSPACE, TBM_SETRANGE, FALSE, MAKELONG(0, 4)); - SendDlgItemMessage(hwndDlg, IDC_RWSPACE, TBM_SETPOS, TRUE, g_plugin.getByte(hContact, RWSPACE_KEY, 0)); - SetDlgItemText(hwndDlg, IDC_RWSPC_TEXT, TranslateW(szTrackerBarDescr[SendDlgItemMessage(hwndDlg, IDC_RWSPACE, TBM_GETPOS, 0, 0)])); - - EnableWindow(GetDlgItem(hwndDlg, IDC_RWSPACE), (IsDlgButtonChecked(hwndDlg, IDC_CLEAN))); - EnableWindow(GetDlgItem(hwndDlg, IDC_RWSPC_TEXT), (IsDlgButtonChecked(hwndDlg, IDC_CLEAN))); - - if (g_plugin.getByte(hContact, DBLE_WIN_KEY, 1) == 1) - CheckRadioButton(hwndDlg, IDC_DBLE_WEB, IDC_DBLE_WIN, IDC_DBLE_WIN); - else - CheckRadioButton(hwndDlg, IDC_DBLE_WEB, IDC_DBLE_WIN, IDC_DBLE_WEB); - - if (g_plugin.getByte(hContact, U_ALLSITE_KEY, 0) == 1) { - CheckRadioButton(hwndDlg, IDC_U_SE_STRINGS, IDC_U_ALLSITE, IDC_U_ALLSITE); - EnableWindow(GetDlgItem(hwndDlg, IDC_START), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_END), 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_CPY_STRINGS), 0); - } - else { - CheckRadioButton(hwndDlg, IDC_U_SE_STRINGS, IDC_U_ALLSITE, IDC_U_SE_STRINGS); - EnableWindow(GetDlgItem(hwndDlg, IDC_START), 1); - EnableWindow(GetDlgItem(hwndDlg, IDC_END), 1); - EnableWindow(GetDlgItem(hwndDlg, IDC_CPY_STRINGS), 1); - //EnableWindow(GetDlgItem(hwndDlg, IDC_CPY_STR_TXT), 1); - } - break; - - case WM_HSCROLL: - SetDlgItemText(hwndDlg, IDC_RWSPC_TEXT, TranslateW(szTrackerBarDescr[SendDlgItemMessage(hwndDlg, IDC_RWSPACE, TBM_GETPOS, 0, 0)])); - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_APPLY), 1); - break; - - case WM_COMMAND: - switch (LOWORD(wParam)) { - case WM_CLOSE: - case IDCANCEL: - if (hwndDlg) { - DestroyWindow(hwndDlg); - hwndDlg = nullptr; - } - return TRUE; - - case IDC_SITE_NAME: - case IDC_URL: - if (HIWORD(wParam) == EN_CHANGE) - test++; - if (test > 2) - EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_APPLY), 1); - break; - - case IDC_DBLE_WEB: - case IDC_DBLE_WIN: - EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_APPLY), 1); - break; - - case IDC_START: - case IDC_END: - if (HIWORD(wParam) == EN_CHANGE) - test2++; - if (test2 > 2) - EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_APPLY), 1); - break; - - case IDC_CPY_STRINGS: - { - wchar_t string[128]; - hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - - GetDlgItemText(hwndDlg, IDC_START, string, _countof(string)); - g_plugin.setWString(hContact, ALRT_S_STRING_KEY, string); - - GetDlgItemText(hwndDlg, IDC_END, string, _countof(string)); - g_plugin.setWString(hContact, ALRT_E_STRING_KEY, string); - - g_plugin.setWord(hContact, EVNT_INDEX_KEY, 2); - } - break; - - case IDC_CLEAN: - EnableWindow(GetDlgItem(hwndDlg, IDC_RWSPACE), (IsDlgButtonChecked(hwndDlg, IDC_CLEAN))); - EnableWindow(GetDlgItem(hwndDlg, IDC_RWSPC_TEXT), (IsDlgButtonChecked(hwndDlg, IDC_CLEAN))); - EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_APPLY), 1); - break; - - case IDC_U_SE_STRINGS: - EnableWindow(GetDlgItem(hwndDlg, IDC_START), (IsDlgButtonChecked(hwndDlg, IDC_U_SE_STRINGS))); - EnableWindow(GetDlgItem(hwndDlg, IDC_END), (IsDlgButtonChecked(hwndDlg, IDC_U_SE_STRINGS))); - EnableWindow(GetDlgItem(hwndDlg, IDC_CPY_STRINGS), (IsDlgButtonChecked(hwndDlg, IDC_U_SE_STRINGS))); - EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_APPLY), 1); - break; - - case IDC_U_ALLSITE: - EnableWindow(GetDlgItem(hwndDlg, IDC_START), (IsDlgButtonChecked(hwndDlg, IDC_U_SE_STRINGS))); - EnableWindow(GetDlgItem(hwndDlg, IDC_END), (IsDlgButtonChecked(hwndDlg, IDC_U_SE_STRINGS))); - EnableWindow(GetDlgItem(hwndDlg, IDC_CPY_STRINGS), (IsDlgButtonChecked(hwndDlg, IDC_U_SE_STRINGS))); - EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_APPLY), 1); - break; - - case IDC_OPT_APPLY: - case IDOK: - { - wchar_t str[128], contactname[128]; - if (!GetWindowTextLength(GetDlgItem(hwndDlg, IDC_URL))) { - MessageBox(nullptr, TranslateT("You need to supply a URL."), _A2W(MODULENAME), MB_OK); - break; - } - if (!GetWindowTextLength(GetDlgItem(hwndDlg, IDC_START))) { - if (IsDlgButtonChecked(hwndDlg, IDC_U_SE_STRINGS)) { - MessageBox(nullptr, TranslateT("You need to supply a start string."), _A2W(MODULENAME), MB_OK); - break; - } - } - if (!GetWindowTextLength(GetDlgItem(hwndDlg, IDC_END))) { - if (IsDlgButtonChecked(hwndDlg, IDC_U_SE_STRINGS)) { - MessageBox(nullptr, TranslateT("You need to supply an end string."), _A2W(MODULENAME), MB_OK); - break; - } - } - if (!GetWindowTextLength(GetDlgItem(hwndDlg, IDC_SITE_NAME))) { - MessageBox(nullptr, TranslateT("You need to supply a name for the contact."), _A2W(MODULENAME), MB_OK); - break; - } - - GetDlgItemText(hwndDlg, IDC_SITE_NAME, contactname, _countof(contactname)); - if (wcschr(contactname, '\\') != nullptr) { - MessageBox(nullptr, TranslateT("Invalid symbol present in contact name."), _A2W(MODULENAME), MB_OK); - break; - } - if (wcschr(contactname, '/') != nullptr) { - MessageBox(nullptr, TranslateT("Invalid symbol present in contact name."), _A2W(MODULENAME), MB_OK); - break; - } - if (wcschr(contactname, ':') != nullptr) { - MessageBox(nullptr, TranslateT("Invalid symbol present in contact name."), _A2W(MODULENAME), MB_OK); - break; - } - if (wcschr(contactname, '*') != nullptr) { - MessageBox(nullptr, TranslateT("Invalid symbol present in contact name."), _A2W(MODULENAME), MB_OK); - break; - } - if (wcschr(contactname, '?') != nullptr) { - MessageBox(nullptr, TranslateT("Invalid symbol present in contact name."), _A2W(MODULENAME), MB_OK); - break; - } - if (wcschr(contactname, '\"') != nullptr) { - MessageBox(nullptr, TranslateT("Invalid symbol present in contact name."), _A2W(MODULENAME), MB_OK); - break; - } - if (wcschr(contactname, '<') != nullptr) { - MessageBox(nullptr, TranslateT("Invalid symbol present in contact name."), _A2W(MODULENAME), MB_OK); - break; - } - if (wcschr(contactname, '>') != nullptr) { - MessageBox(nullptr, TranslateT("Invalid symbol present in contact name."), _A2W(MODULENAME), MB_OK); - break; - } - if (wcschr(contactname, '|') != nullptr) { - MessageBox(nullptr, TranslateT("Invalid symbol present in contact name."), _A2W(MODULENAME), MB_OK); - break; - } - - hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - - GetDlgItemText(hwndDlg, IDC_URL, url, _countof(url)); - g_plugin.setWString(hContact, URL_KEY, url); - g_plugin.setWString(hContact, "Homepage", url); - - GetDlgItemText(hwndDlg, IDC_START, str, _countof(str)); - g_plugin.setWString(hContact, START_STRING_KEY, str); - - GetDlgItemText(hwndDlg, IDC_END, str, _countof(str)); - g_plugin.setWString(hContact, END_STRING_KEY, str); - - GetDlgItemText(hwndDlg, IDC_SITE_NAME, str, _countof(str)); - db_set_ws(hContact, "CList", "MyHandle", str); - - g_plugin.setByte(hContact, DBLE_WIN_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_DBLE_WIN)); - g_plugin.setByte(hContact, U_ALLSITE_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_U_ALLSITE)); - - g_plugin.setByte(hContact, CLEAR_DISPLAY_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CLEAN)); - g_plugin.setByte(hContact, RWSPACE_KEY, (BYTE)(SendDlgItemMessage(hwndDlg, IDC_RWSPACE, TBM_GETPOS, 0, 0))); - - SetDlgItemText(ParentHwnd, IDC_OPEN_URL, FixButtonText(url, _countof(url))); - - SetWindowText(ParentHwnd, str); - EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_APPLY), 0); - - if (LOWORD(wParam) == IDOK) - EndDialog(hwndDlg, 1); - } - break; - - case IDC_OPT_CANCEL: - EndDialog(hwndDlg, 0); - } - break; - } - return FALSE; -} - -/*****************************************************************************/ -INT_PTR CALLBACK DlgProcOpt(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - DWORD timerval, delaytime, oldcolor; - DBVARIANT dbv; static int test = 0; static int test2 = 0; @@ -1048,7 +227,6 @@ INT_PTR CALLBACK DlgProcOpt(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara mir_forkthread(FillFontListThread, hwndDlg); - CheckDlgButton(hwndDlg, IDC_DISABLEMENU, g_plugin.getByte(MENU_OFF, 0) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_SUPPRESS, g_plugin.getByte(SUPPRESS_ERR_KEY, 0) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_UPDATE_ONSTART, g_plugin.getByte(UPDATE_ONSTART_KEY, 0) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_UPDATE_ON_OPEN, g_plugin.getByte(UPDATE_ON_OPEN_KEY, 0) ? BST_CHECKED : BST_UNCHECKED); @@ -1114,9 +292,8 @@ INT_PTR CALLBACK DlgProcOpt(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara case M_FILLSCRIPTCOMBO: // fill the script combo box and set the // selection to the value for fontid wParam - { - LOGFONT lf = { 0 }; + LOGFONT lf = { 0 }; int i; HDC hdc = GetDC(hwndDlg); @@ -1175,10 +352,6 @@ INT_PTR CALLBACK DlgProcOpt(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara EnableWindow(GetDlgItem(hwndDlg, IDC_STDELAYSECTXT), ((IsDlgButtonChecked(hwndDlg, IDC_UPDATE_ONSTART)))); break; - case IDC_DISABLEMENU: - ShowWindow(GetDlgItem(hwndDlg, IDC_RESTART), SW_SHOW); - break; - case IDC_TYPEFACE: SendMessage(hwndDlg, M_FILLSCRIPTCOMBO, wParam, 0); case IDC_FONTSIZE: @@ -1210,7 +383,6 @@ INT_PTR CALLBACK DlgProcOpt(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara case WM_NOTIFY: switch (((LPNMHDR)lParam)->code) { case PSN_APPLY: - g_plugin.setByte(MENU_OFF, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_DISABLEMENU)); g_plugin.setByte(SUPPRESS_ERR_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SUPPRESS)); g_plugin.setByte(UPDATE_ONSTART_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_UPDATE_ONSTART)); g_plugin.setByte(UPDATE_ON_OPEN_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_UPDATE_ON_OPEN)); @@ -1260,3 +432,25 @@ INT_PTR CALLBACK DlgProcOpt(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara return 0; } + +///////////////////////////////////////////////////////////////////////////////////////// +// module entry point + +int OptInitialise(WPARAM wParam, LPARAM) +{ + OPTIONSDIALOGPAGE odp = {}; + odp.szTitle.a = MODULENAME; + odp.flags = ODPF_BOLDGROUPS; + + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT); + odp.szGroup.a = LPGEN("Network"); + odp.pfnDlgProc = DlgProcOpt; + g_plugin.addOptions(wParam, &odp); + + // if popup service exists + odp.pszTemplate = MAKEINTRESOURCEA(IDD_POPUP); + odp.szGroup.a = LPGEN("Popups"); + odp.pfnDlgProc = DlgPopUpOpts; + g_plugin.addOptions(wParam, &odp); + return 0; +} diff --git a/protocols/WebView/src/webview_services.cpp b/protocols/WebView/src/webview_services.cpp index 0800f8938f..a7cd69441f 100644 --- a/protocols/WebView/src/webview_services.cpp +++ b/protocols/WebView/src/webview_services.cpp @@ -25,7 +25,7 @@ static int searchId = -1; -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// static char szInvalidChars[] = { '\\', '/', ':', '*', '?', '\"', '<', '>', '|' }; int DBSettingChanged(WPARAM wParam, LPARAM lParam) @@ -107,7 +107,7 @@ int DBSettingChanged(WPARAM wParam, LPARAM lParam) return 0; } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// int SiteDeleted(WPARAM wParam, LPARAM) { MCONTACT hContact = wParam; @@ -138,7 +138,7 @@ int SiteDeleted(WPARAM wParam, LPARAM) return 0; } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// INT_PTR OpenCacheDir(WPARAM, LPARAM) { //GET NAME FOR CACHE @@ -157,7 +157,7 @@ INT_PTR OpenCacheDir(WPARAM, LPARAM) return 0; } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// INT_PTR PingWebsiteMenuCommand(WPARAM wParam, LPARAM) { FILE *pfile = fopen("psite.bat", "r"); @@ -184,7 +184,7 @@ INT_PTR PingWebsiteMenuCommand(WPARAM wParam, LPARAM) return 0; } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// INT_PTR StpPrcssMenuCommand(WPARAM wParam, LPARAM) { g_plugin.setByte(wParam, STOP_KEY, 1); @@ -296,7 +296,7 @@ INT_PTR BPLoadIcon(WPARAM wParam, LPARAM) GetSystemMetrics(wParam & PLIF_SMALL ? SM_CYSMICON : SM_CYICON), 0); } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// static void __cdecl BasicSearchTimerProc(wchar_t *pszNick) { PROTOSEARCHRESULT psr = { sizeof(psr) }; @@ -324,7 +324,7 @@ INT_PTR BasicSearch(WPARAM, LPARAM lParam) return searchId; } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// INT_PTR AddToList(WPARAM, LPARAM lParam) { PROTOSEARCHRESULT *psr = (PROTOSEARCHRESULT *)lParam; @@ -443,7 +443,7 @@ INT_PTR AddToList(WPARAM, LPARAM lParam) return (INT_PTR)hContact; } -/*****************************************************************************/ +///////////////////////////////////////////////////////////////////////////////////////// static void __cdecl AckFunc(void*) { diff --git a/protocols/WebView/src/webview_ui.cpp b/protocols/WebView/src/webview_ui.cpp new file mode 100644 index 0000000000..cf0f00b4fb --- /dev/null +++ b/protocols/WebView/src/webview_ui.cpp @@ -0,0 +1,850 @@ +/* +* A plugin for Miranda IM which displays web page text in a window +* Copyright (C) 2005 Vincent Joyce. +* +* Miranda IM: the free icq client for MS Windows Copyright (C) 2000-2 +* Richard Hughes, Roland Rabien & Tristan Van de Vreede +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the Free +* Software Foundation; either version 2 of the License, or (at your option) +* any later version. +* +* This program is distributed in the hope that it will be useful, but +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +* for more details. +* +* You should have received a copy of the GNU General Public License along +* with this program; if not, write to the Free Software Foundation, Inc., 59 +* Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include "stdafx.h" +#include "webview.h" + +static const wchar_t *szTrackerBarDescr[] = { + LPGENW("No whitespace removal"), + LPGENW("Minimal level of whitespace removal"), + LPGENW("Medium level of whitespace removal"), + LPGENW("Large level of whitespace removal"), + LPGENW("Remove all whitespace") +}; + +static wchar_t *AlertTypes[] = { LPGENW("Popup plugin"), LPGENW("Log to file"), LPGENW("Open data display window"), LPGENW("Use OSD plugin") }; +static wchar_t *EventTypes[] = { LPGENW("A string is present"), LPGENW("The web page changes"), LPGENW("A specific part of web page changes") }; + +#define M_FILLSCRIPTCOMBO (WM_USER+16) + +wchar_t* FixButtonText(wchar_t *url, size_t len) +{ + wchar_t buttontext[256], stringbefore[256], newbuttontext[256]; + wcsncpy_s(buttontext, url, _TRUNCATE); + wcsncpy_s(newbuttontext, url, _TRUNCATE); + + if (wcschr(newbuttontext, '&') != nullptr) { + while (true) { + if (wcschr(newbuttontext, '&') == nullptr) + break; + + wcsncpy_s(buttontext, newbuttontext, _TRUNCATE); + wchar_t *stringafter = wcschr(buttontext, '&'); + int pos = (stringafter - buttontext); + int posbefore = (stringafter - buttontext) - 1; + int posafter = (stringafter - buttontext) + 1; + strdelw(stringafter, 1); + wcsncpy_s(stringbefore, pos, buttontext, _TRUNCATE); + mir_snwprintf(newbuttontext, L"%s!!%s", stringbefore, stringafter); + + posafter = 0; + posbefore = 0; + } + + while (true) { + if (wcschr(newbuttontext, '!') != nullptr) { + wchar_t *stringafter = wcschr(newbuttontext, '!'); + int pos = (stringafter - newbuttontext); + newbuttontext[pos] = '&'; + } + if (wcschr(newbuttontext, '!') == nullptr) + break; + } + } + + wcsncpy_s(url, len, newbuttontext, _TRUNCATE); + return url; +} + +///////////////////////////////////////////////////////////////////////////////////////// + +INT_PTR CALLBACK DlgProcAlertOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + HWND ParentHwnd; + DBVARIANT dbv; + int alertIndex = 0; + int eventIndex = 0; + static int test; + MCONTACT hContact; + + ParentHwnd = GetParent(hwndDlg); + + switch (msg) { + case WM_INITDIALOG: + test = 0; + TranslateDialogDefault(hwndDlg); + hContact = lParam; + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam); + + SetWindowText(hwndDlg, TranslateT("Alert options")); + + SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_ALERT))); + + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_APPLY), 0); + + if (!g_plugin.getWString(hContact, ALERT_STRING_KEY, &dbv)) { + SetDlgItemText(hwndDlg, IDC_ALERT_STRING, dbv.pwszVal); + db_free(&dbv); + } + if (!g_plugin.getWString(hContact, ALRT_S_STRING_KEY, &dbv)) { + SetDlgItemText(hwndDlg, IDC_START2, dbv.pwszVal); + db_free(&dbv); + } + if (!g_plugin.getWString(hContact, ALRT_E_STRING_KEY, &dbv)) { + SetDlgItemText(hwndDlg, IDC_END2, dbv.pwszVal); + db_free(&dbv); + } + CheckDlgButton(hwndDlg, IDC_ENABLE_ALERTS, g_plugin.getByte(hContact, ENABLE_ALERTS_KEY, 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_ADD_DATE_NAME, g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_24_HOUR, g_plugin.getByte(hContact, USE_24_HOUR_KEY, 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_ALWAYS_LOG, g_plugin.getByte(hContact, ALWAYS_LOG_KEY, 0) ? BST_CHECKED : BST_UNCHECKED); + + SetDlgItemText(hwndDlg, IDC_ALERT_TYPE, TranslateW(AlertTypes[g_plugin.getByte(hContact, ALRT_INDEX_KEY, 0)])); + SetDlgItemText(hwndDlg, IDC_EVENT_TYPE, TranslateW(EventTypes[g_plugin.getByte(hContact, EVNT_INDEX_KEY, 0)])); + + for (auto &it: AlertTypes) + SendDlgItemMessage(hwndDlg, IDC_ALERT_TYPE, CB_ADDSTRING, 0, (LPARAM)TranslateW(it)); + + for (auto &it: EventTypes) + SendDlgItemMessage(hwndDlg, IDC_EVENT_TYPE, CB_ADDSTRING, 0, (LPARAM)TranslateW(it)); + + if (g_plugin.getByte(hContact, ENABLE_ALERTS_KEY, 0)) { + CheckDlgButton(hwndDlg, IDC_ENABLE_ALERTS, BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_ADD_DATE_NAME, BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_24_HOUR, BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_PREFIX, BST_UNCHECKED); + } + EnableWindow(GetDlgItem(hwndDlg, IDC_EVENT_TYPE), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + EnableWindow(GetDlgItem(hwndDlg, IDC_ADD_DATE_NAME), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + + if (IsDlgButtonChecked(hwndDlg, IDC_ADD_DATE_NAME)) { + EnableWindow(GetDlgItem(hwndDlg, IDC_PREFIX), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + EnableWindow(GetDlgItem(hwndDlg, IDC_SUFFIX), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + EnableWindow(GetDlgItem(hwndDlg, IDC_24_HOUR), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + } + else { + EnableWindow(GetDlgItem(hwndDlg, IDC_PREFIX), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_SUFFIX), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_24_HOUR), 0); + } + + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_TYPE), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + EnableWindow(GetDlgItem(hwndDlg, IDC_START2), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + EnableWindow(GetDlgItem(hwndDlg, IDC_END2), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + EnableWindow(GetDlgItem(hwndDlg, IDC_ALWAYS_LOG), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + + if (!g_plugin.getString(hContact, EVNT_INDEX_KEY, &dbv)) { + eventIndex = g_plugin.getByte(hContact, EVNT_INDEX_KEY, 0); + db_free(&dbv); + } + if (!g_plugin.getString(hContact, ALRT_INDEX_KEY, &dbv)) { + alertIndex = g_plugin.getByte(hContact, ALRT_INDEX_KEY, 0); + db_free(&dbv); + } + + // alerts + if (alertIndex == 0) // Popup + { + if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) { + EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 0); + } + } + else if (alertIndex == 1) // file + { + if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) { + EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 1); + } + } + else if (alertIndex == 2) // datawindow + { + if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) { + EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 0); + } + } + else if (alertIndex == 3) // osd + { + if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) { + EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 0); + } + } + + // events + if (eventIndex == 0) // string is present + { + if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) { + EnableWindow(GetDlgItem(hwndDlg, IDC_START2), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_END2), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), 1); + } + } + else if (eventIndex == 1) // webpage changed + { + if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) { + EnableWindow(GetDlgItem(hwndDlg, IDC_START2), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_END2), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), 0); + } + } + else if (eventIndex == 2) // part of page changed + { + if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) { + EnableWindow(GetDlgItem(hwndDlg, IDC_START2), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_END2), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), 0); + } + } + + if (!g_plugin.getWString(hContact, FILE_KEY, &dbv)) { + SetDlgItemText(hwndDlg, IDC_FILENAME, dbv.pwszVal); + db_free(&dbv); + } + + CheckDlgButton(hwndDlg, IDC_APPEND, g_plugin.getByte(hContact, APPEND_KEY, 0) ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_SAVE_AS_RAW, g_plugin.getByte(hContact, SAVE_AS_RAW_KEY, 0) ? BST_CHECKED : BST_UNCHECKED); + + if (g_plugin.getByte(hContact, CONTACT_PREFIX_KEY, 1) == 1) + CheckRadioButton(hwndDlg, IDC_PREFIX, IDC_SUFFIX, IDC_PREFIX); + else + CheckRadioButton(hwndDlg, IDC_PREFIX, IDC_SUFFIX, IDC_SUFFIX); + + if (g_plugin.getByte(hContact, ALWAYS_LOG_KEY, 0)) { + if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) { + EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 1); + } + } + return TRUE; + + case WM_COMMAND: + switch (LOWORD(wParam)) { + case IDC_BROWSE: + { + wchar_t szFileName[MAX_PATH]; + GetDlgItemText(hwndDlg, IDC_FILENAME, szFileName, _countof(szFileName)); + + OPENFILENAME ofn = { 0 }; + ofn.lStructSize = sizeof(ofn); + ofn.hwndOwner = hwndDlg; + ofn.hInstance = nullptr; + ofn.lpstrFilter = L"TEXT Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0\0"; + ofn.lpstrFile = szFileName; + ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; + ofn.nMaxFile = _countof(szFileName); + ofn.nMaxFileTitle = MAX_PATH; + ofn.lpstrDefExt = L"txt"; + if (!GetSaveFileName(&ofn)) + break; + + SetDlgItemText(hwndDlg, IDC_FILENAME, szFileName); + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_APPLY), 1); + } + break; + + case IDC_ADD_DATE_NAME: + EnableWindow(GetDlgItem(hwndDlg, IDC_PREFIX), (IsDlgButtonChecked(hwndDlg, IDC_ADD_DATE_NAME))); + EnableWindow(GetDlgItem(hwndDlg, IDC_SUFFIX), (IsDlgButtonChecked(hwndDlg, IDC_ADD_DATE_NAME))); + EnableWindow(GetDlgItem(hwndDlg, IDC_24_HOUR), (IsDlgButtonChecked(hwndDlg, IDC_ADD_DATE_NAME))); + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_APPLY), 1); + break; + + case IDC_24_HOUR: + case IDC_SUFFIX: + case IDC_PREFIX: + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_APPLY), 1); + break; + + case IDC_ALERT_STRING: + if (HIWORD(wParam) == EN_CHANGE) + test++; + if (test > 1) + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_APPLY), 1); + break; + + case IDC_START2: + case IDC_END2: + if (HIWORD(wParam) == EN_CHANGE) + test++; + if (test > 3) + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_APPLY), 1); + break; + + case IDC_APPEND: + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_APPLY), 1); + break; + + case IDC_SAVE_AS_RAW: + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_APPLY), 1); + break; + + case IDC_ENABLE_ALERTS: + hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + EnableWindow(GetDlgItem(hwndDlg, IDC_ADD_DATE_NAME), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + + if (IsDlgButtonChecked(hwndDlg, IDC_ADD_DATE_NAME)) { + EnableWindow(GetDlgItem(hwndDlg, IDC_PREFIX), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + EnableWindow(GetDlgItem(hwndDlg, IDC_SUFFIX), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + EnableWindow(GetDlgItem(hwndDlg, IDC_24_HOUR), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + } + else { + EnableWindow(GetDlgItem(hwndDlg, IDC_PREFIX), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_SUFFIX), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_24_HOUR), 0); + } + + EnableWindow(GetDlgItem(hwndDlg, IDC_EVENT_TYPE), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_TYPE), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + EnableWindow(GetDlgItem(hwndDlg, IDC_ALWAYS_LOG), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + + eventIndex = g_plugin.getByte(hContact, EVNT_INDEX_KEY, 0); + alertIndex = g_plugin.getByte(hContact, ALRT_INDEX_KEY, 0); + + if (eventIndex == 2) { // part of webpage changed + EnableWindow(GetDlgItem(hwndDlg, IDC_START2), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + EnableWindow(GetDlgItem(hwndDlg, IDC_END2), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + } + else { + EnableWindow(GetDlgItem(hwndDlg, IDC_START2), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_END2), 0); + } + + // //////// + if (alertIndex == 0) { // popup + if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) { + EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 0); + + if (eventIndex == 2) // part of webpage changed + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), 0); + if (eventIndex == 1) // webpage changed + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), 0); + if (eventIndex == 0) // string present + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + } + } + else if (alertIndex == 1) { // log to file + if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) { + EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 1); + + if (eventIndex == 1) // webpage changed + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), 0); + if (eventIndex == 0) // string present + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + } + else { + EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 0); + } + } + else if (alertIndex == 2) { // display window + if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) { + EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 0); + + if (eventIndex == 1) // webpage changed + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), 0); + if (eventIndex == 0) // string present + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + } + } + else if (alertIndex == 3) { // osd + if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) { + EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 0); + + if (eventIndex == 1) // webpage changed + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), 0); + if (eventIndex == 0) // string present + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + } + } + + if (eventIndex == 0) // string present + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))); + + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_APPLY), 1); + + if (IsDlgButtonChecked(hwndDlg, IDC_ALWAYS_LOG)) { + if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) { + EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 1); + } + else { + EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 0); + } + } + break; + + case IDC_ALWAYS_LOG: + EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), (IsDlgButtonChecked(hwndDlg, IDC_ALWAYS_LOG))); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), (IsDlgButtonChecked(hwndDlg, IDC_ALWAYS_LOG))); + EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), (IsDlgButtonChecked(hwndDlg, IDC_ALWAYS_LOG))); + EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), (IsDlgButtonChecked(hwndDlg, IDC_ALWAYS_LOG))); + break; + + case IDC_ALERT_TYPE: + if (HIWORD(wParam) == CBN_SELCHANGE || HIWORD(wParam) == CBN_EDITCHANGE) { + hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + alertIndex = SendDlgItemMessage(hwndDlg, IDC_ALERT_TYPE, CB_GETCURSEL, 0, 0); + + if (HIWORD(wParam) == CBN_SELCHANGE) { + g_plugin.setByte(hContact, ALRT_INDEX_KEY, alertIndex); + if (alertIndex == 0) { + // PopUp + EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 0); + } + else if (alertIndex == 1) { + // log to file + EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 1); + } + else if (alertIndex == 2) { + // data window + EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 0); + } + else if (alertIndex == 3) { + // OSD + EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), 0); + } + + if (IsDlgButtonChecked(hwndDlg, IDC_ALWAYS_LOG)) { + EnableWindow(GetDlgItem(hwndDlg, IDC_APPEND), (IsDlgButtonChecked(hwndDlg, IDC_ALWAYS_LOG))); + EnableWindow(GetDlgItem(hwndDlg, IDC_FILENAME), (IsDlgButtonChecked(hwndDlg, IDC_ALWAYS_LOG))); + EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE), (IsDlgButtonChecked(hwndDlg, IDC_ALWAYS_LOG))); + EnableWindow(GetDlgItem(hwndDlg, IDC_SAVE_AS_RAW), (IsDlgButtonChecked(hwndDlg, IDC_ALWAYS_LOG))); + } + } + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_APPLY), 1); + } + break; + + case IDC_EVENT_TYPE: + if (HIWORD(wParam) == CBN_SELCHANGE || HIWORD(wParam) == CBN_EDITCHANGE) { + hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + eventIndex = SendDlgItemMessage(hwndDlg, IDC_EVENT_TYPE, CB_GETCURSEL, 0, 0); + + if (HIWORD(wParam) == CBN_SELCHANGE) { + g_plugin.setByte(hContact, EVNT_INDEX_KEY, eventIndex); + if (eventIndex == 0) { + // event when string is present + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_START2), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_END2), 0); + } + else if (eventIndex == 1) { + // event when web page changes + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_START2), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_END2), 0); + } + else if (eventIndex == 2) { + // event when part of web page changes + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_STRING), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_START2), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_END2), 1); + } + } + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_APPLY), 1); + } + break; + + case IDC_ALERT_APPLY: + case IDC_OK2: + { + hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + + eventIndex = g_plugin.getByte(hContact, EVNT_INDEX_KEY, 0); + alertIndex = g_plugin.getByte(hContact, ALRT_INDEX_KEY, 0); + + g_plugin.setByte(hContact, ENABLE_ALERTS_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)); + g_plugin.setByte(hContact, APND_DATE_NAME_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_ADD_DATE_NAME)); + g_plugin.setByte(hContact, USE_24_HOUR_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_24_HOUR)); + g_plugin.setByte(hContact, ALWAYS_LOG_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_ALWAYS_LOG)); + + //if alerts is unticked delete the cache + if (!(IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))) + SiteDeleted(hContact, 0); + + if (eventIndex == 0) // string present + if (!(GetWindowTextLength(GetDlgItem(hwndDlg, IDC_ALERT_STRING)))) + if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) { + MessageBox(nullptr, TranslateT("You need to supply a search string."), _A2W(MODULENAME), MB_OK); + break; + } + + if (eventIndex == 2) // part of web page changed + if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) { + if (!(GetWindowTextLength(GetDlgItem(hwndDlg, IDC_START2)))) { + MessageBox(nullptr, TranslateT("You need to supply a start string."), _A2W(MODULENAME), MB_OK); + break; + } + if (!(GetWindowTextLength(GetDlgItem(hwndDlg, IDC_END2)))) { + MessageBox(nullptr, TranslateT("You need to supply an end string."), _A2W(MODULENAME), MB_OK); + break; + } + } + + if (alertIndex == 1) // log to file + if (!(GetWindowTextLength(GetDlgItem(hwndDlg, IDC_FILENAME)))) + if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) { + MessageBox(nullptr, TranslateT("You need to supply a file name and path."), _A2W(MODULENAME), MB_OK); + break; + } + + if (IsDlgButtonChecked(hwndDlg, IDC_ALWAYS_LOG)) + if (!(GetWindowTextLength(GetDlgItem(hwndDlg, IDC_FILENAME)))) + if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) { + MessageBox(nullptr, TranslateT("You need to supply a file name and path."), _A2W(MODULENAME), MB_OK); + break; + } + + wchar_t buf[MAX_PATH]; + GetDlgItemText(hwndDlg, IDC_FILENAME, buf, _countof(buf)); + g_plugin.setWString(hContact, FILE_KEY, buf); + + g_plugin.setByte(hContact, APPEND_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_APPEND)); + g_plugin.setByte(hContact, SAVE_AS_RAW_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SAVE_AS_RAW)); + + GetDlgItemText(hwndDlg, IDC_ALERT_STRING, buf, _countof(buf)); + g_plugin.setWString(hContact, ALERT_STRING_KEY, buf); + + GetDlgItemText(hwndDlg, IDC_START2, buf, _countof(buf)); + g_plugin.setWString(hContact, ALRT_S_STRING_KEY, buf); + + GetDlgItemText(hwndDlg, IDC_END2, buf, _countof(buf)); + g_plugin.setWString(hContact, ALRT_E_STRING_KEY, buf); + + g_plugin.setByte(hContact, CONTACT_PREFIX_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_PREFIX)); + + EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_APPLY), 0); + + if (LOWORD(wParam) == IDC_OK2) + EndDialog(hwndDlg, 1); + } + break; + + case IDC_ALERT_CANCEL: + case IDC_CANCEL: + EndDialog(hwndDlg, 0); + } + } + return FALSE; +} + +///////////////////////////////////////////////////////////////////////////////////////// + +INT_PTR CALLBACK DlgProcContactOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + DBVARIANT dbv; + wchar_t url[300]; + HWND ParentHwnd = GetParent(hwndDlg); + static int test; + static int test2; + MCONTACT hContact; + + switch (msg) { + case WM_INITDIALOG: + TranslateDialogDefault(hwndDlg); + + hContact = (MCONTACT)lParam; + + test = 0; + test2 = 0; + + SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)hContact); + + SetWindowText(hwndDlg, TranslateT("Contact options")); + + SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_OPTIONS))); + + EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_APPLY), 0); + + if (!g_plugin.getWString(hContact, URL_KEY, &dbv)) { + SetDlgItemText(hwndDlg, IDC_URL, dbv.pwszVal); + db_free(&dbv); + } + if (!g_plugin.getWString(hContact, START_STRING_KEY, &dbv)) { + SetDlgItemText(hwndDlg, IDC_START, dbv.pwszVal); + db_free(&dbv); + } + if (!g_plugin.getWString(hContact, END_STRING_KEY, &dbv)) { + SetDlgItemText(hwndDlg, IDC_END, dbv.pwszVal); + db_free(&dbv); + } + if (g_plugin.getWString(hContact, PRESERVE_NAME_KEY, &dbv)) { + db_free(&dbv); + db_get_ws(hContact, "CList", "MyHandle", &dbv); + g_plugin.setWString(hContact, PRESERVE_NAME_KEY, dbv.pwszVal); + db_free(&dbv); + } + if (!g_plugin.getWString(hContact, PRESERVE_NAME_KEY, &dbv)) { + SetDlgItemText(hwndDlg, IDC_SITE_NAME, dbv.pwszVal); + db_free(&dbv); + } + + CheckDlgButton(hwndDlg, IDC_CLEAN, g_plugin.getByte(hContact, CLEAR_DISPLAY_KEY, 0) ? BST_CHECKED : BST_UNCHECKED); + + SendDlgItemMessage(hwndDlg, IDC_RWSPACE, TBM_SETRANGE, FALSE, MAKELONG(0, 4)); + SendDlgItemMessage(hwndDlg, IDC_RWSPACE, TBM_SETPOS, TRUE, g_plugin.getByte(hContact, RWSPACE_KEY, 0)); + SetDlgItemText(hwndDlg, IDC_RWSPC_TEXT, TranslateW(szTrackerBarDescr[SendDlgItemMessage(hwndDlg, IDC_RWSPACE, TBM_GETPOS, 0, 0)])); + + EnableWindow(GetDlgItem(hwndDlg, IDC_RWSPACE), (IsDlgButtonChecked(hwndDlg, IDC_CLEAN))); + EnableWindow(GetDlgItem(hwndDlg, IDC_RWSPC_TEXT), (IsDlgButtonChecked(hwndDlg, IDC_CLEAN))); + + if (g_plugin.getByte(hContact, DBLE_WIN_KEY, 1) == 1) + CheckRadioButton(hwndDlg, IDC_DBLE_WEB, IDC_DBLE_WIN, IDC_DBLE_WIN); + else + CheckRadioButton(hwndDlg, IDC_DBLE_WEB, IDC_DBLE_WIN, IDC_DBLE_WEB); + + if (g_plugin.getByte(hContact, U_ALLSITE_KEY, 0) == 1) { + CheckRadioButton(hwndDlg, IDC_U_SE_STRINGS, IDC_U_ALLSITE, IDC_U_ALLSITE); + EnableWindow(GetDlgItem(hwndDlg, IDC_START), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_END), 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_CPY_STRINGS), 0); + } + else { + CheckRadioButton(hwndDlg, IDC_U_SE_STRINGS, IDC_U_ALLSITE, IDC_U_SE_STRINGS); + EnableWindow(GetDlgItem(hwndDlg, IDC_START), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_END), 1); + EnableWindow(GetDlgItem(hwndDlg, IDC_CPY_STRINGS), 1); + //EnableWindow(GetDlgItem(hwndDlg, IDC_CPY_STR_TXT), 1); + } + break; + + case WM_HSCROLL: + SetDlgItemText(hwndDlg, IDC_RWSPC_TEXT, TranslateW(szTrackerBarDescr[SendDlgItemMessage(hwndDlg, IDC_RWSPACE, TBM_GETPOS, 0, 0)])); + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_APPLY), 1); + break; + + case WM_COMMAND: + switch (LOWORD(wParam)) { + case WM_CLOSE: + case IDCANCEL: + if (hwndDlg) { + DestroyWindow(hwndDlg); + hwndDlg = nullptr; + } + return TRUE; + + case IDC_SITE_NAME: + case IDC_URL: + if (HIWORD(wParam) == EN_CHANGE) + test++; + if (test > 2) + EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_APPLY), 1); + break; + + case IDC_DBLE_WEB: + case IDC_DBLE_WIN: + EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_APPLY), 1); + break; + + case IDC_START: + case IDC_END: + if (HIWORD(wParam) == EN_CHANGE) + test2++; + if (test2 > 2) + EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_APPLY), 1); + break; + + case IDC_CPY_STRINGS: + { + wchar_t string[128]; + hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + + GetDlgItemText(hwndDlg, IDC_START, string, _countof(string)); + g_plugin.setWString(hContact, ALRT_S_STRING_KEY, string); + + GetDlgItemText(hwndDlg, IDC_END, string, _countof(string)); + g_plugin.setWString(hContact, ALRT_E_STRING_KEY, string); + + g_plugin.setWord(hContact, EVNT_INDEX_KEY, 2); + } + break; + + case IDC_CLEAN: + EnableWindow(GetDlgItem(hwndDlg, IDC_RWSPACE), (IsDlgButtonChecked(hwndDlg, IDC_CLEAN))); + EnableWindow(GetDlgItem(hwndDlg, IDC_RWSPC_TEXT), (IsDlgButtonChecked(hwndDlg, IDC_CLEAN))); + EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_APPLY), 1); + break; + + case IDC_U_SE_STRINGS: + EnableWindow(GetDlgItem(hwndDlg, IDC_START), (IsDlgButtonChecked(hwndDlg, IDC_U_SE_STRINGS))); + EnableWindow(GetDlgItem(hwndDlg, IDC_END), (IsDlgButtonChecked(hwndDlg, IDC_U_SE_STRINGS))); + EnableWindow(GetDlgItem(hwndDlg, IDC_CPY_STRINGS), (IsDlgButtonChecked(hwndDlg, IDC_U_SE_STRINGS))); + EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_APPLY), 1); + break; + + case IDC_U_ALLSITE: + EnableWindow(GetDlgItem(hwndDlg, IDC_START), (IsDlgButtonChecked(hwndDlg, IDC_U_SE_STRINGS))); + EnableWindow(GetDlgItem(hwndDlg, IDC_END), (IsDlgButtonChecked(hwndDlg, IDC_U_SE_STRINGS))); + EnableWindow(GetDlgItem(hwndDlg, IDC_CPY_STRINGS), (IsDlgButtonChecked(hwndDlg, IDC_U_SE_STRINGS))); + EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_APPLY), 1); + break; + + case IDC_OPT_APPLY: + case IDOK: + { + wchar_t str[128], contactname[128]; + if (!GetWindowTextLength(GetDlgItem(hwndDlg, IDC_URL))) { + MessageBox(nullptr, TranslateT("You need to supply a URL."), _A2W(MODULENAME), MB_OK); + break; + } + if (!GetWindowTextLength(GetDlgItem(hwndDlg, IDC_START))) { + if (IsDlgButtonChecked(hwndDlg, IDC_U_SE_STRINGS)) { + MessageBox(nullptr, TranslateT("You need to supply a start string."), _A2W(MODULENAME), MB_OK); + break; + } + } + if (!GetWindowTextLength(GetDlgItem(hwndDlg, IDC_END))) { + if (IsDlgButtonChecked(hwndDlg, IDC_U_SE_STRINGS)) { + MessageBox(nullptr, TranslateT("You need to supply an end string."), _A2W(MODULENAME), MB_OK); + break; + } + } + if (!GetWindowTextLength(GetDlgItem(hwndDlg, IDC_SITE_NAME))) { + MessageBox(nullptr, TranslateT("You need to supply a name for the contact."), _A2W(MODULENAME), MB_OK); + break; + } + + GetDlgItemText(hwndDlg, IDC_SITE_NAME, contactname, _countof(contactname)); + if (wcschr(contactname, '\\') != nullptr) { + MessageBox(nullptr, TranslateT("Invalid symbol present in contact name."), _A2W(MODULENAME), MB_OK); + break; + } + if (wcschr(contactname, '/') != nullptr) { + MessageBox(nullptr, TranslateT("Invalid symbol present in contact name."), _A2W(MODULENAME), MB_OK); + break; + } + if (wcschr(contactname, ':') != nullptr) { + MessageBox(nullptr, TranslateT("Invalid symbol present in contact name."), _A2W(MODULENAME), MB_OK); + break; + } + if (wcschr(contactname, '*') != nullptr) { + MessageBox(nullptr, TranslateT("Invalid symbol present in contact name."), _A2W(MODULENAME), MB_OK); + break; + } + if (wcschr(contactname, '?') != nullptr) { + MessageBox(nullptr, TranslateT("Invalid symbol present in contact name."), _A2W(MODULENAME), MB_OK); + break; + } + if (wcschr(contactname, '\"') != nullptr) { + MessageBox(nullptr, TranslateT("Invalid symbol present in contact name."), _A2W(MODULENAME), MB_OK); + break; + } + if (wcschr(contactname, '<') != nullptr) { + MessageBox(nullptr, TranslateT("Invalid symbol present in contact name."), _A2W(MODULENAME), MB_OK); + break; + } + if (wcschr(contactname, '>') != nullptr) { + MessageBox(nullptr, TranslateT("Invalid symbol present in contact name."), _A2W(MODULENAME), MB_OK); + break; + } + if (wcschr(contactname, '|') != nullptr) { + MessageBox(nullptr, TranslateT("Invalid symbol present in contact name."), _A2W(MODULENAME), MB_OK); + break; + } + + hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + + GetDlgItemText(hwndDlg, IDC_URL, url, _countof(url)); + g_plugin.setWString(hContact, URL_KEY, url); + g_plugin.setWString(hContact, "Homepage", url); + + GetDlgItemText(hwndDlg, IDC_START, str, _countof(str)); + g_plugin.setWString(hContact, START_STRING_KEY, str); + + GetDlgItemText(hwndDlg, IDC_END, str, _countof(str)); + g_plugin.setWString(hContact, END_STRING_KEY, str); + + GetDlgItemText(hwndDlg, IDC_SITE_NAME, str, _countof(str)); + db_set_ws(hContact, "CList", "MyHandle", str); + + g_plugin.setByte(hContact, DBLE_WIN_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_DBLE_WIN)); + g_plugin.setByte(hContact, U_ALLSITE_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_U_ALLSITE)); + + g_plugin.setByte(hContact, CLEAR_DISPLAY_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CLEAN)); + g_plugin.setByte(hContact, RWSPACE_KEY, (BYTE)(SendDlgItemMessage(hwndDlg, IDC_RWSPACE, TBM_GETPOS, 0, 0))); + + SetDlgItemText(ParentHwnd, IDC_OPEN_URL, FixButtonText(url, _countof(url))); + + SetWindowText(ParentHwnd, str); + EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_APPLY), 0); + + if (LOWORD(wParam) == IDOK) + EndDialog(hwndDlg, 1); + } + break; + + case IDC_OPT_CANCEL: + EndDialog(hwndDlg, 0); + } + break; + } + return FALSE; +} |