summaryrefslogtreecommitdiff
path: root/protocols/WebView/src
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/WebView/src')
-rw-r--r--protocols/WebView/src/main.cpp285
-rw-r--r--protocols/WebView/src/resource.h139
-rw-r--r--protocols/WebView/src/stdafx.cxx18
-rw-r--r--protocols/WebView/src/stdafx.h36
-rw-r--r--protocols/WebView/src/version.h13
-rw-r--r--protocols/WebView/src/webview.cpp481
-rw-r--r--protocols/WebView/src/webview.h254
-rw-r--r--protocols/WebView/src/webview_alerts.cpp839
-rw-r--r--protocols/WebView/src/webview_cleanup.cpp797
-rw-r--r--protocols/WebView/src/webview_datawnd.cpp514
-rw-r--r--protocols/WebView/src/webview_getdata.cpp511
-rw-r--r--protocols/WebView/src/webview_opts.cpp1265
-rw-r--r--protocols/WebView/src/webview_services.cpp458
13 files changed, 5610 insertions, 0 deletions
diff --git a/protocols/WebView/src/main.cpp b/protocols/WebView/src/main.cpp
new file mode 100644
index 0000000000..d53964c0af
--- /dev/null
+++ b/protocols/WebView/src/main.cpp
@@ -0,0 +1,285 @@
+/*
+ * 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"
+
+MWindowList hWindowList;
+HNETLIBUSER hNetlibUser;
+HANDLE hHookDisplayDataAlert, hHookAlertPopup, hHookAlertWPopup, hHookErrorPopup, hHookAlertOSD;
+
+CMPlugin g_plugin;
+
+static HMODULE hRichEd = nullptr;
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+PLUGININFOEX pluginInfoEx = {
+ sizeof(PLUGININFOEX),
+ __PLUGIN_NAME,
+ PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM),
+ __DESCRIPTION,
+ __AUTHOR,
+ __COPYRIGHT,
+ __AUTHORWEB,
+ UNICODE_AWARE,
+ // {CD5427FB-5320-4f65-B4BF-86B7CF7B5087}
+ {0xcd5427fb, 0x5320, 0x4f65, {0xb4, 0xbf, 0x86, 0xb7, 0xcf, 0x7b, 0x50, 0x87}}
+};
+
+CMPlugin::CMPlugin() :
+ PLUGIN<CMPlugin>(MODULENAME, pluginInfoEx)
+{
+ RegisterProtocol(PROTOTYPE_PROTOCOL);
+ SetUniqueId("PreserveName");
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+void InitServices()
+{
+ CreateProtoServiceFunction(MODULENAME, PS_GETCAPS, GetCaps);
+ CreateProtoServiceFunction(MODULENAME, PS_GETNAME, GetName);
+ CreateProtoServiceFunction(MODULENAME, PS_LOADICON, BPLoadIcon);
+ CreateProtoServiceFunction(MODULENAME, PS_SETSTATUS, SetStatus);
+ CreateProtoServiceFunction(MODULENAME, PS_GETSTATUS, GetStatus);
+ CreateProtoServiceFunction(MODULENAME, PS_BASICSEARCH, BasicSearch);
+ CreateProtoServiceFunction(MODULENAME, PS_ADDTOLIST, AddToList);
+ CreateProtoServiceFunction(MODULENAME, PSS_GETINFO, GetInfo);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+void ChangeContactStatus(int con_stat)
+{
+ WORD status_code = 0;
+ if (con_stat == 0)
+ status_code = ID_STATUS_OFFLINE;
+ if (con_stat == 1)
+ status_code = ID_STATUS_ONLINE;
+ if (con_stat == 2)
+ status_code = ID_STATUS_AWAY;
+ if (con_stat == 3)
+ status_code = ID_STATUS_NA;
+
+ for (auto &hContact : Contacts(MODULENAME))
+ g_plugin.setWord(hContact, "Status", status_code);
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOCOL, MIID_LAST };
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+int CMPlugin::Load()
+{
+ HookEvent(ME_CLIST_DOUBLECLICKED, Doubleclick);
+
+ hMenu = LoadMenu(g_plugin.getInst(), MAKEINTRESOURCE(IDR_CONTEXT));
+ hRichEd = LoadLibrary(L"Msftedit.dll");
+
+ /*TIMERS*/
+ if ((g_plugin.getDword(REFRESH_KEY, TIME) != 0)) {
+ timerId = SetTimer(nullptr, 0, ((g_plugin.getDword(REFRESH_KEY, TIME)) * MINUTE), timerfunc);
+ g_plugin.setDword(COUNTDOWN_KEY, 0);
+ Countdown = SetTimer(nullptr, 0, MINUTE, Countdownfunc);
+ }
+
+ InitialiseGlobals();
+
+ // register netlib handle
+ char tempNdesc[50];
+ mir_snprintf(tempNdesc, "%s connection settings", MODULENAME);
+
+ NETLIBUSER nlu = {};
+ nlu.flags = NUF_OUTGOING | NUF_HTTPCONNS;
+ nlu.szSettingsModule = MODULENAME;
+ nlu.szDescriptiveName.a = tempNdesc;
+ hNetlibUser = Netlib_RegisterUser(&nlu);
+
+ //protocol services
+ InitServices();
+
+ //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);
+ }
+
+ // contact menu
+ mi.flags = CMIF_UNICODE;
+
+ SET_UID(mi, 0xadc6a9a4, 0xdf7, 0x4f63, 0x89, 0x11, 0x8e, 0x42, 0x1d, 0xd6, 0x29, 0x31);
+ CreateServiceFunction("Open web page", WebsiteMenuCommand);
+ mi.position = 100;
+ mi.hIcolibItem = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_URL));
+ mi.pszService = "Open web page";
+ mi.name.w = LPGENW("Open web page");
+ Menu_AddContactMenuItem(&mi, MODULENAME);
+
+ SET_UID(mi, 0x9d803e61, 0xc929, 0x4c6e, 0x9e, 0x7, 0x93, 0x0, 0xab, 0x14, 0x13, 0x50);
+ CreateServiceFunction("OpenClose Window", DataWndMenuCommand);
+ mi.pszService = "OpenClose Window";
+ mi.hIcolibItem = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_SHOW_HIDE));
+ mi.name.w = LPGENW("Open/Close window");
+ Menu_AddContactMenuItem(&mi, MODULENAME);
+
+ SET_UID(mi, 0x3840cc71, 0xcc85, 0x448d, 0xb5, 0xc8, 0x1a, 0x7d, 0xfe, 0xf0, 0x8, 0x85);
+ mi.position = 2222220;
+ mi.pszService = "UpdateData";
+ mi.hIcolibItem = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_UPDATE));
+ mi.name.w = LPGENW("Update data");
+ Menu_AddContactMenuItem(&mi, MODULENAME);
+
+ SET_UID(mi, 0xd1ab586c, 0x2c71, 0x429c, 0xb1, 0x79, 0x7b, 0x3a, 0x1d, 0x4a, 0xc1, 0x7d);
+ CreateServiceFunction("ContactOptions", CntOptionsMenuCommand);
+ mi.pszService = "ContactOptions";
+ mi.hIcolibItem = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_OPTIONS));
+ mi.name.w = LPGENW("Contact options");
+ Menu_AddContactMenuItem(&mi, MODULENAME);
+
+ SET_UID(mi, 0xe4cda597, 0x9def, 0x4f54, 0x8a, 0xc6, 0x69, 0x3b, 0x5a, 0x7d, 0x77, 0xb6);
+ CreateServiceFunction("ContactAlertOpts", CntAlertMenuCommand);
+ mi.pszService = "ContactAlertOpts";
+ mi.hIcolibItem = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_ALERT));
+ mi.name.w = LPGENW("Contact alert options");
+ Menu_AddContactMenuItem(&mi, MODULENAME);
+
+ SET_UID(mi, 0x63fdeed8, 0xf880, 0x423f, 0x95, 0xae, 0x20, 0x8c, 0x86, 0x3c, 0x5, 0xd8);
+ CreateServiceFunction("PingWebsite", PingWebsiteMenuCommand);
+ mi.pszService = "PingWebsite";
+ mi.hIcolibItem = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_PING));
+ mi.name.w = LPGENW("Ping web site");
+ Menu_AddContactMenuItem(&mi, MODULENAME);
+
+ SET_UID(mi, 0x28fd36de, 0x6ce1, 0x43d0, 0xa1, 0x6e, 0x98, 0x71, 0x53, 0xe8, 0xc9, 0xf4);
+ CreateServiceFunction("StopDataProcessing", StpPrcssMenuCommand);
+ mi.pszService = "StopDataProcessing";
+ mi.hIcolibItem = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_STOP));
+ mi.name.w = LPGENW("Stop data processing");
+ Menu_AddContactMenuItem(&mi, MODULENAME);
+
+ hWindowList = WindowList_Create();
+
+ HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
+ HookEvent(ME_DB_CONTACT_SETTINGCHANGED, DBSettingChanged);
+ HookEvent(ME_DB_CONTACT_DELETED, SiteDeleted);
+ HookEvent(ME_OPT_INITIALISE, OptInitialise);
+
+ g_plugin.setByte(HAS_CRASHED_KEY, 1);
+ return 0;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+int CMPlugin::Unload()
+{
+ ChangeContactStatus(0);
+
+ KillTimer(nullptr, timerId);
+ KillTimer(nullptr, Countdown);
+
+ g_plugin.setByte(HAS_CRASHED_KEY, 0);
+ SavewinSettings();
+ if (hRichEd)
+ FreeLibrary(hRichEd);
+
+ if (hNetlibUser) {
+ Netlib_CloseHandle(hNetlibUser);
+ hNetlibUser = nullptr;
+ }
+
+ if (hHookDisplayDataAlert)
+ DestroyHookableEvent(hHookDisplayDataAlert);
+ if (hHookAlertPopup)
+ DestroyHookableEvent(hHookAlertPopup);
+ if (hHookAlertWPopup)
+ DestroyHookableEvent(hHookAlertWPopup);
+
+ if (h_font != nullptr)
+ DeleteObject(h_font);
+ if (hMenu)
+ DestroyMenu(hMenu);
+ WindowList_Destroy(hWindowList);
+ return 0;
+}
diff --git a/protocols/WebView/src/resource.h b/protocols/WebView/src/resource.h
new file mode 100644
index 0000000000..d0203c7cab
--- /dev/null
+++ b/protocols/WebView/src/resource.h
@@ -0,0 +1,139 @@
+#define UNI 1
+
+#define IDC_STATIC -1
+
+#define IDI_SITE 101
+#define IDI_STICK 102
+#define IDI_UNSTICK 103
+#define IDI_URL 104
+#define IDI_OPTIONS 105
+#define IDI_UPDATE 106
+#define IDI_SHOW_HIDE 107
+#define IDI_FIND 108
+#define IDI_ALERT 110
+#define IDI_FOLDER 111
+#define IDI_UPDATEALL 112
+#define IDI_MARKALLREAD 113
+#define IDI_PING 114
+#define IDI_STOP 115
+
+
+#define IDC_UPDATE_ONSTART 300
+#define IDC_DBLE_WEB 301
+#define IDC_DBLE_WIN 302
+#define IDC_UPDATE_ON_OPEN 303
+#define IDC_UPDATE_ONALERT 304
+
+#define IDD_OPT 443
+#define IDC_DISABLEMENU 446
+#define IDC_OPEN_WEBPAGE 447
+#define IDC_TIME 450
+
+#define IDC_BGCOLOR 451
+#define IDC_TXTCOLOR 452
+#define IDC_RESTART 453
+#define IDC_CLEAN 457
+#define IDC_SUPPRESS 458
+#define IDC_SPIN1 461
+#define IDC_HIDE_STATUS_ICON 464
+#define IDC_RWSPACE 465
+#define IDC_RWSPC_TEXT 466
+#define IDC_TYPEFACE 467
+#define IDC_FONT_BOLD 468
+#define IDC_FONT_ITALIC 469
+#define IDC_FONT_UNDERLINE 470
+#define IDC_FONTSIZE 471
+#define IDC_U_SE_STRINGS 475
+#define IDC_U_ALLSITE 476
+#define IDC_ERROR_POPUP 477
+#define IDC_START_DELAY 480
+#define IDC_SPIN2 481
+#define IDC_STARTDELAYTXT 482
+#define IDC_STDELAYSECTXT 483
+#define IDC_SAVE_INDIVID_POS 484
+#define IDC_ADV_GRP 485
+#define IDC_NO_PROTECT 486
+#define IDC_NOT_RECOMND_TXT 487
+#define IDC_SCRIPT 488
+#define IDC_DATAPOPUP 489
+
+#define IDR_CONTEXT 500
+#define IDM_CUT 501
+#define IDM_PASTE 502
+#define IDM_DELETE 503
+#define IDM_CLEAR_ALL 504
+#define IDM_COPY 505
+#define IDM_COPYALL 506
+#define IDM_SELECTALL 507
+
+#define IDC_SITE_NAME 551
+#define IDC_ERR_CHK 552
+#define IDC_APPEND 554
+#define IDC_FILENAME 555
+#define IDC_BROWSE 556
+#define IDC_SAVE_AS_RAW 557
+//#define IDC_AGENT 557//temp
+
+#define IDD_DISPLAY_DATA 600
+#define IDC_OPEN_URL 601
+#define IDC_DATA 602
+#define IDC_UPDATE_BUTTON 603
+#define IDC_STICK_BUTTON 604
+#define IDC_FIND_BUTTON 605
+#define IDC_STATUSBAR 606
+#define IDC_OPTIONS_BUTTON 607
+#define IDC_ALERT_BUTTON 608
+//#define IDC_HIDDEN_URL 609
+#define IDC_STOP 609
+
+#define IDC_ERRORMSG 620
+
+#define IDD_CONTACT_OPT 700
+#define IDC_END 701
+#define IDC_START 702
+#define IDC_URL 703
+#define IDC_OPT_CANCEL 704
+#define IDC_OPT_APPLY 705
+#define IDC_CPY_STRINGS 706
+
+
+#define IDD_FIND 750
+#define IDC_FINDWHAT 751
+#define IDC_OK 752
+#define IDC_CANCEL 753
+#define IDC_SEARCH_COMPLETE 754
+
+#define IDD_ALRT_OPT 801
+#define IDC_ENABLE_ALERTS 802
+#define IDC_OK2 803
+#define IDC_ALERT_STRING 804
+#define IDC_ALERT_TYPE 807
+#define IDC_EVENT_TYPE 808
+#define IDC_ALERT_CANCEL 809
+#define IDC_ALERT_APPLY 810
+#define IDC_START2 811
+#define IDC_END2 812
+#define IDC_ADD_DATE_NAME 813
+#define IDC_DELAY 814
+#define IDC_PREFIX 815
+#define IDC_SUFFIX 816
+#define IDC_24_HOUR 817
+#define IDC_ALWAYS_LOG 818
+
+#define IDD_POPUP 850
+#define IDC_POP_BGCOLOUR 851
+#define IDC_POP_TEXTCOLOUR 852
+#define IDC_PD1 853
+#define IDC_PD2 854
+//#define IDC_PD3 855
+#define IDC_PREVIEW 856
+#define IDC_POP_USEWINCOLORS 857
+#define IDC_POP_USESAMECOLORS 858
+#define IDC_POP_USECUSTCOLORS 859
+#define IDC_LCLK_WINDOW 860
+#define IDC_LCLK_WEB_PGE 861
+#define IDC_LCLK_DISMISS 862
+#define IDC_RCLK_WINDOW 863
+#define IDC_RCLK_WEB_PGE 864
+#define IDC_RCLK_DISMISS 865
+//#define IDC_PUALERT 866
diff --git a/protocols/WebView/src/stdafx.cxx b/protocols/WebView/src/stdafx.cxx
new file mode 100644
index 0000000000..1b563fc866
--- /dev/null
+++ b/protocols/WebView/src/stdafx.cxx
@@ -0,0 +1,18 @@
+/*
+Copyright (C) 2012-19 Miranda NG team (https://miranda-ng.org)
+
+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 version 2
+of the License.
+
+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, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "stdafx.h" \ No newline at end of file
diff --git a/protocols/WebView/src/stdafx.h b/protocols/WebView/src/stdafx.h
new file mode 100644
index 0000000000..91a1ac63c1
--- /dev/null
+++ b/protocols/WebView/src/stdafx.h
@@ -0,0 +1,36 @@
+#pragma once
+
+#include <windows.h>
+#include <shlwapi.h>
+#include <Richedit.h>
+#include <Commctrl.h>
+
+#include <ctype.h>
+#include <io.h>
+#include <locale.h>
+#include <process.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+#include <wchar.h>
+
+#include <newpluginapi.h>
+#include <m_system.h>
+#include <m_clist.h>
+#include <m_clist.h>
+#include <m_database.h>
+#include <m_protocols.h>
+#include <m_protosvc.h>
+#include <m_button.h>
+#include <m_utils.h>
+#include <m_skin.h>
+#include <m_genmenu.h>
+#include <m_icolib.h>
+#include <m_options.h>
+#include <m_popup.h>
+#include <m_netlib.h>
+#include <m_langpack.h>
+#include <m_findadd.h>
+
+#include "resource.h"
+#include "version.h"
diff --git a/protocols/WebView/src/version.h b/protocols/WebView/src/version.h
new file mode 100644
index 0000000000..c2030de835
--- /dev/null
+++ b/protocols/WebView/src/version.h
@@ -0,0 +1,13 @@
+#define __MAJOR_VERSION 0
+#define __MINOR_VERSION 1
+#define __RELEASE_NUM 3
+#define __BUILD_NUM 2
+
+#include <stdver.h>
+
+#define __PLUGIN_NAME "Webview"
+#define __FILENAME "Webview.dll"
+#define __DESCRIPTION "Adds web pages as contacts to your contact list and can display text and/or issue change alerts from those pages in a window."
+#define __AUTHOR "Vincent Joyce"
+#define __AUTHORWEB "https://miranda-ng.org/p/WebView/"
+#define __COPYRIGHT "© 2011 Vincent Joyce"
diff --git a/protocols/WebView/src/webview.cpp b/protocols/WebView/src/webview.cpp
new file mode 100644
index 0000000000..87e5baf4a1
--- /dev/null
+++ b/protocols/WebView/src/webview.cpp
@@ -0,0 +1,481 @@
+/*
+* 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"
+
+char* WndClass = "WEBWnd";
+WNDCLASSEX wincl;
+MSG messages;
+DWORD winheight;
+int StartUpDelay = 0;
+
+int Xposition, Yposition;
+int WindowHeight, WindowWidth;
+COLORREF BackgoundClr, TextClr;
+
+UINT_PTR timerId;
+UINT_PTR Countdown;
+LOGFONT g_lf;
+HFONT h_font;
+HMENU hMenu;
+int bpStatus;
+HGENMENU hMenuItem1;
+HGENMENU hMenuItemCountdown;
+
+/*****************************************************************************/
+void ChangeMenuItem1()
+{
+ // Enable or Disable auto updates
+ LPCTSTR ptszName;
+ if (!g_plugin.getByte(DISABLE_AUTOUPDATE_KEY, 0))
+ ptszName = LPGENW("Auto update enabled");
+ else
+ ptszName = LPGENW("Auto update disabled");
+
+ Menu_ModifyItem(hMenuItem1, ptszName, LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_SITE)));
+}
+
+/*****************************************************************************/
+void ChangeMenuItemCountdown()
+{
+ // countdown
+ HICON hIcon = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_UPDATEALL));
+
+ wchar_t countername[100];
+ mir_snwprintf(countername, TranslateT("%d minutes to update"), g_plugin.getDword(COUNTDOWN_KEY, 0));
+
+ Menu_ModifyItem(hMenuItemCountdown, countername, hIcon, CMIF_KEEPUNTRANSLATED);
+}
+
+/*****************************************************************************/
+static int CALLBACK EnumFontsProc(ENUMLOGFONTEX *lpelfe, NEWTEXTMETRICEX*, int, LPARAM lParam)
+{
+ if (!IsWindow((HWND)lParam))
+ return FALSE;
+ if (SendMessage((HWND)lParam, CB_FINDSTRINGEXACT, -1, (LPARAM)lpelfe->elfLogFont.lfFaceName) == CB_ERR)
+ SendMessage((HWND)lParam, CB_ADDSTRING, 0, (LPARAM)lpelfe->elfLogFont.lfFaceName);
+ return TRUE;
+}
+
+void FillFontListThread(void *param)
+{
+ HDC hdc = GetDC((HWND)param);
+
+ LOGFONT lf = { 0 };
+ g_lf.lfCharSet = DEFAULT_CHARSET;
+ g_lf.lfFaceName[0] = 0;
+ g_lf.lfPitchAndFamily = 0;
+ EnumFontFamiliesEx(hdc, &lf, (FONTENUMPROC)EnumFontsProc, (LPARAM)GetDlgItem((HWND)param, IDC_TYPEFACE), 0);
+ ReleaseDC((HWND)param, hdc);
+}
+
+/*****************************************************************************/
+void TxtclrLoop()
+{
+ for (auto &hContact : Contacts(MODULENAME)) {
+ HWND hwndDlg = WindowList_Find(hWindowList, hContact);
+ SetDlgItemText(hwndDlg, IDC_DATA, L"");
+ InvalidateRect(hwndDlg, nullptr, 1);
+ }
+}
+
+/*****************************************************************************/
+void BGclrLoop()
+{
+ for (auto &hContact : Contacts(MODULENAME)) {
+ HWND hwndDlg = (WindowList_Find(hWindowList, hContact));
+ SetDlgItemText(hwndDlg, IDC_DATA, L"");
+ SendDlgItemMessage(hwndDlg, IDC_DATA, EM_SETBKGNDCOLOR, 0, BackgoundClr);
+ InvalidateRect(hwndDlg, nullptr, 1);
+ }
+}
+
+/*****************************************************************************/
+void StartUpdate(void*)
+{
+ StartUpDelay = 1;
+ Sleep(((g_plugin.getDword(START_DELAY_KEY, 0)) * SECOND));
+
+ for (auto &hContact : Contacts(MODULENAME))
+ GetData((void*)hContact);
+
+ StartUpDelay = 0;
+}
+
+/*****************************************************************************/
+void ContactLoop(void*)
+{
+ if (StartUpDelay == 0) {
+ for (auto &hContact : Contacts(MODULENAME)) {
+ GetData((void*)hContact);
+ Sleep(10); // avoid 100% CPU
+ }
+ }
+
+ 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);
+ Yposition = g_plugin.getDword(Ypos_WIN_KEY, 0);
+
+ if (Yposition == -32000)
+ Yposition = 100;
+
+ if (Xposition == -32000)
+ Xposition = 100;
+
+ BackgoundClr = g_plugin.getDword(BG_COLOR_KEY, Def_color_bg);
+ TextClr = g_plugin.getDword(TXT_COLOR_KEY, Def_color_txt);
+
+ WindowHeight = g_plugin.getDword(WIN_HEIGHT_KEY, Def_win_height);
+ WindowWidth = g_plugin.getDword(WIN_WIDTH_KEY, Def_win_width);
+}
+
+/*****************************************************************************/
+int Doubleclick(WPARAM wParam, LPARAM)
+{
+ MCONTACT hContact = wParam;
+ char *szProto = GetContactProto(hContact);
+ if (mir_strcmp(MODULENAME, szProto))
+ return 0;
+
+ int action = g_plugin.getByte(hContact, DBLE_WIN_KEY, 1);
+ if (action == 0) {
+ ptrW url(g_plugin.getWStringA(hContact, "URL"));
+ Utils_OpenUrlW(url);
+
+ g_plugin.setWord(hContact, "Status", ID_STATUS_ONLINE);
+ }
+ else if (action == 1) {
+ HWND hwndDlg = WindowList_Find(hWindowList, hContact);
+ if (hwndDlg) {
+ SetForegroundWindow(hwndDlg);
+ SetFocus(hwndDlg);
+ }
+ else {
+ hwndDlg = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_DISPLAY_DATA), nullptr, DlgProcDisplayData, (LPARAM)hContact);
+ HWND hTopmost = g_plugin.getByte(hContact, ON_TOP_KEY, 0) ? HWND_TOPMOST : HWND_NOTOPMOST;
+ SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM)((HICON)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDI_STICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)));
+
+ if (g_plugin.getByte(SAVE_INDIVID_POS_KEY, 0))
+ SetWindowPos(hwndDlg, hTopmost,
+ g_plugin.getDword(hContact, "WVx", 100), // Xposition,
+ g_plugin.getDword(hContact, "WVy", 100), // Yposition,
+ g_plugin.getDword(hContact, "WVwidth", 412), // WindowWidth,
+ g_plugin.getDword(hContact, "WVheight", 350), 0); // WindowHeight,
+ else
+ SetWindowPos(hwndDlg, HWND_TOPMOST, Xposition, Yposition, WindowWidth, WindowHeight, 0);
+ }
+
+ ShowWindow(hwndDlg, SW_SHOW);
+ SetActiveWindow(hwndDlg);
+
+ if (g_plugin.getByte(UPDATE_ON_OPEN_KEY, 0)) {
+ if (g_plugin.getByte(hContact, ENABLE_ALERTS_KEY, 0))
+ mir_forkthread(ReadFromFile, (void*)hContact);
+ else
+ mir_forkthread(GetData, (void*)hContact);
+ g_plugin.setWord(hContact, "Status", ID_STATUS_ONLINE);
+ }
+ }
+
+ return 1;
+}
+
+/*****************************************************************************/
+int SendToRichEdit(HWND hWindow, char *truncated, COLORREF rgbText, COLORREF rgbBack)
+{
+ DBVARIANT dbv;
+ DWORD bold = 0;
+ DWORD italic = 0;
+ DWORD underline = 0;
+
+ SetDlgItemText(hWindow, IDC_DATA, L"");
+
+ CHARFORMAT2 cfFM;
+ memset(&cfFM, 0, sizeof(cfFM));
+ cfFM.cbSize = sizeof(CHARFORMAT2);
+ cfFM.dwMask = CFM_COLOR | CFM_CHARSET | CFM_FACE | ENM_LINK | ENM_MOUSEEVENTS | CFM_BOLD | CFM_ITALIC | CFM_UNDERLINE | CFM_SIZE;
+
+ if (g_plugin.getByte(FONT_BOLD_KEY, 0))
+ bold = CFE_BOLD;
+
+ if (g_plugin.getByte(FONT_ITALIC_KEY, 0))
+ italic = CFE_ITALIC;
+
+ if (g_plugin.getByte(FONT_UNDERLINE_KEY, 0))
+ underline = CFE_UNDERLINE;
+
+ cfFM.dwEffects = bold | italic | underline;
+
+ if (!g_plugin.getWString(FONT_FACE_KEY, &dbv)) {
+ mir_wstrcpy(cfFM.szFaceName, dbv.pwszVal);
+ db_free(&dbv);
+ }
+ else mir_wstrcpy(cfFM.szFaceName, Def_font_face);
+
+ HDC hDC = GetDC(hWindow);
+ cfFM.yHeight = (BYTE)MulDiv(abs(g_lf.lfHeight), 120, GetDeviceCaps(GetDC(hWindow), LOGPIXELSY)) * (g_plugin.getByte(FONT_SIZE_KEY, 14));
+ ReleaseDC(hWindow, hDC);
+
+ cfFM.bCharSet = g_plugin.getByte(FONT_SCRIPT_KEY, 0);
+ cfFM.bPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
+ cfFM.crTextColor = rgbText;
+ cfFM.crBackColor = rgbBack;
+ SendDlgItemMessage(hWindow, IDC_DATA, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)& cfFM);
+
+ SendDlgItemMessage(hWindow, IDC_DATA, EM_SETSEL, 0, -1);
+ SendDlgItemMessageA(hWindow, IDC_DATA, EM_REPLACESEL, FALSE, (LPARAM)truncated);
+ SendDlgItemMessage(hWindow, IDC_DATA, EM_SETCHARFORMAT, SCF_ALL, (LPARAM)&cfFM);
+ return 1;
+}
+
+/*****************************************************************************/
+void CALLBACK timerfunc(HWND, UINT, UINT_PTR, DWORD)
+{
+ g_plugin.setByte(HAS_CRASHED_KEY, 0);
+
+ if (!(g_plugin.getByte(OFFLINE_STATUS, 1)))
+ if (!(g_plugin.getByte(DISABLE_AUTOUPDATE_KEY, 0)))
+ mir_forkthread(ContactLoop);
+
+ g_plugin.setDword(COUNTDOWN_KEY, 0);
+}
+
+/*****************************************************************************/
+void CALLBACK Countdownfunc(HWND, UINT, UINT_PTR, DWORD)
+{
+ DWORD timetemp = g_plugin.getDword(COUNTDOWN_KEY, 100);
+ if (timetemp <= 0) {
+ timetemp = g_plugin.getDword(REFRESH_KEY, TIME);
+ g_plugin.setDword(COUNTDOWN_KEY, timetemp);
+ }
+
+ g_plugin.setDword(COUNTDOWN_KEY, timetemp - 1);
+
+ 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
+ if ((ServiceExists(MS_POPUP_ADDPOPUPW))) {
+ 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;
+ g_lf.lfWidth = 0;
+ g_lf.lfEscapement = 0;
+ g_lf.lfOrientation = 0;
+ g_lf.lfWeight = FW_NORMAL;
+ g_lf.lfItalic = FALSE;
+ g_lf.lfUnderline = FALSE;
+ g_lf.lfStrikeOut = 0;
+ g_lf.lfCharSet = ANSI_CHARSET;
+ g_lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
+ g_lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
+ g_lf.lfQuality = DEFAULT_QUALITY;
+ g_lf.lfPitchAndFamily = FIXED_PITCH | FF_MODERN;
+ mir_wstrcpy(g_lf.lfFaceName, Def_font_face);
+}
+
+/*****************************************************************************/
+int ModulesLoaded(WPARAM, LPARAM)
+{
+ hHookDisplayDataAlert = CreateHookableEvent(ME_DISPLAYDATA_ALERT);
+ HookEvent(ME_DISPLAYDATA_ALERT, DataWndAlertCommand);
+
+ hHookAlertPopup = CreateHookableEvent(ME_POPUP_ALERT);
+ HookEvent(ME_POPUP_ALERT, PopupAlert);
+
+ hHookErrorPopup = CreateHookableEvent(ME_POPUP_ERROR);
+ HookEvent(ME_POPUP_ERROR, ErrorMsgs);
+
+ hHookAlertOSD = CreateHookableEvent(ME_OSD_ALERT);
+ HookEvent(ME_OSD_ALERT, OSDAlert);
+
+ FontSettings();
+ h_font = CreateFontIndirect(&g_lf);
+
+ // get data on startup
+ if (g_plugin.getByte(UPDATE_ONSTART_KEY, 0))
+ mir_forkthread(StartUpdate);
+
+ return 0;
+}
+
+/*****************************************************************************/
+INT_PTR DataWndMenuCommand(WPARAM wParam, LPARAM)
+{
+ MCONTACT hContact = wParam;
+ HWND hwndDlg = WindowList_Find(hWindowList, hContact);
+ if (hwndDlg != nullptr) {
+ DestroyWindow(hwndDlg);
+ return 0;
+ }
+
+ HWND hTopmost = g_plugin.getByte(hContact, ON_TOP_KEY, 0) ? HWND_TOPMOST : HWND_NOTOPMOST;
+ hwndDlg = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_DISPLAY_DATA), nullptr, DlgProcDisplayData, (LPARAM)hContact);
+ SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDI_STICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0));
+ if (g_plugin.getByte(SAVE_INDIVID_POS_KEY, 0))
+ SetWindowPos(hwndDlg, hTopmost,
+ g_plugin.getDword(hContact, "WVx", 100), // Xposition,
+ g_plugin.getDword(hContact, "WVy", 100), // Yposition,
+ g_plugin.getDword(hContact, "WVwidth", 100), // WindowWidth,
+ g_plugin.getDword(hContact, "WVheight", 100), 0); // WindowHeight,
+ else
+ SetWindowPos(hwndDlg, HWND_TOPMOST, Xposition, Yposition, WindowWidth, WindowHeight, 0);
+
+ ShowWindow(hwndDlg, SW_SHOW);
+ SetActiveWindow(hwndDlg);
+
+ if (g_plugin.getByte(UPDATE_ON_OPEN_KEY, 0)) {
+ if (g_plugin.getByte(hContact, ENABLE_ALERTS_KEY, 0))
+ mir_forkthread(ReadFromFile, (void*)hContact);
+ else
+ mir_forkthread(GetData, (void*)hContact);
+ g_plugin.setWord(hContact, "Status", ID_STATUS_ONLINE);
+ }
+
+ 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))
+ g_plugin.setByte(DISABLE_AUTOUPDATE_KEY, 0);
+ else
+ g_plugin.setByte(DISABLE_AUTOUPDATE_KEY, 1);
+
+ ChangeMenuItem1();
+ return 0;
+}
+
+/*****************************************************************************/
+INT_PTR AddContactMenuCommand(WPARAM, LPARAM)
+{
+ db_set_s(0, "FindAdd", "LastSearched", MODULENAME);
+ CallService(MS_FINDADD_FINDADD, 0, 0);
+ return 0;
+}
+
+/*****************************************************************************/
+int OnTopMenuCommand(WPARAM, LPARAM, MCONTACT singlecontact)
+{
+ int ontop = 0;
+ int done = 0;
+
+ if (((g_plugin.getByte(singlecontact, ON_TOP_KEY))) && done == 0) {
+ g_plugin.setByte(singlecontact, ON_TOP_KEY, 0);
+ ontop = 0;
+ done = 1;
+ }
+ if ((!(g_plugin.getByte(singlecontact, ON_TOP_KEY, 0))) && done == 0) {
+ g_plugin.setByte(singlecontact, ON_TOP_KEY, 1);
+ ontop = 1;
+ done = 1;
+ }
+ return 0;
+}
+
+/*****************************************************************************/
+INT_PTR WebsiteMenuCommand(WPARAM wParam, LPARAM)
+{
+ MCONTACT hContact = wParam;
+ ptrW url(g_plugin.getWStringA(hContact, "URL"));
+ if (url)
+ Utils_OpenUrlW(url);
+
+ g_plugin.setWord(hContact, "Status", ID_STATUS_ONLINE);
+ 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
new file mode 100644
index 0000000000..e7bdd6c57b
--- /dev/null
+++ b/protocols/WebView/src/webview.h
@@ -0,0 +1,254 @@
+/*
+ * 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.
+ */
+
+#pragma once
+
+#define CFM_BACKCOLOR 0x04000000
+
+#define MODULENAME "WebView"
+
+#define MENU_OFF "DisableMenu"
+#define REFRESH_KEY "Refresh interval"
+#define ON_TOP_KEY "Always on top"
+#define OFFLINE_STATUS "OfflineOnBoot"
+#define URL_KEY "URL"
+#define START_STRING_KEY "Start_string"
+#define END_STRING_KEY "End_String"
+#define DBLE_WIN_KEY "Doub_click_win"
+#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"
+#define PRESERVE_NAME_KEY "PreserveName"
+#define CLEAR_DISPLAY_KEY "Remove_tags_whitespace"
+#define ALRT_S_STRING_KEY "ALRT_S_STRING"
+#define ALRT_E_STRING_KEY "ALRT_E_STRING"
+#define ALRT_INDEX_KEY "AlertIndex"
+#define EVNT_INDEX_KEY "EventIndex"
+#define START_DELAY_KEY "StartUpDelay"
+#define ALWAYS_LOG_KEY "AlwaysLogToFile"
+#define SAVE_INDIVID_POS_KEY "SaveIndividWinPos"
+#define NO_PROTECT_KEY "NoDownloadProtection"
+#define SAVE_AS_RAW_KEY "SaveAsRaw"
+#define FONT_SCRIPT_KEY "FontScript"
+#define STOP_KEY "StopProcessing"
+#define DATA_POPUP_KEY "DisplayDataPopup"
+#define COUNTDOWN_KEY "Countdown"
+
+#define MINUTE 60000
+#define SECOND 1000
+
+#define MS_UPDATE_ALL "Webview/UpdateAll"
+#define MS_ADD_SITE "Webview/AddSite"
+#define MS_AUTO_UPDATE "Webview/AutoUpdate"
+
+#define CACHE_FILE_KEY "Filename"
+
+#define Xpos_WIN_KEY "win_Xpos"
+#define Ypos_WIN_KEY "win_Ypos"
+#define BG_COLOR_KEY "BgColor"
+#define TXT_COLOR_KEY "TxtColor"
+#define WIN_HEIGHT_KEY "Height"
+#define SUPPRESS_ERR_KEY "Suppress error messages"
+#define WIN_WIDTH_KEY "Width"
+#define FILE_KEY "Filename"
+#define APPEND_KEY "Append"
+#define UPDATE_ONSTART_KEY "update_onboot"
+#define UPDATE_ON_OPEN_KEY "update_on_Window_open"
+#define FONT_FACE_KEY "FontFace"
+#define FONT_BOLD_KEY "FontBold"
+#define FONT_ITALIC_KEY "FontItalic"
+#define FONT_UNDERLINE_KEY "FontUnderline"
+#define FONT_SIZE_KEY "FontSize"
+#define ERROR_POPUP_KEY "UsePopupPlugin"
+#define ENABLE_ALERTS_KEY "EnableAlerts"
+#define ALERT_STRING_KEY "ALERTSTRING"
+#define ALERT_TYPE_KEY "Alert_Type"
+#define APND_DATE_NAME_KEY "AppendDateContact"
+#define POP_DELAY_KEY "PopUpDelay"
+#define POP_BG_CLR_KEY "PopBGClr"
+#define POP_TXT_CLR_KEY "PopTxtClr"
+#define POP_USEWINCLRS_KEY "PopUseWinClrs"
+#define CONTACT_PREFIX_KEY "PrefixDateContact"
+#define USE_24_HOUR_KEY "Use24hourformat"
+#define POP_USESAMECLRS_KEY "PopUseSameClrs"
+#define POP_USECUSTCLRS_KEY "PopUseCustomClrs"
+#define LCLK_WINDOW_KEY "LeftClkWindow"
+#define LCLK_WEB_PGE_KEY "LeftClkWebPage"
+#define LCLK_DISMISS_KEY "LeftClkDismiss"
+#define RCLK_WINDOW_KEY "RightClkWindow"
+#define RCLK_WEB_PGE_KEY "RightClkWebPage"
+#define RCLK_DISMISS_KEY "RightClkDismiss"
+
+#define TIME 60
+#define Def_color_bg 0x00ffffff
+#define Def_color_txt 0x00000000
+#define Def_font_face L"Courier"
+#define Def_font_size 14
+#define HK_SHOWHIDE 3001
+
+#define MAXSIZE1 250000
+#define MAXSIZE2 500000
+#define MAXSIZE3 1000000
+
+#define Def_win_height 152
+#define Def_win_width 250
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// lets get rid of some warnings
+
+void CodetoSymbol(char *truncated);
+void GetData(void *param);
+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);
+int ErrorMsgs(WPARAM wParam, LPARAM lParam);
+int OSDAlert(WPARAM wParam, LPARAM lParam);
+
+void ReadFromFile(void *hContact);
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// some globals for window settings
+
+extern int Xposition, Yposition, WindowHeight, WindowWidth;
+extern COLORREF BackgoundClr, TextClr;
+extern UINT_PTR timerId, Countdown;
+extern LOGFONT g_lf;
+extern HFONT h_font;
+extern HMENU hMenu;
+extern int bpStatus;
+extern HNETLIBUSER hNetlibUser;
+extern MWindowList hWindowList;
+extern HGENMENU hMenuItem1, hMenuItemCountdown;
+extern char optionsname[80];
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// lets get rid of some warnings
+
+void CALLBACK timerfunc(HWND, UINT, UINT_PTR, DWORD);
+void CALLBACK Countdownfunc(HWND, UINT, UINT_PTR, DWORD);
+void SavewinSettings(void);
+void ValidatePosition(HWND hwndDlg);
+int ModulesLoaded(WPARAM wParam, LPARAM lParam);
+wchar_t* FixButtonText(wchar_t *url, size_t len);
+int ContactMenuItemUpdateData (WPARAM wParam, LPARAM lParam);
+
+int Doubleclick(WPARAM wParam, LPARAM lParam);
+int DBSettingChanged(WPARAM wParam, LPARAM lParam);
+
+int SendToRichEdit(HWND hWindow, char *truncated, COLORREF rgbText, COLORREF rgbBack);
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// Services
+
+INT_PTR GetCaps(WPARAM wParam, LPARAM lParam);
+INT_PTR GetName(WPARAM wParam, LPARAM lParam);
+INT_PTR BPLoadIcon(WPARAM wParam, LPARAM lParam); // BPLoadIcon
+
+INT_PTR SetStatus(WPARAM wParam, LPARAM lParam);
+INT_PTR GetStatus(WPARAM wParam, LPARAM lParam);
+
+INT_PTR BasicSearch(WPARAM wParam, LPARAM lParam);
+INT_PTR AddToList(WPARAM wParam, LPARAM lParam);
+INT_PTR GetInfo(WPARAM wParam, LPARAM lParam);
+
+INT_PTR OpenCacheDir(WPARAM wParam, LPARAM lParam);
+
+INT_PTR UpdateAllMenuCommand(WPARAM wParam, LPARAM lParam);
+INT_PTR CountdownMenuCommand(WPARAM wParam, LPARAM lParam);
+INT_PTR MarkAllReadMenuCommand(WPARAM wParam, LPARAM lParam);
+INT_PTR WebsiteMenuCommand(WPARAM wParam, LPARAM lParam);
+INT_PTR AddContactMenuCommand(WPARAM wParam, LPARAM lParam);
+INT_PTR CntOptionsMenuCommand(WPARAM wParam, LPARAM lParam);
+INT_PTR CntAlertMenuCommand(WPARAM wParam, LPARAM lParam);
+INT_PTR DataWndMenuCommand(WPARAM wParam, LPARAM lParam);
+INT_PTR PingWebsiteMenuCommand(WPARAM wParam, LPARAM lParam);
+INT_PTR StpPrcssMenuCommand(WPARAM wParam, LPARAM lParam);
+
+int UpdateMenuCommand(WPARAM wParam, LPARAM lParam, MCONTACT singlecontact);
+int OnTopMenuCommand(WPARAM wParam, LPARAM lParam, MCONTACT singlecontact);
+
+/////////////////////////////////////////////////////////////////////////////////////////
+void ChangeContactStatus(int con_stat);
+void InitialiseGlobals(void);
+void FontSettings(void);
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+void Removewhitespace(char *truncated);
+void RemoveInvis(char *truncated, int AmountWspcRem);
+void RemoveTabs(char *truncated);
+void FastTagFilter(char *truncated);
+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);
+
+void Filter(char *truncated);
+void TxtclrLoop();
+void BGclrLoop();
+void ContactLoop(void *dummy);
+void NumSymbols(char *truncated);
+
+INT_PTR AutoUpdateMCmd(WPARAM wParam, LPARAM lParam);
+INT_PTR CALLBACK DlgProcContactOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
+int SiteDeleted(WPARAM wParam, LPARAM lParam);
+
+int WErrorPopup(MCONTACT hContact, wchar_t *textdisplay);
+int WAlertPopup(MCONTACT hContact, wchar_t *displaytext);
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// wrappers
+
+extern HANDLE hHookDisplayDataAlert;
+#define ME_DISPLAYDATA_ALERT "Miranda/ALERT/DISPLAYDATA"
+
+extern HANDLE hHookAlertPopup;
+#define ME_POPUP_ALERT "Miranda/ALERT/POPUP"
+
+extern HANDLE hHookErrorPopup;
+#define ME_POPUP_ERROR "Miranda/ERROR/POPUP"
+
+extern HANDLE hHookAlertOSD;
+#define ME_OSD_ALERT "Miranda/ALERT/OSD"
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+struct CMPlugin : public PLUGIN<CMPlugin>
+{
+ CMPlugin();
+
+ int Load() override;
+ int Unload() override;
+};
diff --git a/protocols/WebView/src/webview_alerts.cpp b/protocols/WebView/src/webview_alerts.cpp
new file mode 100644
index 0000000000..1b068f099e
--- /dev/null
+++ b/protocols/WebView/src/webview_alerts.cpp
@@ -0,0 +1,839 @@
+/*
+* 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"
+
+/*****************************************************************************/
+int CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+{
+ switch (message) {
+ case WM_COMMAND:
+ case WM_CONTEXTMENU:
+ MCONTACT hContact = PUGetContact(hWnd);
+ ptrW url(g_plugin.getWStringA(hContact, URL_KEY));
+
+ if (message == WM_COMMAND) { // left click
+ if (hContact != NULL) {
+ // open data window
+ if (g_plugin.getByte(LCLK_WINDOW_KEY, 0)) {
+ NotifyEventHooks(hHookDisplayDataAlert, (int)hContact, 0);
+ mir_forkthread(GetData, (void*)hContact);
+ PUDeletePopup(hWnd);
+ }
+ // open url
+ if (g_plugin.getByte(LCLK_WEB_PGE_KEY, 0)) {
+ Utils_OpenUrlW(url);
+ PUDeletePopup(hWnd);
+ g_plugin.setWord(wParam, "Status", ID_STATUS_ONLINE);
+ }
+ // dismiss
+ if (g_plugin.getByte(LCLK_DISMISS_KEY, 1))
+ PUDeletePopup(hWnd);
+ }
+ else if (hContact == NULL)
+ PUDeletePopup(hWnd);
+ }
+ else if (message == WM_CONTEXTMENU) { // right click
+ if (hContact != NULL) {
+ // open datA window
+ if (g_plugin.getByte(RCLK_WINDOW_KEY, 0)) {
+ NotifyEventHooks(hHookDisplayDataAlert, (int)hContact, 0);
+ mir_forkthread(GetData, (void*)hContact);
+ PUDeletePopup(hWnd);
+ }
+ // open url
+ if (g_plugin.getByte(RCLK_WEB_PGE_KEY, 1)) {
+ Utils_OpenUrlW(url);
+ PUDeletePopup(hWnd);
+ g_plugin.setWord(wParam, "Status", ID_STATUS_ONLINE);
+ }
+ // dismiss
+ if (g_plugin.getByte(RCLK_DISMISS_KEY, 0))
+ PUDeletePopup(hWnd);
+ }
+ else if (hContact == NULL)
+ PUDeletePopup(hWnd);
+ }
+ break;
+ }
+
+ 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 = { 0 };
+
+ if (hContact != 0)
+ mir_wstrncpy(ppd.lpwzContactName, ptrW(g_plugin.getWStringA(hContact, PRESERVE_NAME_KEY)), _countof(ppd.lpwzContactName));
+ else
+ mir_wstrcpy(ppd.lpwzContactName, _A2W(MODULENAME));
+
+ ppd.lchContact = hContact;
+ ppd.lchIcon = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_SITE));
+
+ wchar_t *displaytext = (wchar_t*)lParam;
+ if ((mir_wstrlen(displaytext) == MAX_SECONDLINE) || (mir_wstrlen(displaytext) > MAX_SECONDLINE))
+ mir_snwprintf(ppd.lpwzText, displaytext);
+ else if (mir_wstrlen(displaytext) < MAX_SECONDLINE)
+ mir_snwprintf(ppd.lpwzText, displaytext);
+
+ if (g_plugin.getByte(POP_USECUSTCLRS_KEY, 0)) {
+ ppd.colorBack = g_plugin.getDword(POP_BG_CLR_KEY, Def_color_bg);
+ ppd.colorText = g_plugin.getDword(POP_TXT_CLR_KEY, Def_color_txt);
+ }
+ else if (g_plugin.getByte(POP_USEWINCLRS_KEY, 0)) {
+ ppd.colorBack = GetSysColor(COLOR_BTNFACE);
+ ppd.colorText = GetSysColor(COLOR_WINDOWTEXT);
+ }
+ else if (g_plugin.getByte(POP_USESAMECLRS_KEY, 1)) {
+ ppd.colorBack = BackgoundClr;
+ ppd.colorText = TextClr;
+ }
+
+ ppd.PluginWindowProc = nullptr;
+ ppd.iSeconds = g_plugin.getDword(POP_DELAY_KEY, 0);
+
+ if (ServiceExists(MS_POPUP_ADDPOPUPW))
+ CallService(MS_POPUP_ADDPOPUPW, (WPARAM)&ppd, 0);
+
+ return 0;
+}
+
+/*****************************************************************************/
+int OSDAlert(WPARAM hContact, LPARAM lParam)
+{
+ char contactname[255], newdisplaytext[2000];
+ contactname[0] = 0;
+
+ if (hContact != NULL) {
+ DBVARIANT dbv;
+ if (!g_plugin.getString(hContact, PRESERVE_NAME_KEY, &dbv)) {
+ strncpy_s(contactname, _countof(contactname), dbv.pszVal, _TRUNCATE);
+ db_free(&dbv);
+ }
+ }
+ if (contactname[0] == 0)
+ strncpy_s(contactname, _countof(contactname), MODULENAME, _TRUNCATE);
+
+ char *displaytext = (char*)lParam;
+ mir_snprintf(newdisplaytext, "%s: %s", contactname, Translate(displaytext));
+
+ if (ServiceExists("OSD/Announce"))
+ CallService("OSD/Announce", (WPARAM)newdisplaytext, 0);
+
+ return 0;
+}
+
+/*****************************************************************************/
+int ErrorMsgs(WPARAM wParam, LPARAM lParam)
+{
+ MCONTACT hContact = wParam;
+ wchar_t newdisplaytext[2000], *displaytext = (wchar_t*)lParam;
+
+ if (g_plugin.getByte(SUPPRESS_ERR_KEY, 0))
+ return 0;
+
+ wchar_t *ptszContactName = Clist_GetContactDisplayName(hContact);
+ if (ServiceExists(MS_POPUP_ADDPOPUPW) && g_plugin.getByte(ERROR_POPUP_KEY, 0)) {
+ mir_snwprintf(newdisplaytext, L"%s\n%s", ptszContactName, displaytext);
+ PUShowMessageW(newdisplaytext, SM_WARNING);
+ }
+ else if (ServiceExists("OSD/Announce") && g_plugin.getByte(ERROR_POPUP_KEY, 0)) {
+ mir_snwprintf(newdisplaytext, L"%s: %s", ptszContactName, TranslateW(displaytext));
+ CallService("OSD/Announce", (WPARAM)newdisplaytext, 0);
+ }
+
+ Clist_TrayNotifyW(nullptr, ptszContactName, TranslateW(displaytext), NIIF_ERROR, 15000);
+ return 0;
+}
+
+/*****************************************************************************/
+void SaveToFile(MCONTACT hContact, char *truncated)
+{
+ char *mode;
+ if (!g_plugin.getByte(hContact, APPEND_KEY, 0))
+ mode = "w";
+ else
+ mode = "a";
+
+ char url[300]; url[0] = '\0';
+ DBVARIANT dbv;
+ if (!g_plugin.getString(hContact, URL_KEY, &dbv)) {
+ strncpy_s(url, _countof(url), dbv.pszVal, _TRUNCATE);
+ db_free(&dbv);
+ }
+
+ if (g_plugin.getString(hContact, FILE_KEY, &dbv))
+ return;
+
+ FILE *pfile = fopen(dbv.pszVal, mode);
+ if (pfile == nullptr)
+ WErrorPopup(hContact, TranslateT("Cannot write to file"));
+ else {
+ char timestring[128], timeprefix[32];
+ char temptime1[32], temptime2[32];
+
+ time_t ftime = time(0);
+ struct tm *nTime = localtime(&ftime);
+
+ mir_snprintf(timeprefix, " %s ", Translate("Last updated on"));
+ strftime(temptime1, 32, " %a, %b %d, %Y ", nTime);
+ strftime(temptime2, 32, " %I:%M %p.", nTime);
+ mir_snprintf(timestring, "(%s)%s\n%s,%s\n", MODULENAME, url, temptime1, temptime2);
+
+ fputs(timestring, pfile);
+ fwrite(truncated, mir_strlen(truncated), 1, pfile);
+ fputs("\n\n", pfile);
+ fclose(pfile);
+ }
+
+ db_free(&dbv);
+}
+
+/*****************************************************************************/
+int ProcessAlerts(MCONTACT hContact, char *truncated, char *tstr, char *contactname, int notpresent)
+{
+ char alertstring[255];
+ wchar_t displaystring[300];
+ FILE *pcachefile;
+ DBVARIANT tdbv;
+ int wasAlert = 0;
+
+ int statalertpos = 0, disalertpos = 0, statalertposend = 0;
+ char*alertpos;
+ char Alerttempstring[300], Alerttempstring2[300];
+ static char cachecompare[MAXSIZE1];
+ static char raw[MAXSIZE1];
+
+ int alertIndex = 0, eventIndex = 0;
+
+ char tempraw[MAXSIZE1];
+ memset(&tempraw, 0, sizeof(tempraw));
+ memset(&raw, 0, sizeof(raw));
+
+ strncpy(tempraw, truncated, _countof(tempraw));
+
+ memset(&alertstring, 0, sizeof(alertstring));
+ memset(&Alerttempstring, 0, sizeof(Alerttempstring));
+ memset(&Alerttempstring2, 0, sizeof(Alerttempstring2));
+ memset(&cachecompare, 0, sizeof(cachecompare));
+
+ // alerts
+ if (g_plugin.getByte(hContact, ENABLE_ALERTS_KEY, 0)) { // ALERTS
+ alertIndex = g_plugin.getByte(hContact, ALRT_INDEX_KEY, 0);
+ eventIndex = g_plugin.getByte(hContact, EVNT_INDEX_KEY, 0);
+ if (notpresent) {
+ if (alertIndex == 0) { // Popup
+ Sleep(1000);
+ WAlertPopup(hContact, TranslateT("Start/end strings not found or strings not set."));
+ // contactlist name//
+ if (g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
+ db_set_s(hContact, "CList", "MyHandle", tstr);
+ }
+ else if (alertIndex == 1) { // log to file
+ if (!g_plugin.getString(hContact, FILE_KEY, &tdbv)) {
+ int AmountWspcRem = 0;
+
+ if (!g_plugin.getByte(hContact, SAVE_AS_RAW_KEY, 0)) {
+ CodetoSymbol(tempraw);
+ Sleep(100); // avoid 100% CPU
+
+ EraseBlock(tempraw);
+ Sleep(100); // avoid 100% CPU
+
+ FastTagFilter(tempraw);
+ Sleep(100); // avoid 100% CPU
+
+ NumSymbols(tempraw);
+ Sleep(100); // avoid 100% CPU
+
+ EraseSymbols(tempraw);
+ Sleep(100); // avoid 100% CPU
+
+ AmountWspcRem = g_plugin.getByte(hContact, RWSPACE_KEY, 0);
+ RemoveInvis(tempraw, AmountWspcRem);
+ Sleep(100); // avoid 100% CPU
+
+ Removewhitespace(tempraw);
+ }
+
+ SaveToFile(hContact, tempraw);
+ db_free(&tdbv);
+
+ if (g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
+ db_set_s(hContact, "CList", "MyHandle", tstr);
+ }
+ }
+ else if (alertIndex == 3) {
+ WAlertOSD(hContact, TranslateT("Alert start/end strings not found or strings not set."));
+ if (g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
+ db_set_s(hContact, "CList", "MyHandle", tstr);
+ }
+ else if (eventIndex == 2) {
+ WDisplayDataAlert(hContact);
+
+ if (g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
+ db_set_s(hContact, "CList", "MyHandle", tstr);
+
+ HWND hwndDlg = (WindowList_Find(hWindowList, hContact));
+
+ SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Start/end strings not found or strings not set."));
+ }
+ else MessageBox(nullptr, TranslateT("Start/end strings not found or strings not set."), _A2W(MODULENAME), MB_OK);
+ }
+
+ if (eventIndex == 0) { // string present
+ if (!g_plugin.getString(hContact, ALERT_STRING_KEY, &tdbv)) {
+ strncpy_s(alertstring, _countof(alertstring), tdbv.pszVal, _TRUNCATE);
+ db_free(&tdbv);
+
+ if ((strstr(tempraw, alertstring)) != nullptr) { // // ENDALERT EVENT:CHECK FOR STRING
+ // there was an alert
+ wasAlert = 1;
+
+ // play sound?
+ Skin_PlaySound("webviewalert");
+ //
+ if ((!notpresent)) {
+ if (alertIndex == 0) { // popup
+ mir_snwprintf(displaystring, L"%s \"%S\" %s.", Translate("The string"), alertstring, Translate("has been found on the web page"));
+ WAlertPopup(hContact, displaystring);
+
+ // contactlist name//
+ if (g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
+ db_set_s(hContact, "CList", "MyHandle", tstr);
+ } //
+ else if (alertIndex == 1) {
+ if (!g_plugin.getString(hContact, FILE_KEY, &tdbv)) {
+ int AmountWspcRem = 0;
+ if (!g_plugin.getByte(hContact, SAVE_AS_RAW_KEY, 0)) {
+ CodetoSymbol(tempraw);
+ Sleep(100); // avoid 100% CPU
+
+ EraseBlock(tempraw);
+ Sleep(100); // avoid 100% CPU
+
+ FastTagFilter(tempraw);
+ Sleep(100); // avoid 100% CPU
+
+ NumSymbols(tempraw);
+ Sleep(100); // avoid 100% CPU
+
+ EraseSymbols(tempraw);
+ Sleep(100); // avoid 100% CPU
+
+ AmountWspcRem = g_plugin.getByte(hContact, RWSPACE_KEY, 0);
+ RemoveInvis(tempraw, AmountWspcRem);
+ Sleep(100); // avoid 100% CPU
+
+ Removewhitespace(tempraw);
+ }
+ SaveToFile(hContact, tempraw);
+ db_free(&tdbv);
+
+ if (g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
+ db_set_s(hContact, "CList", "MyHandle", tstr);
+ }
+ }
+ else if (alertIndex == 3) {
+ mir_snwprintf(displaystring, L"%s \"%s\" %s.", TranslateT("The string"), alertstring, TranslateT("has been found on the web page"));
+ WAlertOSD(hContact, displaystring);
+
+ // contactlist name//
+ if (g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
+ db_set_s(hContact, "CList", "MyHandle", tstr);
+ }
+ else if (alertIndex == 2) {
+ WDisplayDataAlert(hContact);
+ // contactlist name//
+ if (g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
+ db_set_s(hContact, "CList", "MyHandle", tstr);
+
+ HWND hwndDlg = WindowList_Find(hWindowList, hContact);
+ SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Download successful; about to process data..."));
+ }
+ else MessageBox(nullptr, TranslateT("Unknown alert type."), _A2W(MODULENAME), MB_OK);
+ }
+ }
+ }
+ }
+ else if (eventIndex == 1) { // webpage changed
+ // TEST GET NAME FOR CACHE
+ wchar_t cachepath[MAX_PATH], cachedirectorypath[MAX_PATH], newcachepath[MAX_PATH + 50];
+ GetModuleFileName(g_plugin.getInst(), cachepath, _countof(cachepath));
+ wchar_t *cacheend = wcsrchr(cachepath, '\\');
+ cacheend++;
+ *cacheend = '\0';
+
+ mir_snwprintf(cachedirectorypath, L"%s%S%S", cachepath, MODULENAME, "cache\\");
+ CreateDirectory(cachedirectorypath, nullptr);
+ mir_snwprintf(newcachepath, L"%s%S%S%S%S", cachepath, MODULENAME, "cache\\", contactname, ".txt");
+ // file exists?
+ if (_waccess(newcachepath, 0) != -1) {
+ if ((pcachefile = _wfopen(newcachepath, L"r")) == nullptr)
+ WErrorPopup((UINT_PTR)contactname, TranslateT("Cannot read from file"));
+ else {
+ memset(&cachecompare, 0, sizeof(cachecompare));
+ fread(cachecompare, sizeof(cachecompare), 1, pcachefile);
+ fclose(pcachefile);
+ }
+ }
+ // write to cache
+ if ((pcachefile = _wfopen(newcachepath, L"w")) == nullptr)
+ WErrorPopup((UINT_PTR)contactname, TranslateT("Cannot write to file 1"));
+ else {
+ fwrite(tempraw, mir_strlen(tempraw), 1, pcachefile); //smaller cache
+ fclose(pcachefile);
+ g_plugin.setWString(hContact, CACHE_FILE_KEY, newcachepath);
+ }
+ // end write to cache
+
+ if (strncmp(tempraw, cachecompare, mir_strlen(tempraw)) != 0) { //lets try this instead
+ // play sound?
+ Skin_PlaySound("webviewalert");
+ // there was an alert
+ wasAlert = 1;
+
+ if (!notpresent) {
+ if (alertIndex == 0) { // popup
+ WAlertPopup(hContact, TranslateT("The web page has changed."));
+ // contactlist name//
+ if (g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
+ db_set_s(hContact, "CList", "MyHandle", tstr);
+ }
+ else if (alertIndex == 3) { // osd
+ WAlertOSD(hContact, TranslateT("The web page has changed."));
+ // contactlist name//
+ if (g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
+ db_set_s(hContact, "CList", "MyHandle", tstr);
+ }
+ else if (alertIndex == 1) { // log
+ if (!g_plugin.getString(hContact, FILE_KEY, &tdbv)) {
+ int AmountWspcRem = 0;
+
+ if (!g_plugin.getByte(hContact, SAVE_AS_RAW_KEY, 0)) {
+ CodetoSymbol(tempraw);
+ Sleep(100); // avoid 100% CPU
+
+ EraseBlock(tempraw);
+ Sleep(100); // avoid 100% CPU
+
+ FastTagFilter(tempraw);
+ Sleep(100); // avoid 100% CPU
+
+ NumSymbols(tempraw);
+ Sleep(100); // avoid 100% CPU
+
+ EraseSymbols(tempraw);
+ Sleep(100); // avoid 100% CPU
+
+ AmountWspcRem = g_plugin.getByte(hContact, RWSPACE_KEY, 0);
+ RemoveInvis(tempraw, AmountWspcRem);
+ Sleep(100); // avoid 100% CPU
+
+ Removewhitespace(tempraw);
+ }
+
+ SaveToFile(hContact, tempraw);
+ db_free(&tdbv);
+ // contactlist name//
+ if (g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
+ db_set_s(hContact, "CList", "MyHandle", tstr);
+ }
+ }
+ else if (alertIndex == 2) { // window
+ WDisplayDataAlert(hContact);
+ // contactlist name//
+ if (g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
+ db_set_s(hContact, "CList", "MyHandle", tstr);
+ }
+ else MessageBox(nullptr, TranslateT("Unknown alert type."), _A2W(MODULENAME), MB_OK);
+ }
+ }
+ }
+
+ if (eventIndex == 2) { // part of webpage changed
+ Alerttempstring[0] = Alerttempstring2[0] = 0;
+ if (!g_plugin.getString(hContact, ALRT_S_STRING_KEY, &tdbv)) {
+ strncpy_s(Alerttempstring, _countof(Alerttempstring), tdbv.pszVal, _TRUNCATE);
+ db_free(&tdbv);
+ }
+ if (!g_plugin.getString(hContact, ALRT_E_STRING_KEY, &tdbv)) {
+ strncpy_s(Alerttempstring2, _countof(Alerttempstring2), tdbv.pszVal, _TRUNCATE);
+ db_free(&tdbv);
+ }
+
+ // putting data into string
+ if (((strstr(tempraw, Alerttempstring)) != nullptr) && ((strstr(tempraw, Alerttempstring2)) != nullptr)) {
+ //start string
+ alertpos = strstr(tempraw, Alerttempstring);
+ statalertpos = alertpos - tempraw;
+
+ memset(&alertpos, 0, sizeof(alertpos));
+ //end string
+ alertpos = strstr(tempraw, Alerttempstring2);
+ statalertposend = alertpos - tempraw + (int)mir_strlen(Alerttempstring2);
+
+ if (statalertpos > statalertposend) {
+ memset(&tempraw, ' ', statalertpos);
+ memset(&alertpos, 0, sizeof(alertpos));
+ alertpos = strstr(tempraw, Alerttempstring2);
+ statalertposend = alertpos - tempraw + (int)mir_strlen(Alerttempstring2);
+ }
+
+ if (statalertpos < statalertposend) {
+ memset(&raw, 0, sizeof(raw));
+
+ //start string
+ alertpos = strstr(tempraw, Alerttempstring);
+ statalertpos = alertpos - tempraw;
+
+ //end string
+ alertpos = strstr(tempraw, Alerttempstring2);
+ statalertposend = alertpos - tempraw + (int)mir_strlen(Alerttempstring2);
+
+ if (statalertpos > statalertposend) {
+ memset(&tempraw, ' ', statalertpos);
+ memset(&alertpos, 0, sizeof(alertpos));
+ alertpos = strstr(tempraw, Alerttempstring2);
+ statalertposend = alertpos - tempraw + (int)mir_strlen(Alerttempstring2);
+ }
+ disalertpos = 0;
+
+ //write selected data to string
+ strncpy(raw, &tempraw[statalertpos], (statalertposend - statalertpos));
+ raw[(statalertposend - statalertpos)] = '\0';
+ }
+ } // end putting data into string
+ else { // start and/or end string not present
+ if (alertIndex == 0) { // popup
+ Sleep(1000);
+ WAlertPopup(hContact, TranslateT("Alert start/end strings not found or strings not set."));
+ // contactlist name//
+ if (g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
+ db_set_s(hContact, "CList", "MyHandle", tstr);
+ }
+ else if (alertIndex == 1) { // LOG
+ if (!notpresent) { // dont log to file twice if both types of start/end strings not present
+ if (!g_plugin.getString(hContact, FILE_KEY, &tdbv)) {
+ int AmountWspcRem = 0;
+ if (!g_plugin.getByte(hContact, SAVE_AS_RAW_KEY, 0)) {
+ CodetoSymbol(tempraw);
+ Sleep(100); // avoid 100% CPU
+
+ EraseBlock(tempraw);
+ Sleep(100); // avoid 100% CPU
+
+ FastTagFilter(tempraw);
+ Sleep(100); // avoid 100% CPU
+
+ NumSymbols(tempraw);
+ Sleep(100); // avoid 100% CPU
+
+ EraseSymbols(tempraw);
+ Sleep(100); // avoid 100% CPU
+
+ AmountWspcRem = g_plugin.getByte(hContact, RWSPACE_KEY, 0);
+ RemoveInvis(tempraw, AmountWspcRem);
+ Sleep(100); // avoid 100% CPU
+
+ Removewhitespace(tempraw);
+ }
+
+ SaveToFile(hContact, tempraw);
+ db_free(&tdbv);
+ // contactlist name
+ if (g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
+ db_set_s(hContact, "CList", "MyHandle", tstr);
+ }
+ }
+ }
+ else if (alertIndex == 3) { // osd
+ WAlertOSD(hContact, TranslateT("Alert start/end strings not found or strings not set."));
+ // contactlist name//
+ if (g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
+ db_set_s(hContact, "CList", "MyHandle", tstr);
+ }
+ else if (alertIndex == 2) { // window
+ WDisplayDataAlert(hContact);
+ // contactlist name//
+ if (g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
+ db_set_s(hContact, "CList", "MyHandle", tstr);
+
+ HWND hwndDlg = (WindowList_Find(hWindowList, hContact));
+ SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Alert start/end strings not found or strings not set."));
+ }
+ else MessageBox(nullptr, TranslateT("Alert start/end strings not found or strings not set."), _A2W(MODULENAME), MB_OK);
+
+ g_plugin.setWord(hContact, "Status", ID_STATUS_AWAY);
+ }
+
+ ///////////////
+ if (((strstr(tempraw, Alerttempstring)) != nullptr) && ((strstr(tempraw, Alerttempstring2)) != nullptr)) {
+ // TEST GET NAME FOR CACHE
+ wchar_t cachepath[MAX_PATH], cachedirectorypath[MAX_PATH], newcachepath[MAX_PATH + 50];
+ GetModuleFileName(g_plugin.getInst(), cachepath, _countof(cachepath));
+ wchar_t *cacheend = wcsrchr(cachepath, '\\');
+ cacheend++;
+ *cacheend = '\0';
+
+ mir_snwprintf(cachedirectorypath, L"%s%S%S", cachepath, MODULENAME, "cache\\");
+ CreateDirectory(cachedirectorypath, nullptr);
+ mir_snwprintf(newcachepath, L"%s%S%S%S%S", cachepath, MODULENAME, "cache\\", contactname, ".txt");
+ // file exists?
+ if (_waccess(newcachepath, 0) != -1) {
+ if ((pcachefile = _wfopen(newcachepath, L"r")) == nullptr)
+ WErrorPopup((UINT_PTR)contactname, TranslateT("Cannot read from file"));
+ else {
+ memset(&cachecompare, 0, sizeof(cachecompare));
+ fread(cachecompare, sizeof(cachecompare), 1, pcachefile);
+ fclose(pcachefile);
+ }
+ }
+ // write to cache
+ if ((pcachefile = _wfopen(newcachepath, L"w")) == nullptr)
+ WErrorPopup((UINT_PTR)contactname, TranslateT("Cannot write to file 2"));
+ else {
+ fwrite(raw, mir_strlen(raw), 1, pcachefile); //smaller cache
+ g_plugin.setWString(hContact, CACHE_FILE_KEY, newcachepath);
+ fclose(pcachefile);
+ }
+ // end write to cache
+ if (strncmp(raw, cachecompare, (mir_strlen(raw))) != 0) { //lets try this instead
+ // play sound?
+ Skin_PlaySound("webviewalert");
+ // there was an alert
+ wasAlert = 1;
+
+ if (!notpresent) {
+ if (alertIndex == 0) { // popup
+ WAlertPopup(hContact, TranslateT("Specific part of the web page has changed."));
+ // contactlist name//
+ if (g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
+ db_set_s(hContact, "CList", "MyHandle", tstr);
+ }
+ else if (alertIndex == 3) { // osd
+ WAlertOSD(hContact, TranslateT("Specific part of the web page has changed."));
+ // contactlist name//
+ if (g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
+ db_set_s(hContact, "CList", "MyHandle", tstr);
+ }
+ else if (alertIndex == 1) { // log to file
+ if (!g_plugin.getString(hContact, FILE_KEY, &tdbv)) {
+ int AmountWspcRem = 0;
+ if (!g_plugin.getByte(hContact, SAVE_AS_RAW_KEY, 0)) {
+ CodetoSymbol(tempraw);
+ Sleep(100); // avoid 100% CPU
+
+ EraseBlock(tempraw);
+ Sleep(100); // avoid 100% CPU
+
+ FastTagFilter(tempraw);
+ Sleep(100); // avoid 100% CPU
+
+ NumSymbols(tempraw);
+ Sleep(100); // avoid 100% CPU
+
+ EraseSymbols(tempraw);
+ Sleep(100); // avoid 100% CPU
+
+ AmountWspcRem = g_plugin.getByte(hContact, RWSPACE_KEY, 0);
+ RemoveInvis(tempraw, AmountWspcRem);
+ Sleep(100); // avoid 100% CPU
+
+ Removewhitespace(tempraw);
+ }
+
+ SaveToFile(hContact, tempraw);
+ db_free(&tdbv);
+ // contactlist name
+ if (g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
+ db_set_s(hContact, "CList", "MyHandle", tstr);
+ }
+ }
+ else if (alertIndex == 2) { // window
+ WDisplayDataAlert(hContact);
+ // contactlist name//
+ if (g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
+ db_set_s(hContact, "CList", "MyHandle", tstr);
+ }
+ else MessageBox(nullptr, TranslateT("Unknown alert type."), _A2W(MODULENAME), MB_OK);
+ }
+ }
+ }
+ } // alert type
+ }
+ // end alerts
+
+ //if always log to file option is enabled do this
+ if (wasAlert && alertIndex != 1) { // dont do for log to file alert
+ if (g_plugin.getByte(hContact, ALWAYS_LOG_KEY, 0)) {
+ if (!g_plugin.getString(hContact, FILE_KEY, &tdbv)) {
+ int AmountWspcRem = 0;
+
+ if (!g_plugin.getByte(hContact, SAVE_AS_RAW_KEY, 0)) {
+ CodetoSymbol(tempraw);
+ Sleep(100); // avoid 100% CPU
+
+ EraseBlock(tempraw);
+ Sleep(100); // avoid 100% CPU
+
+ FastTagFilter(tempraw);
+ Sleep(100); // avoid 100% CPU
+
+ NumSymbols(tempraw);
+ Sleep(100); // avoid 100% CPU
+
+ EraseSymbols(tempraw);
+ Sleep(100); // avoid 100% CPU
+
+ AmountWspcRem = g_plugin.getByte(hContact, RWSPACE_KEY, 0);
+ RemoveInvis(tempraw, AmountWspcRem);
+ Sleep(100); // avoid 100% CPU
+
+ Removewhitespace(tempraw);
+ }
+
+ SaveToFile(hContact, tempraw);
+ db_free(&tdbv);
+ }
+ }
+ }
+ strncpy(truncated, tempraw, mir_strlen(truncated));
+ return wasAlert;
+}
+
+/*****************************************************************************/
+int DataWndAlertCommand(WPARAM wParam, LPARAM)
+{
+ MCONTACT hContact = wParam;
+ if (WindowList_Find(hWindowList, hContact))
+ return 0;
+
+ HWND hwndDlg = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_DISPLAY_DATA), nullptr, DlgProcDisplayData, hContact);
+ HWND hTopmost = g_plugin.getByte(hContact, ON_TOP_KEY, 0) ? HWND_TOPMOST : HWND_NOTOPMOST;
+ SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM)((HICON)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDI_STICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)));
+ if (g_plugin.getByte(SAVE_INDIVID_POS_KEY, 0))
+ SetWindowPos(hwndDlg, hTopmost,
+ g_plugin.getDword(hContact, "WVx", 100), // Xposition,
+ g_plugin.getDword(hContact, "WVy", 100), // Yposition,
+ g_plugin.getDword(hContact, "WVwidth", 100), // WindowWidth,
+ g_plugin.getDword(hContact, "WVheight", 100), 0); // WindowHeight,
+ else
+ SetWindowPos(hwndDlg, HWND_TOPMOST, Xposition, Yposition, WindowWidth, WindowHeight, 0);
+
+ ShowWindow(hwndDlg, SW_SHOW);
+ SetActiveWindow(hwndDlg);
+ return 0;
+}
+
+/*****************************************************************************/
+void ReadFromFile(void *param)
+{
+ MCONTACT hContact = (UINT_PTR)param;
+
+ DBVARIANT dbv;
+ char truncated[MAXSIZE1];
+ int AmountWspcRem = 0;
+ int fileexists = 0;
+
+ HWND hwndDlg = WindowList_Find(hWindowList, hContact);
+
+ char contactname[100]; contactname[0] = 0;
+ if (!db_get_s(hContact, "CList", "MyHandle", &dbv)) {
+ strncpy_s(contactname, _countof(contactname), dbv.pszVal, _TRUNCATE);
+ db_free(&dbv);
+ }
+
+ if (g_plugin.getString(hContact, CACHE_FILE_KEY, &dbv))
+ return;
+
+ FILE *pfile;
+ if ((pfile = fopen(dbv.pszVal, "r")) == nullptr) {
+ SendToRichEdit(hwndDlg, Translate("Cannot read from cache file"), TextClr, BackgoundClr);
+ fileexists = 0;
+ }
+ else {
+ fread(truncated, sizeof(truncated), 1, pfile);
+ fclose(pfile);
+ fileexists = 1;
+ }
+
+ db_free(&dbv);
+
+ if (fileexists) {
+ CodetoSymbol(truncated);
+ Sleep(100); // avoid 100% CPU
+
+ EraseBlock(truncated);
+ Sleep(100); // avoid 100% CPU
+
+ FastTagFilter(truncated);
+ Sleep(100); // avoid 100% CPU
+
+ NumSymbols(truncated);
+ Sleep(100); // avoid 100% CPU
+
+ EraseSymbols(truncated);
+ Sleep(100); // avoid 100% CPU
+
+ AmountWspcRem = g_plugin.getByte(hContact, RWSPACE_KEY, 0);
+ RemoveInvis(truncated, AmountWspcRem);
+ Sleep(100); // avoid 100% CPU
+
+ Removewhitespace(truncated);
+
+ SendToRichEdit(hwndDlg, truncated, TextClr, BackgoundClr);
+ SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Loaded from cache"));
+ }
+}
diff --git a/protocols/WebView/src/webview_cleanup.cpp b/protocols/WebView/src/webview_cleanup.cpp
new file mode 100644
index 0000000000..af620f7351
--- /dev/null
+++ b/protocols/WebView/src/webview_cleanup.cpp
@@ -0,0 +1,797 @@
+/*
+* 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"
+
+// ///////////////////////
+// characters and symbols//
+// ///////////////////////
+
+#define AMOUNT3 164
+
+char*CharacterCodes[AMOUNT3] =
+{
+ "&quot;",
+ "&amp;",
+ "&lt;",
+ "&gt;",
+ "&nbsp;",
+ "&iexcl;",
+ "&cent;",
+ "&pound;",
+ "&curren;",
+ "&yen;",
+ "&brvbar",
+ "&sect;",
+ "&uml;",
+ "&copy;",
+ "&ordf;",
+ "&laquo;",
+ "&not;",
+ "&shy;",
+ "&reg;",
+ "&macr;",
+ "&deg;",
+ "&plusmn;",
+ "&sup2;",
+ "&sup3;",
+ "&acute;",
+ "&micro;",
+ "&para;",
+ "&middot;",
+ "&cedil;",
+ "&sup1;",
+ "&ordm;",
+ "&raquo;",
+ "&frac14;",
+ "&frac12;",
+ "&frac34;",
+ "&iquest;",
+ "&Agrave;",
+ "&Aacute;",
+ "&Acirc;",
+ "&Atilde;",
+ "&Auml;",
+ "&Aring;",
+ "&AElig;",
+ "&Ccedil;",
+ "&Egrave;",
+ "&Eacute;",
+ "&Ecirc;",
+ "&Euml;",
+ "&Igrave;",
+ "&Iacute;",
+ "&Icirc;",
+ "&Iuml;",
+ "&ETH;",
+ "&Ntilde;",
+ "&Ograve;",
+ "&Oacute;",
+ "&Ocirc;",
+ "&Otilde;",
+ "&Ouml;",
+ "&times;",
+ "&Oslash;",
+ "&Ugrave;",
+ "&Uacute;",
+ "&Ucirc;",
+ "&Uuml;",
+ "&Yacute;",
+ "&THORN;",
+ "&szlig;",
+ "&agrave;",
+ "&aacute;",
+ "&acirc;",
+ "&atilde;",
+ "&auml;",
+ "&aring;",
+ "&aelig;",
+ "&ccedil;",
+ "&egrave;",
+ "&eacute;",
+ "&ecirc;",
+ "&euml;",
+ "&igrave;",
+ "&iacute;",
+ "&icirc;",
+ "&iuml;",
+ "&eth;",
+ "&ntilde;",
+ "&ograve;",
+ "&oacute;",
+ "&ocirc;",
+ "&otilde;",
+ "&ouml;",
+ "&divide;",
+ "&oslash;",
+ "&ugrave;",
+ "&uacute;",
+ "&ucirc;",
+ "&uuml;",
+ "&yacute;",
+ "&thorn;",
+ "&yumil;",
+ "&#338;", // greater that 255, extra latin characters
+ "&#339;",
+ "&#352;",
+ "&#353;",
+ "&#376;",
+ "&#402;",
+ "&#710;",
+ "&#732;",
+ "&OElig;",
+ "&oelig;",
+ "&Scaron;",
+ "&scaron;",
+ "&Yuml;",
+ "&fnof;",
+ "&circ;",
+ "&tilde;",
+ "&#8211;", // Misc other characters
+ "&#8212;",
+ "&#8216;",
+ "&#8217;",
+ "&#8218;",
+ "&#8220;",
+ "&#8221;",
+ "&#8222;",
+ "&#8224;",
+ "&#8225;",
+ "&#8226;",
+ "&#8230;",
+ "&#8240;",
+ "&#8249;",
+ "&#8250;",
+ "&#8364;",
+ "&#8465;",
+ "&#8476;",
+ "&#8482;",
+ "&ndash;",
+ "&mdash;",
+ "&lsquo;",
+ "&rsquo;",
+ "&sbquo;",
+ "&ldquo;",
+ "&rdquo;",
+ "&bdquo;",
+ "&dagger;",
+ "&Dagger;",
+ "&bull;",
+ "&hellip;",
+ "&permil;",
+ "&lsaquo;",
+ "&rsaquo;",
+ "&euro;",
+ "&image;",
+ "&real;",
+ "&trade;",
+ "&ensp;",
+ "&emsp;",
+ "&thinsp;",
+ "&#8194;",
+ "&#8195;",
+ "&#8201;",
+ "&otilde;", // symbols without numeric code
+ "&iquest;",
+ "&brvbar;",
+ "&macr;"};
+
+char Characters[AMOUNT3] =
+{
+ '\"',
+ '&',
+ '<',
+ '>',
+ ' ',
+ '¡',
+ '¢',
+ '£',
+ '¤',
+ '¥',
+ '¦',
+ '§',
+ '¨',
+ '©',
+ 'ª',
+ '«',
+ '¬',
+ '­',
+ '®',
+ '¯',
+ '°',
+ '±',
+ '²',
+ '³',
+ '´',
+ 'µ',
+ '¶',
+ '·',
+ '¸',
+ '¹',
+ 'º',
+ '»',
+ '¼',
+ '½',
+ '¾',
+ '¿',
+ 'À',
+ 'Á',
+ 'Â',
+ 'Ã',
+ 'Ä',
+ 'Å',
+ 'Æ',
+ 'Ç',
+ 'È',
+ 'É',
+ 'Ê',
+ 'Ë',
+ 'Ì',
+ 'Í',
+ 'Î',
+ 'Ï',
+ 'Ð',
+ 'Ñ',
+ 'Ò',
+ 'Ó',
+ 'Ô',
+ 'Õ',
+ 'Ö',
+ '×',
+ 'Ø',
+ 'Ù',
+ 'Ú',
+ 'Û',
+ 'Ü',
+ 'Ý',
+ 'Þ',
+ 'ß',
+ 'à',
+ 'á',
+ 'â',
+ 'ã',
+ 'ä',
+ 'å',
+ 'æ',
+ 'ç',
+ 'è',
+ 'é',
+ 'ê',
+ 'ë',
+ 'ì',
+ 'í',
+ 'î',
+ 'ï',
+ 'ð',
+ 'ñ',
+ 'ò',
+ 'ó',
+ 'ô',
+ 'õ',
+ 'ö',
+ '÷',
+ 'ø',
+ 'ù',
+ 'ú',
+ 'û',
+ 'ü',
+ 'ý',
+ 'þ',
+ 'ÿ',
+ 'Œ', // greater than 255 extra latin characters
+ 'œ',
+ 'Š',
+ 'š',
+ 'Ÿ',
+ 'ƒ',
+ 'ˆ',
+ '˜',
+ 'Œ',
+ 'œ',
+ 'Š',
+ 'š',
+ 'Ÿ',
+ 'ƒ',
+ 'ˆ',
+ '˜',
+ '–',
+ '—', // misc other characters
+ '‘',
+ '’',
+ '‚',
+ '“',
+ '”',
+ '„',
+ '†',
+ '‡',
+ '•',
+ '…',
+ '‰',
+ '‹',
+ '›',
+ '€',
+ 'I',
+ 'R',
+ '™',
+ '–',
+ '—',
+ '‘',
+ '’',
+ '‚',
+ '“',
+ '”',
+ '„',
+ '†',
+ '‡',
+ '•',
+ '…',
+ '‰',
+ '‹',
+ '›',
+ '€',
+ 'I',
+ 'R',
+ '™',
+ ' ',
+ ' ',
+ ' ',
+ ' ',
+ ' ',
+ ' ',
+ 'õ',
+ '¿',
+ '¦',
+ '¯'};
+
+/*****************************************************************************/
+void CodetoSymbol(char *truncated)
+{
+ int counter = 0;
+ int position = 0, recpos = 0;
+ static char *stringfrompos;
+
+ for (int n = 0; n < AMOUNT3; n++) {
+ while (true) { // loop forever
+ Sleep(1); // avoid 100% CPU
+
+ if ( strstr(truncated, CharacterCodes[n]) != nullptr) { // does character code exist?
+ stringfrompos = strstr(truncated, CharacterCodes[n]);
+
+ position = stringfrompos - truncated;
+ counter = 0;
+ while (counter != mir_strlen(CharacterCodes[n])) {
+ truncated[position + counter] = ' ';
+ counter++;
+ }
+
+ truncated[(position + counter) - 1] = Characters[n];
+ strncpy(&truncated[position], &truncated[position + mir_strlen(CharacterCodes[n])] - 1, mir_strlen(&truncated[position]) - 1);
+ } // end does character code exist?
+
+ if (recpos == position)
+ break; // break out of loop if doesn't find new character code
+
+ recpos = position;
+ } // end loop forever
+ } // for
+}
+
+/*****************************************************************************/
+void EraseBlock(char *truncated)
+{
+ int counter = 0;
+ int positionStart = 0, positionEnd = 0;
+ char *stringfrompos;
+ int BlockLength = 0;
+
+ char* tempraw = (char*)malloc(MAXSIZE1);
+ if (truncated)
+ strncpy(tempraw, truncated, MAXSIZE1);
+
+ // ///////////////////////////
+
+ while (true) {
+ Sleep(1); // avoid 100% CPU
+ // /get start and end of block
+
+ if (strstr(tempraw, "<!--") != nullptr) // does tag exist?
+ {
+ stringfrompos = strstr(tempraw, "<!--");
+ positionStart = stringfrompos - tempraw;
+ }
+
+ if (strstr(tempraw, "-->") != nullptr) // does tag exist?
+ {
+ stringfrompos = strstr(tempraw, "-->");
+ positionEnd = stringfrompos - tempraw;
+ }
+ BlockLength = (positionEnd - positionStart) + 3;
+
+ if ((strstr(tempraw, "<!--") == nullptr) || (strstr(tempraw, "-->") == nullptr))
+ break;
+
+ /////////////////////////////////////////
+
+ if (strstr(tempraw, "<!--") != nullptr)
+ for (counter = 0; counter < BlockLength; counter++)
+ tempraw[positionStart + counter] = ' ';
+
+ if ((positionStart == 0) && (positionEnd == 0))
+ break;
+ if (positionStart > positionEnd)
+ break;
+
+ positionStart = 0;
+ positionEnd = 0;
+ }
+
+ // ///////////////////////////
+ positionStart = 0;
+ positionEnd = 0;
+
+ // 2//
+ while (true) {
+ Sleep(1); // avoid 100% CPU
+ // /get start and end of block
+
+ if (((strstr(tempraw, "<script")) != nullptr) || (strstr(tempraw, "<SCRIPT") != nullptr)) // does
+ {
+ if (strstr(tempraw, "<script") != nullptr)
+ stringfrompos = strstr(tempraw, "<script");
+ else
+ stringfrompos = strstr(tempraw, "<SCRIPT");
+
+ positionStart = stringfrompos - tempraw;
+ }
+
+ if (((strstr(tempraw, "</script")) != nullptr) || (strstr(tempraw, "</SCRIPT") != nullptr)) // does
+ {
+ if (strstr(tempraw, "<script") != nullptr)
+ stringfrompos = strstr(tempraw, "</script");
+ else
+ stringfrompos = strstr(tempraw, "</SCRIPT");
+
+ positionEnd = stringfrompos - tempraw;
+ }
+ BlockLength = (positionEnd - positionStart) + 9;
+
+ if ((strstr(tempraw, "<script") != nullptr) && (strstr(tempraw, "</script") == nullptr))
+ break;
+
+ if ((strstr(tempraw, "<SCRIPT") != nullptr) && (strstr(tempraw, "</SCRIPT") == nullptr))
+ break;
+
+ ///////////////////////////////////////
+
+ if (((strstr(tempraw, "<script")) != nullptr) || ((strstr(tempraw, "<SCRIPT")) != nullptr))
+ for (counter = 0; counter < BlockLength; counter++)
+ tempraw[positionStart + counter] = ' ';
+
+ if ((positionStart == 0) && (positionEnd == 0))
+ break;
+ if (positionStart > positionEnd)
+ break;
+
+ positionStart = 0;
+ positionEnd = 0;
+ }
+
+ // ////
+ // 3//
+ while (true)
+ {
+ Sleep(1); // avoid 100% CPU
+ // /get start and end of block
+
+ if (((strstr(tempraw, "<style")) != nullptr) || (strstr(tempraw, "<STYLE") != nullptr)) // does
+ {
+ if (strstr(tempraw, "<style") != nullptr)
+ stringfrompos = strstr(tempraw, "<style");
+ else
+ stringfrompos = strstr(tempraw, "<STYLE");
+
+ positionStart = stringfrompos - tempraw;
+ }
+
+ if (((strstr(tempraw, "</style")) != nullptr) || (strstr(tempraw, "</STYLE") != nullptr)) // does
+ {
+ if (strstr(tempraw, "<style") != nullptr)
+ stringfrompos = strstr(tempraw, "</style");
+ else
+ stringfrompos = strstr(tempraw, "</STYLE");
+
+ positionEnd = stringfrompos - tempraw;
+ }
+ BlockLength = (positionEnd - positionStart) + 8;
+
+ if ((strstr(tempraw, "<style") != nullptr) && (strstr(tempraw, "</style") == nullptr))
+ break;
+
+ if ((strstr(tempraw, "<STYLE") != nullptr) && (strstr(tempraw, "</STYLE") == nullptr))
+ break;
+
+ ///////////////////////////////////////
+ if (((strstr(tempraw, "<style")) != nullptr) || ((strstr(tempraw, "<STYLE")) != nullptr))
+ for (counter = 0; counter < BlockLength; counter++)
+ tempraw[positionStart + counter] = ' ';
+
+ if ((positionStart == 0) && (positionEnd == 0))
+ break;
+ if (positionStart > positionEnd)
+ break;
+
+ positionStart = 0;
+ positionEnd = 0;
+ }
+
+ // 4//
+
+ while (true) {
+ Sleep(1); // avoid 100% CPU
+ // /get start and end of block
+ if (strstr(tempraw, "{") != nullptr) // does tag exist?
+ {
+ stringfrompos = strstr(tempraw, "{");
+ positionStart = stringfrompos - tempraw;
+ }
+
+ if (strstr(tempraw, "}") != nullptr) // does tag exist?
+ {
+ stringfrompos = strstr(tempraw, "}");
+ positionEnd = stringfrompos - tempraw;
+ }
+ BlockLength = (positionEnd - positionStart) + 1;
+
+ if ((strstr(tempraw, "}") == nullptr) || (strstr(tempraw, "{") == nullptr))
+ break;
+
+ /////////////////////////////////////////
+ if (strstr(tempraw, "{") != nullptr)
+ for (counter = 0; counter < BlockLength; counter++)
+ tempraw[positionStart + counter] = ' ';
+
+ if ((positionStart == 0) && (positionEnd == 0))
+ break;
+ if (positionStart > positionEnd)
+ break;
+
+ positionStart = 0;
+ positionEnd = 0;
+ }
+
+ // ///////////////////////////
+ positionStart = 0;
+ positionEnd = 0;
+
+ strncpy(truncated, tempraw, mir_strlen(truncated));
+ free(tempraw);
+}
+
+/*****************************************************************************/
+void EraseSymbols(char *truncated)
+{
+ int counter = 0;
+ int position = 0, recpos = 0;
+ char *stringfrompos;
+
+ char *tempraw = (char*)malloc(MAXSIZE1);
+ if (truncated)
+ strncpy(tempraw, truncated, MAXSIZE1);
+
+ // //////
+ while (true) {
+ Sleep(1); // avoid 100% CPU
+
+ /**/
+ counter = 0;
+ if ((strstr(tempraw, "&#")) != nullptr) {
+ stringfrompos = strstr(tempraw, "&#");
+ position = stringfrompos - tempraw;
+
+ while (true) {
+ tempraw[position + counter] = ' ';
+ counter++;
+ if (counter > 20)
+ break;
+ if (tempraw[position + counter] == ' ')
+ break;
+ }
+ if (tempraw[position + counter] == ';')
+ tempraw[position + counter] = ' ';
+ }
+ if (recpos == position)
+ break;
+ recpos = position;
+ }
+
+ strncpy(truncated, tempraw, mir_strlen(truncated));
+ free(tempraw);
+}
+
+/*****************************************************************************/
+void NumSymbols(char *truncated)
+{
+ int counter = 0;
+ int position = 0, recpos = 0;
+ char*stringfrompos;
+ char symbol[20];
+ int character;
+
+ char *tempraw = (char*)malloc(MAXSIZE1);
+ if (truncated)
+ strncpy(tempraw, truncated, MAXSIZE1);
+
+ while (true) {
+ Sleep(1); // avoid 100% CPU
+
+ counter = 0;
+
+ if ((strstr(tempraw, "&#")) != nullptr) {
+ stringfrompos = strstr(tempraw, "&#");
+ position = stringfrompos - tempraw;
+
+ while (true) {
+ if (counter > 1)
+ symbol[counter - 2] = tempraw[position + counter];
+
+ tempraw[position + counter] = ' ';
+ counter++;
+ if (counter > 20)
+ break;
+
+ if ((tempraw[position + counter] == ';')) {
+ symbol[counter - 2] = '\0';
+ character = atoi(symbol);
+
+ if (character > 0 && character < 256)
+ memset(&tempraw[position], character, 1);
+ break;
+ }
+ }
+
+ if (tempraw[position + counter] == ';')
+ tempraw[position + counter] = ' ';
+ }
+ if (recpos == position)
+ break;
+ recpos = position;
+ }
+
+ strncpy(truncated, tempraw, mir_strlen(truncated));
+ free(tempraw);
+}
+
+/*****************************************************************************/
+void FastTagFilter(char *truncated)
+{
+ char *tempraw = (char*)malloc(MAXSIZE1);
+ if (truncated)
+ strncpy(tempraw, truncated, MAXSIZE1);
+
+ for (int counter = 0; counter < mir_strlen(tempraw); counter++) {
+ if (tempraw[counter] == '<') {
+ while (tempraw[counter] != '>') {
+ if (counter >= mir_strlen(tempraw))
+ break;
+
+ tempraw[counter] = ' ';
+ counter++;
+ }
+ if (tempraw[counter] == '>')
+ tempraw[counter] = ' ';
+ }
+ }
+
+ strncpy(truncated, tempraw, mir_strlen(truncated));
+ free(tempraw);
+}
+
+/*****************************************************************************/
+void RemoveInvis(char *truncated, int AmountWspcRem)
+{
+ int erase = 0;
+ int RemovalLevel = 0;
+
+ char *tempraw = (char*)malloc(MAXSIZE1);
+ if (truncated)
+ strncpy(tempraw, truncated, MAXSIZE1);
+
+ switch (AmountWspcRem) {
+ case 1:
+ RemovalLevel = 80; // small
+ break;
+ case 2:
+ RemovalLevel = 30; // medium
+ break;
+ case 3:
+ RemovalLevel = 10; // large
+ break;
+ }
+
+ for (int counter = 0; counter < mir_strlen(tempraw); counter++) {
+ if (AmountWspcRem != 0 && AmountWspcRem != 4) {
+ if ((tempraw[counter] == '\n') || (tempraw[counter] == ' ') || (tempraw[counter] == '\r'))
+ erase = erase + 1;
+ else
+ erase = 0;
+
+ if (erase > RemovalLevel)
+ tempraw[counter] = ' ';
+ }
+
+ if (AmountWspcRem == 4)
+ if ((tempraw[counter] == '\n') || (tempraw[counter] == ' ') || (tempraw[counter] == '\r'))
+ tempraw[counter] = ' ';
+ } // end for
+
+ strncpy(truncated, tempraw, mir_strlen(truncated));
+ free(tempraw);
+}
+
+/*****************************************************************************/
+void RemoveTabs(char *truncated)
+{
+ char *tempraw = (char*)malloc(MAXSIZE1);
+ if (truncated)
+ strncpy(tempraw, truncated, MAXSIZE1);
+
+ for (int counter = 0; counter < mir_strlen(tempraw); counter++)
+ if (tempraw[counter] == '\t')
+ tempraw[counter] = ' ';
+
+ strncpy(truncated, tempraw, mir_strlen(truncated));
+ free(tempraw);
+}
+
+/*****************************************************************************/
+void Removewhitespace(char *truncated)
+{
+ int counter2 = 0;
+ int pos1 = 0, pos2 = 0;
+
+ for (int counter = 0; counter < mir_strlen(truncated); counter++) {
+ if (truncated[counter] == ' ' && truncated[counter + 1] == ' ') {
+ pos1 = counter + 1;
+ counter2 = counter;
+
+ while (truncated[counter2] == ' ')
+ counter2++;
+
+ pos2 = counter2;
+ strncpy(&truncated[pos1], &truncated[pos2], mir_strlen(&truncated[pos1]) - 1);
+ } // end if
+ } // end for
+}
+
+/*****************************************************************************/
+void Filter(char *truncated)
+{
+ char tempraw[MAXSIZE1];
+ strncpy(tempraw, truncated, _countof(tempraw));
+
+ for (int counter = 0; counter < mir_strlen(tempraw); counter++)
+ if ((tempraw[counter] == '\n') || (tempraw[counter] == '\r') || (tempraw[counter] == '\t'))
+ strncpy(&tempraw[counter], &tempraw[counter + 1], mir_strlen(&tempraw[counter]) - 1);
+
+ strncpy(truncated, tempraw, mir_strlen(truncated));
+}
diff --git a/protocols/WebView/src/webview_datawnd.cpp b/protocols/WebView/src/webview_datawnd.cpp
new file mode 100644
index 0000000000..dc8b414547
--- /dev/null
+++ b/protocols/WebView/src/webview_datawnd.cpp
@@ -0,0 +1,514 @@
+/*
+* 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"
+
+/*****************************************************************************/
+INT_PTR CALLBACK DlgProcFind(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ static char Searchstr[128];
+ static int loc;
+ static int oldloc;
+ static int startposition;
+ static int OLDstartposition;
+
+ HWND ParentHwnd = GetParent(hwndDlg);
+
+ switch (msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
+ SetWindowText(hwndDlg, TranslateT("Find"));
+ SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_FIND)));
+ return TRUE;
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDC_OK: // find Next
+ {
+ char NewSearchstr[128];
+ int location = 0;
+ int startsel = 0, endsel = 0;
+ char buff[MAXSIZE1];
+
+ memset(&NewSearchstr, 0, sizeof(NewSearchstr));
+
+ int len = GetWindowTextLength(GetDlgItem(ParentHwnd, IDC_DATA));
+
+ char *tempbuffer = (char*)malloc(len + 2);
+
+ GetDlgItemTextA(ParentHwnd, IDC_DATA, tempbuffer, len);
+ strncpy(buff, tempbuffer, _countof(buff));
+ free(tempbuffer);
+
+ Filter(buff);
+ CharUpperBuffA(buff, (int)mir_strlen(buff));
+
+ GetDlgItemTextA(hwndDlg, IDC_FINDWHAT, NewSearchstr, _countof(NewSearchstr));
+ CharUpperBuffA(NewSearchstr, (int)mir_strlen(NewSearchstr));
+
+ OLDstartposition = startposition;
+
+ if ((strstr(Searchstr, NewSearchstr)) != nullptr)
+ startposition = loc + (int)mir_strlen(Searchstr);
+ else {
+ oldloc = 0;
+ startposition = 0;
+ }
+
+ mir_strcpy(Searchstr, NewSearchstr);
+
+ if (!(startposition > (int)mir_strlen(buff)))
+ location = (strstr(buff + startposition, NewSearchstr)) - buff;
+
+ oldloc = loc;
+ loc = location;
+
+ if (loc == 0) {
+ ShowWindow(GetDlgItem(hwndDlg, IDC_SEARCH_COMPLETE), SW_SHOW);
+ loc = (strstr(buff, NewSearchstr)) - buff;
+ startsel = loc;
+ endsel = loc + (int)mir_strlen(NewSearchstr);
+ oldloc = 0;
+ startposition = 0;
+ }
+ else {
+ ShowWindow(GetDlgItem(hwndDlg, IDC_SEARCH_COMPLETE), SW_HIDE);
+ startsel = loc;
+ endsel = loc + (int)mir_strlen(NewSearchstr);
+ }
+
+ CHARRANGE sel2 = { startsel, endsel };
+ SendDlgItemMessage(ParentHwnd, IDC_DATA, EM_EXSETSEL, 0, (LPARAM)&sel2);
+ SetFocus(GetDlgItem(ParentHwnd, IDC_DATA));
+ }
+ return TRUE;
+
+ case WM_DESTROY:
+ case IDC_CANCEL:
+ EnableWindow(GetDlgItem(ParentHwnd, IDC_FIND_BUTTON), 1);
+ EnableWindow(ParentHwnd, 1);
+ DestroyWindow(hwndDlg);
+ }
+ break;
+ }
+ return FALSE;
+}
+
+/*****************************************************************************/
+
+static wchar_t tszSizeString[] = L"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
+
+static MCONTACT FindContactByUrl(HWND hwndDlg)
+{
+ MCONTACT res = NULL;
+ wchar_t urltext[300], titlebartxt[300];
+ int contactcount = 0;
+
+ GetDlgItemText(hwndDlg, IDC_OPEN_URL, urltext, _countof(urltext));
+ GetWindowText(hwndDlg, titlebartxt, _countof(titlebartxt));
+
+ for (auto &hContact : Contacts(MODULENAME)) {
+ ptrW db1(g_plugin.getWStringA(hContact, URL_KEY));
+ ptrW db2(g_plugin.getWStringA(hContact, PRESERVE_NAME_KEY));
+
+ if (!mir_wstrcmp(urltext, db1) && !mir_wstrcmp(titlebartxt, db2)) {
+ contactcount++;
+ if (contactcount > 1) {
+ MessageBox(nullptr, TranslateT("ERROR: You have two or more Webview contacts with the same URL and contact name."), _A2W(MODULENAME), MB_OK);
+ return NULL;
+ }
+ res = hContact;
+ }
+ }
+ return res;
+}
+
+INT_PTR CALLBACK DlgProcDisplayData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ DBVARIANT dbv;
+ RECT rc;
+ wchar_t url[300];
+ MCONTACT hContact;
+
+ switch (msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+ {
+ MCONTACT hContact2 = lParam;
+
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)hContact2);
+ WindowList_Add(hWindowList, hwndDlg, hContact2);
+
+ url[0] = '\0';
+ if (!g_plugin.getWString(hContact2, URL_KEY, &dbv)) {
+ wcsncpy_s(url, dbv.pwszVal, _TRUNCATE);
+ db_free(&dbv);
+ }
+ SetDlgItemText(hwndDlg, IDC_OPEN_URL, FixButtonText(url, _countof(url)));
+
+ char preservename[100];
+ if (!g_plugin.getString(hContact2, PRESERVE_NAME_KEY, &dbv)) {
+ strncpy_s(preservename, _countof(preservename), dbv.pszVal, _TRUNCATE);
+ db_free(&dbv);
+ }
+ else preservename[0] = 0;
+ SetWindowTextA(hwndDlg, preservename);
+
+ SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_SITE)));
+
+ // //////
+ COLORREF colour = BackgoundClr;
+ COLORREF txtcolor;
+ SendDlgItemMessage(hwndDlg, IDC_DATA, EM_SETBKGNDCOLOR, 0, colour);
+
+ SendDlgItemMessage(hwndDlg, IDC_UPDATE_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDI_UPDATE), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0));
+ SendDlgItemMessage(hwndDlg, IDC_UPDATE_BUTTON, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Update data"), BATF_UNICODE);
+
+ SendDlgItemMessage(hwndDlg, IDC_FIND_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDI_FIND), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0));
+ SendDlgItemMessage(hwndDlg, IDC_FIND_BUTTON, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Find"), BATF_UNICODE);
+
+ SendDlgItemMessage(hwndDlg, IDC_OPTIONS_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDI_OPTIONS), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0));
+ SendDlgItemMessage(hwndDlg, IDC_OPTIONS_BUTTON, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Contact options"), BATF_UNICODE);
+
+ SendDlgItemMessage(hwndDlg, IDC_ALERT_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDI_ALERT), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0));
+ SendDlgItemMessage(hwndDlg, IDC_ALERT_BUTTON, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Alert options"), BATF_UNICODE);
+
+ SendDlgItemMessage(hwndDlg, IDC_STOP, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDI_STOP), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0));
+ SendDlgItemMessage(hwndDlg, IDC_STOP, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Stop processing"), BATF_UNICODE);
+
+ SendDlgItemMessage(hwndDlg, IDC_OPEN_URL, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Click here to open this URL in a browser window."), BATF_UNICODE);
+
+ if (!g_plugin.getByte(hContact2, ON_TOP_KEY)) {
+ SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDI_UNSTICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0));
+ SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Stick to the front"), BATF_UNICODE);
+ }
+ else {
+ SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDI_STICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0));
+ SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Disable stick to the front"), BATF_UNICODE);
+ }
+
+ SendDlgItemMessage(hwndDlg, IDC_DATA, WM_SETFONT, (WPARAM)h_font, 1);
+
+ txtcolor = TextClr;
+
+ SetDlgItemText(hwndDlg, IDC_DATA, L"");
+
+ InvalidateRect(hwndDlg, nullptr, 1);
+
+ SendDlgItemMessage(hwndDlg, IDC_DATA, EM_AUTOURLDETECT, 1, 0);
+ int mask = (int)SendDlgItemMessage(hwndDlg, IDC_DATA, EM_GETEVENTMASK, 0, 0);
+
+ SendDlgItemMessage(hwndDlg, IDC_DATA, EM_SETEVENTMASK, 0, mask | ENM_LINK | ENM_MOUSEEVENTS);
+
+ SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BUTTONSETASFLATBTN, 0, 0);
+ SendDlgItemMessage(hwndDlg, IDC_UPDATE_BUTTON, BUTTONSETASFLATBTN, 0, 0);
+ SendDlgItemMessage(hwndDlg, IDC_FIND_BUTTON, BUTTONSETASFLATBTN, 0, 0);
+ SendDlgItemMessage(hwndDlg, IDC_OPTIONS_BUTTON, BUTTONSETASFLATBTN, 0, 0);
+ SendDlgItemMessage(hwndDlg, IDC_ALERT_BUTTON, BUTTONSETASFLATBTN, 0, 0);
+ SendDlgItemMessage(hwndDlg, IDC_STOP, BUTTONSETASFLATBTN, 0, 0);
+
+ SendDlgItemMessage(hwndDlg, IDC_OPEN_URL, BUTTONSETASFLATBTN, 0, 0);
+
+ HDC hdc = GetDC(GetDlgItem(hwndDlg, IDC_STATUSBAR));
+ SelectObject(hdc, (HFONT)SendDlgItemMessage(hwndDlg, IDC_STATUSBAR, WM_GETFONT, 0, 0));
+ SIZE textSize;
+ GetTextExtentPoint32(hdc, tszSizeString, _countof(tszSizeString), &textSize);
+ int partWidth[2] = { textSize.cx, -1 };
+ ReleaseDC(GetDlgItem(hwndDlg, IDC_STATUSBAR), hdc);
+
+ SendDlgItemMessage(hwndDlg, IDC_STATUSBAR, SB_SETPARTS, _countof(partWidth), (LPARAM)partWidth);
+ SendDlgItemMessage(hwndDlg, IDC_STATUSBAR, SB_SETTEXT, 1 | SBT_OWNERDRAW, 0);
+
+ if (g_plugin.getByte(SAVE_INDIVID_POS_KEY, 0))
+ Utils_RestoreWindowPosition(hwndDlg, hContact2, MODULENAME, "WV");
+ }
+ break;
+
+ case WM_NOTIFY:
+ switch (((NMHDR *)lParam)->code) {
+ case EN_MSGFILTER:
+ switch (((MSGFILTER *)lParam)->msg) {
+ case WM_RBUTTONUP:
+ {
+ POINT pt;
+ CHARRANGE sel, all = { 0, -1 };
+
+ HMENU hSubMenu = GetSubMenu(hMenu, 0);
+ TranslateMenu(hSubMenu);
+ SendMessage(((NMHDR *)lParam)->hwndFrom, EM_EXGETSEL, 0, (LPARAM)& sel);
+
+ EnableMenuItem(hSubMenu, IDM_COPY, MF_ENABLED);
+ EnableMenuItem(hSubMenu, IDM_CUT, MF_ENABLED);
+ EnableMenuItem(hSubMenu, IDM_DELETE, MF_ENABLED);
+
+ if (sel.cpMin == sel.cpMax) {
+ EnableMenuItem(hSubMenu, IDM_COPY, MF_BYCOMMAND | MF_GRAYED);
+ EnableMenuItem(hSubMenu, IDM_CUT, MF_BYCOMMAND | MF_GRAYED);
+ EnableMenuItem(hSubMenu, IDM_DELETE, MF_BYCOMMAND | MF_GRAYED);
+ }
+ pt.x = (short)LOWORD(((ENLINK *)lParam)->lParam);
+ pt.y = (short)HIWORD(((ENLINK *)lParam)->lParam);
+ ClientToScreen(((NMHDR *)lParam)->hwndFrom, &pt);
+ switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, nullptr)) {
+ case IDM_COPY:
+ SendMessage(((NMHDR *)lParam)->hwndFrom, WM_COPY, 0, 0);
+ break;
+
+ case IDM_COPYALL:
+ SendMessage(((NMHDR *)lParam)->hwndFrom, EM_EXSETSEL, 0, (LPARAM)& all);
+ SendMessage(((NMHDR *)lParam)->hwndFrom, WM_COPY, 0, 0);
+ SendMessage(((NMHDR *)lParam)->hwndFrom, EM_EXSETSEL, 0, (LPARAM)& sel);
+ break;
+
+ case IDM_SELECTALL:
+ SendMessage(((NMHDR *)lParam)->hwndFrom, EM_EXSETSEL, 0, (LPARAM)& all);
+ break;
+
+ case IDM_CUT:
+ SendMessage(((NMHDR *)lParam)->hwndFrom, WM_CUT, 0, 0);
+ break;
+
+ case IDM_PASTE:
+ SendMessage(((NMHDR *)lParam)->hwndFrom, WM_PASTE, 0, 0);
+ break;
+
+ case IDM_DELETE:
+ SendMessage(((NMHDR *)lParam)->hwndFrom, WM_CLEAR, 0, 0);
+ break;
+
+ case IDM_CLEAR_ALL:
+ SetDlgItemTextA(hwndDlg, IDC_DATA, "");
+ SetFocus(GetDlgItem(hwndDlg, IDC_DATA));
+ break;
+ }
+ }
+ }
+ break;
+
+ case EN_LINK:
+ switch (((ENLINK *)lParam)->msg) {
+ case WM_RBUTTONDOWN:
+ case WM_LBUTTONUP:
+ CHARRANGE sel;
+ SendDlgItemMessage(hwndDlg, IDC_DATA, EM_EXGETSEL, 0, (LPARAM)& sel);
+ if (sel.cpMin != sel.cpMax)
+ break;
+
+ TEXTRANGEA tr;
+ tr.chrg = ((ENLINK *)lParam)->chrg;
+ tr.lpstrText = (char*)malloc(tr.chrg.cpMax - tr.chrg.cpMin + 8);
+
+ SendDlgItemMessage(hwndDlg, IDC_DATA, EM_GETTEXTRANGE, 0, (LPARAM)& tr);
+ if (strchr(tr.lpstrText, '@') != nullptr && strchr(tr.lpstrText, ':') == nullptr && strchr(tr.lpstrText, '/') == nullptr) {
+ memmove(tr.lpstrText + 7, tr.lpstrText, tr.chrg.cpMax - tr.chrg.cpMin + 1);
+ memcpy(tr.lpstrText, "mailto:", 7);
+ }
+
+ Utils_OpenUrl(tr.lpstrText);
+ SetFocus(GetDlgItem(hwndDlg, IDC_DATA));
+
+ free(tr.lpstrText);
+ break;
+ }
+ }
+ break; // notify
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDC_OPEN_URL:
+ GetDlgItemText(hwndDlg, IDC_OPEN_URL, url, _countof(url));
+ Utils_OpenUrlW(url);
+ g_plugin.setWord(wParam, "Status", ID_STATUS_ONLINE);
+ break;
+
+ case IDC_UPDATE_BUTTON:
+ if (hContact = FindContactByUrl(hwndDlg)) {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE_BUTTON), 0);
+ UpdateMenuCommand(wParam, lParam, hContact);
+ }
+ break;
+
+ case IDC_STOP:
+ if (hContact = FindContactByUrl(hwndDlg))
+ g_plugin.setByte(hContact, STOP_KEY, 1);
+ break;
+
+ case IDC_STICK_BUTTON:
+ if (hContact = FindContactByUrl(hwndDlg))
+ OnTopMenuCommand(wParam, lParam, hContact);
+ {
+ wchar_t *ptszToolTip;
+ HWND hTopmost;
+ if (!g_plugin.getByte(hContact, ON_TOP_KEY, 0)) {
+ hTopmost = HWND_NOTOPMOST;
+ ptszToolTip = TranslateT("Stick to the front");
+ }
+ else {
+ hTopmost = HWND_TOPMOST;
+ ptszToolTip = TranslateT("Disable stick to the front");
+ }
+ SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDI_UNSTICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0));
+ SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BUTTONADDTOOLTIP, (WPARAM)ptszToolTip, BATF_UNICODE);
+ SetWindowPos(hwndDlg, hTopmost, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
+ }
+ break;
+
+ case IDC_FIND_BUTTON:
+ {
+ HWND hwndFind = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_FIND), hwndDlg, DlgProcFind, (LPARAM)wParam);
+ ShowWindow(hwndFind, SW_SHOW);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_FIND_BUTTON), 0);
+ }
+ break;
+
+ case IDC_OPTIONS_BUTTON:
+ if (hContact = FindContactByUrl(hwndDlg))
+ DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CONTACT_OPT), hwndDlg, DlgProcContactOpt, hContact);
+ break;
+
+ case IDC_ALERT_BUTTON:
+ if (hContact = FindContactByUrl(hwndDlg))
+ DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_ALRT_OPT), hwndDlg, DlgProcAlertOpt, hContact);
+ break;
+
+ case IDOK:
+ case IDCANCEL:
+ if (hwndDlg != nullptr)
+ DestroyWindow(hwndDlg);
+ return TRUE;
+ }
+ break;
+
+ case WM_CLOSE:
+ if (Yposition == -32000)
+ Yposition = 100;
+
+ if (Xposition == -32000)
+ Xposition = 100;
+
+ SavewinSettings();
+
+ if (hContact = FindContactByUrl(hwndDlg))
+ Utils_SaveWindowPosition(hwndDlg, hContact, MODULENAME, "WV");
+
+ if (hwndDlg != nullptr)
+ DestroyWindow(hwndDlg);
+ return 0;
+
+ case WM_DESTROY:
+ WindowList_Remove(hWindowList, hwndDlg);
+ return 0;
+
+ case WM_SIZE:
+ Utils_ResizeDialog(hwndDlg, g_plugin.getInst(), MAKEINTRESOURCEA(IDD_DISPLAY_DATA), DataDialogResize);
+ InvalidateRect(hwndDlg, nullptr, TRUE);
+
+ // global
+ GetWindowRect(hwndDlg, &rc);
+ Xposition = rc.left;
+ Yposition = rc.top;
+ WindowHeight = rc.bottom - rc.top;
+ WindowWidth = rc.right - rc.left;
+ break;
+
+ case WM_MOVE:
+ if (!IsIconic(hwndDlg) && !IsZoomed(hwndDlg)) {
+ GetWindowRect(hwndDlg, &rc);
+ // global
+ Xposition = rc.left;
+ Yposition = rc.top;
+ WindowHeight = rc.bottom - rc.top;
+ WindowWidth = rc.right - rc.left;
+
+ if ((GetAsyncKeyState(VK_CONTROL) & 0x8000))
+ break;
+
+ ValidatePosition(hwndDlg);
+ }
+ }
+ return FALSE;
+}
+
+/*****************************************************************************/
+
+int DataDialogResize(HWND, LPARAM, UTILRESIZECONTROL *urc)
+{
+ switch (urc->wId) {
+ case IDC_OPEN_URL:
+ return RD_ANCHORX_WIDTH | RD_ANCHORY_TOP;
+ case IDC_DATA:
+ return RD_ANCHORX_WIDTH | RD_ANCHORY_HEIGHT;
+ case IDC_STATUSBAR:
+ return RD_ANCHORX_WIDTH | RD_ANCHORX_RIGHT;
+
+ }
+ return RD_ANCHORX_LEFT | RD_ANCHORY_TOP;
+}
+
+/*****************************************************************************/
+
+void SavewinSettings(void)
+{
+ if (Yposition == -32000)
+ Yposition = 100;
+
+ if (Xposition == -32000)
+ Xposition = 100;
+
+ g_plugin.setDword(Xpos_WIN_KEY, Xposition);
+ g_plugin.setDword(Ypos_WIN_KEY, Yposition);
+
+ g_plugin.setDword(BG_COLOR_KEY, BackgoundClr);
+ g_plugin.setDword(TXT_COLOR_KEY, TextClr);
+ g_plugin.setDword(WIN_HEIGHT_KEY, WindowHeight);
+ g_plugin.setDword(WIN_WIDTH_KEY, WindowWidth);
+
+}
+
+/*****************************************************************************/
+void ValidatePosition(HWND)
+{
+ RECT r;
+ SystemParametersInfo(SPI_GETWORKAREA, 0, &r, 0);
+
+ POINT pt = { 0, 0 };
+ HMONITOR hMonitor = MonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST); // always
+
+ MONITORINFO monitorInfo;
+ monitorInfo.cbSize = sizeof(MONITORINFO);
+ if (GetMonitorInfo(hMonitor, &monitorInfo))
+ memcpy(&r, &monitorInfo.rcMonitor, sizeof(RECT));
+
+ // /window going off right of screen*
+ if (Xposition + WindowWidth >= r.right)
+ Xposition = r.right - WindowWidth;
+
+ // window going off bottom of screen
+ if (Yposition + WindowHeight >= r.bottom)
+ Yposition = r.bottom - WindowHeight;
+
+ // window going off left of screen
+ if (Xposition >= r.right)
+ Xposition = 0;
+}
diff --git a/protocols/WebView/src/webview_getdata.cpp b/protocols/WebView/src/webview_getdata.cpp
new file mode 100644
index 0000000000..155f1be6c9
--- /dev/null
+++ b/protocols/WebView/src/webview_getdata.cpp
@@ -0,0 +1,511 @@
+/*
+* 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"
+
+int Startingup = 1;
+int AlreadyDownloading = 0;
+
+/*******************/
+void GetData(void *param)
+{
+ MCONTACT hContact = (DWORD_PTR)param;
+ int statpos = 0, dispos = 0, statposend = 0;
+ char*pos;
+ DBVARIANT dbv;
+ char tempstring[300], tempstring2[300];
+ int MallocSize = 0;
+ int DownloadSuccess = 0;
+ char*raw;
+ char truncated[MAXSIZE1];
+ char truncated2[MAXSIZE2];
+ int trunccount = 0;
+ char url[300];
+ unsigned long downloadsize = 0;
+ int AmountWspcRem = 0;
+ static char contactname[100];
+ int TherewasAlert = 0;
+ int PosButnClick = 0;
+ char tstr[128];
+ static char timestring[128];
+ int eventIndex = 0;
+ int location = 0;
+ int location2 = 0;
+
+ if (Startingup)
+ Sleep(2000);
+
+ HWND hwndDlg = (WindowList_Find(hWindowList, hContact));
+
+ Startingup = 0;
+
+ memset(&url, 0, sizeof(url));
+ memset(&contactname, 0, sizeof(contactname));
+ memset(&tempstring, 0, sizeof(tempstring));
+ memset(&tempstring2, 0, sizeof(tempstring2));
+ memset(&dbv, 0, sizeof(dbv));
+ memset(&tstr, 0, sizeof(tstr));
+ memset(&timestring, 0, sizeof(timestring));
+
+ g_plugin.setByte(hContact, STOP_KEY, 0);
+
+ if (g_plugin.getString(hContact, PRESERVE_NAME_KEY, &dbv)) {
+ if (!db_get_s(hContact, "CList", "MyHandle", &dbv)) {
+ g_plugin.setString(hContact, PRESERVE_NAME_KEY, dbv.pszVal);
+ db_free(&dbv);
+ }
+ }
+
+ if (!g_plugin.getString(hContact, PRESERVE_NAME_KEY, &dbv)) {
+ strncpy_s(contactname, _countof(contactname), dbv.pszVal, _TRUNCATE);
+ db_free(&dbv);
+ }
+
+ url[0] = '\0';
+
+ if (!Startingup)
+ g_plugin.setByte(HAS_CRASHED_KEY, 1);
+
+ if (!g_plugin.getString(hContact, START_STRING_KEY, &dbv)) {
+ strncpy_s(tempstring, _countof(tempstring), dbv.pszVal, _TRUNCATE);
+ db_free(&dbv);
+ }
+
+ if (!g_plugin.getString(hContact, END_STRING_KEY, &dbv)) {
+ strncpy_s(tempstring2, _countof(tempstring2), dbv.pszVal, _TRUNCATE);
+ db_free(&dbv);
+ }
+
+ if (!g_plugin.getString(hContact, URL_KEY, &dbv)) {
+ strncpy_s(url, _countof(url), dbv.pszVal, _TRUNCATE);
+ db_free(&dbv);
+ }
+
+ if (mir_strlen(url) < 3)
+ WErrorPopup(hContact, TranslateT("URL not supplied"));
+
+ NETLIBHTTPREQUEST nlhr = { sizeof(nlhr) };
+ nlhr.requestType = REQUEST_GET;
+ nlhr.flags = NLHRF_DUMPASTEXT;
+ nlhr.szUrl = url;
+ nlhr.headersCount = 2;
+
+ NETLIBHTTPHEADER headers[2];
+ headers[0].szName = "User-Agent";
+ headers[0].szValue = NETLIB_USER_AGENT;
+
+ headers[1].szName = "Content-Length";
+ headers[1].szValue = nullptr;
+
+ nlhr.headers = headers;
+
+ if ( g_plugin.getByte(NO_PROTECT_KEY, 0)) // disable
+ AlreadyDownloading = 0;
+
+ // //try site////
+ if (!AlreadyDownloading) { // not already downloading
+ if (IsWindowEnabled(GetDlgItem(hwndDlg, IDC_UPDATE_BUTTON)))
+ PosButnClick = 0;
+ else
+ PosButnClick = 1;
+ EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE_BUTTON), 1);
+
+ SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Download in progress, please wait..."));
+ db_set_ws(hContact, "CList", "StatusMsg", TranslateT("Updating..."));
+ g_plugin.setWord(hContact, "Status", ID_STATUS_DND); // download
+
+ NETLIBHTTPREQUEST *nlhrReply = Netlib_HttpTransaction(hNetlibUser, &nlhr);
+ if (nlhrReply) {
+ if (nlhrReply->resultCode < 200 || nlhrReply->resultCode >= 300) {
+ g_plugin.setWord(hContact, "Status", ID_STATUS_AWAY);
+
+ wchar_t *statusText = TranslateT("The server replied with a failure code");
+ SetDlgItemText(hwndDlg, IDC_STATUSBAR, statusText);
+ WErrorPopup(hContact, statusText);
+ db_set_ws(hContact, "CList", "StatusMsg", statusText);
+ }
+ if (nlhrReply->dataLength) {
+ trunccount = 0;
+ downloadsize = (ULONG)mir_strlen(nlhrReply->pData);
+ strncpy_s(truncated2, nlhrReply->pData, _TRUNCATE);
+ AlreadyDownloading = 1;
+ } // END DATELENGTH
+ } // END REPLY
+
+ if (!nlhrReply) {
+ g_plugin.setWord(hContact, "Status", ID_STATUS_NA);
+
+ wchar_t *statusText = TranslateT("The server is down or lagging.");
+ SetDlgItemText(hwndDlg, IDC_STATUSBAR, statusText);
+ WErrorPopup(hContact, statusText);
+ db_set_ws(hContact, "CList", "StatusMsg", statusText);
+ }
+
+ if (!(nlhrReply))
+ DownloadSuccess = 0;
+
+ if ((nlhrReply) && (nlhrReply->resultCode < 200 || nlhrReply->resultCode >= 300))
+ DownloadSuccess = 0;
+ else if (nlhrReply)
+ DownloadSuccess = 1;
+
+ Netlib_FreeHttpRequest(nlhrReply);
+
+ if (DownloadSuccess)
+ SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Download successful; about to process data..."));
+
+ // download successful
+ if (DownloadSuccess) {
+ // all the site
+ if (g_plugin.getByte(hContact, U_ALLSITE_KEY, 0) == 1)
+ mir_strncpy(truncated, truncated2, MAXSIZE1);
+ else { // use start and end string
+ // putting data into string
+ if (((strstr(truncated2, tempstring)) != nullptr) && ((strstr(truncated2, tempstring2)) != nullptr)) {
+ // start string
+ pos = strstr(truncated2, tempstring);
+ statpos = pos - truncated2;
+
+ memset(&pos, 0, sizeof(pos)); // XXX: looks bad.
+ // end string
+ pos = strstr(truncated2, tempstring2);
+ statposend = pos - truncated2 + (int)mir_strlen(tempstring2);
+
+ if (statpos > statposend) {
+ memset(&truncated2, ' ', statpos);
+ memset(&pos, 0, sizeof(pos)); // XXX: looks bad.
+ pos = strstr(truncated2, tempstring2);
+ statposend = pos - truncated2 + (int)mir_strlen(tempstring2);
+ }
+ if (statpos < statposend) {
+ memset(&raw, 0, sizeof(raw));
+
+ // get size for malloc
+ MallocSize = statposend - statpos;
+ raw = (char *) malloc(MallocSize + 1);
+
+ // start string
+ pos = strstr(truncated2, tempstring);
+ statpos = pos - truncated2;
+
+ // end string
+ pos = strstr(truncated2, tempstring2);
+ statposend = pos - truncated2 + (int)mir_strlen(tempstring2);
+
+ if (statpos > statposend) {
+ memset(&truncated2, ' ', statpos);
+ memset(&pos, 0, sizeof(pos)); // XXX
+ pos = strstr(truncated2, tempstring2);
+ statposend = pos - truncated2 + (int)mir_strlen(tempstring2);
+ }
+ dispos = 0;
+
+ strncpy(raw, &truncated2[statpos], MallocSize);
+ raw[MallocSize] = '\0';
+
+ trunccount = 0;
+
+ mir_strncpy(truncated, raw, MAXSIZE1);
+
+ free(raw);
+
+ DownloadSuccess = 1;
+ }
+ else if (g_plugin.getByte(hContact, U_ALLSITE_KEY, 0) == 0) {
+ wchar_t *szStatusText = TranslateT("Invalid search parameters.");
+ WErrorPopup(hContact, szStatusText);
+
+ DownloadSuccess = 0;
+ SetDlgItemText(hwndDlg, IDC_STATUSBAR, szStatusText);
+ g_plugin.setWord(hContact, "Status", ID_STATUS_AWAY);
+ }
+ } // end putting data into string
+ } // end use start and end strings
+ } // end download success
+
+ if (DownloadSuccess) { // download success
+ if (statpos == 0 && statposend == 0) {
+ if (g_plugin.getByte(hContact, U_ALLSITE_KEY, 0) == 0) {
+ wchar_t *statusText = TranslateT("Both search strings not found or strings not set.");
+ WErrorPopup(hContact, statusText);
+ db_set_ws(hContact, "CList", "StatusMsg", statusText);
+
+ DownloadSuccess = 0;
+ SetDlgItemText(hwndDlg, IDC_STATUSBAR, statusText);
+ TherewasAlert = ProcessAlerts(hContact, _T2A(statusText), contactname, contactname, 1);
+ g_plugin.setWord(hContact, "Status", ID_STATUS_AWAY);
+ }
+ }
+ } // end download success
+
+ if (DownloadSuccess) { // download success
+ char timeprefix[32];
+ char temptime1[32];
+ char timeat[16];
+ char temptime2[32];
+ char temptime[128];
+ time_t ftime;
+ struct tm *nTime;
+
+ if (!g_plugin.getString(hContact, PRESERVE_NAME_KEY, &dbv)) {
+ memset(&temptime, 0, sizeof(temptime));
+ memset(&tstr, 0, sizeof(tstr));
+ ftime = time(0);
+ nTime = localtime(&ftime);
+ // 12 hour
+ if (g_plugin.getByte(hContact, USE_24_HOUR_KEY, 0) == 0)
+ strftime(temptime, 128, "(%b %d,%I:%M %p)", nTime);
+ // 24 hour
+ if (g_plugin.getByte(hContact, USE_24_HOUR_KEY, 0) == 1)
+ strftime(temptime, 128, "(%b %d,%H:%M:%S)", nTime);
+
+ if (g_plugin.getByte(hContact, CONTACT_PREFIX_KEY, 1) == 1)
+ mir_snprintf(tstr, "%s %s", temptime, dbv.pszVal);
+ if (g_plugin.getByte(hContact, CONTACT_PREFIX_KEY, 1) == 0)
+ mir_snprintf(tstr, "%s %s", dbv.pszVal, temptime);
+ db_free(&dbv);
+ }
+ else {
+ db_get_ws(hContact, "CList", "MyHandle", &dbv);
+ memset(&temptime, 0, sizeof(temptime));
+ memset(&tstr, 0, sizeof(tstr));
+ ftime = time(0);
+ nTime = localtime(&ftime);
+ // 12 hour
+ if (g_plugin.getByte(hContact, USE_24_HOUR_KEY, 0) == 0)
+ strftime(temptime, 128, "(%b %d,%I:%M %p)", nTime);
+ // 24 hour
+ if (g_plugin.getByte(hContact, USE_24_HOUR_KEY, 0) == 1)
+ strftime(temptime, 128, "(%b %d,%H:%M:%S)", nTime);
+
+ g_plugin.setWString(hContact, PRESERVE_NAME_KEY, dbv.pwszVal);
+ if (g_plugin.getByte(hContact, CONTACT_PREFIX_KEY, 1) == 1)
+ mir_snprintf(tstr, "%s %s", temptime, dbv.pszVal);
+ if (g_plugin.getByte(hContact, CONTACT_PREFIX_KEY, 1) == 0)
+ mir_snprintf(tstr, "%s %s", dbv.pszVal, temptime);
+ db_free(&dbv);
+ }
+
+ ftime = time(0);
+ nTime = localtime(&ftime);
+
+ strncpy_s(timeprefix, _countof(timeprefix), Translate("Last updated on"), _TRUNCATE);
+ strncpy_s(timeat, _countof(timeat), Translate("at the time"), _TRUNCATE);
+ strftime(temptime1, 32, " %a, %b %d, %Y ", nTime);
+ strftime(temptime2, 32, " %I:%M %p.", nTime);
+ mir_snprintf(timestring, " %s %s%s%s", timeprefix, temptime1, timeat, temptime2);
+ } // end download success
+
+ if (DownloadSuccess) {
+ TherewasAlert = ProcessAlerts(hContact, truncated, tstr, contactname, 0);
+
+ // get range of text to be highlighted when part of change changes
+ if (TherewasAlert) {
+ // ////////////////////////
+ static char buff[MAXSIZE1];
+ char Alerttempstring[300], Alerttempstring2[300];
+
+ eventIndex = g_plugin.getByte(hContact, EVNT_INDEX_KEY, 0);
+ if (eventIndex == 2) {
+ strncpy(buff, truncated, _countof(buff));
+ Filter(buff);
+
+ if (!g_plugin.getString(hContact, ALRT_S_STRING_KEY, &dbv)) {
+ strncpy_s(Alerttempstring, _countof(Alerttempstring), dbv.pszVal, _TRUNCATE);
+ db_free(&dbv);
+ }
+ if (!g_plugin.getString(hContact, ALRT_E_STRING_KEY, &dbv)) {
+ strncpy_s(Alerttempstring2, _countof(Alerttempstring2), dbv.pszVal, _TRUNCATE);
+ db_free(&dbv);
+ }
+
+ // putting data into string
+ if (((strstr(buff, Alerttempstring)) != nullptr) && ((strstr(buff, Alerttempstring2)) != nullptr)) {
+ location = (strstr(buff, Alerttempstring)) - buff;
+ location2 = (strstr(buff, Alerttempstring2)) - buff;
+ }
+ }
+ }
+
+ if ((((strstr(truncated2, tempstring)) != nullptr) && ((strstr(truncated2, tempstring2)) != nullptr) && (g_plugin.getByte(hContact, U_ALLSITE_KEY, 0) == 0)) || (g_plugin.getByte(hContact, U_ALLSITE_KEY, 0) == 1)) {
+ RemoveTabs(truncated);
+
+ if ( g_plugin.getByte(hContact, CLEAR_DISPLAY_KEY, 0)) {
+ SendToRichEdit(hwndDlg, truncated, TextClr, BackgoundClr);
+ SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Processing data (Stage 1)"));
+
+ if (g_plugin.getByte(hContact, STOP_KEY, 1) == 1) {
+LBL_Stop: wchar_t *statusText = TranslateT("Processing data stopped by user.");
+ SetDlgItemText(hwndDlg, IDC_STATUSBAR, statusText);
+ g_plugin.setByte(hContact, STOP_KEY, 0);
+ g_plugin.setWord(hContact, "Status", ID_STATUS_ONLINE);
+ db_set_ws(hContact, "CList", "StatusMsg", statusText);
+ AlreadyDownloading = 0;
+ return;
+ }
+
+ CodetoSymbol(truncated);
+ Sleep(100); // avoid 100% CPU
+
+ SendToRichEdit(hwndDlg, truncated, TextClr, BackgoundClr);
+ SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Processing data (Stage 2)"));
+ if (g_plugin.getByte(hContact, STOP_KEY, 1) == 1)
+ goto LBL_Stop;
+
+ EraseBlock(truncated);
+ Sleep(100); // avoid 100% CPU
+
+ SendToRichEdit(hwndDlg, truncated, TextClr, BackgoundClr);
+ SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Processing data (Stage 3)"));
+ if (g_plugin.getByte(hContact, STOP_KEY, 1) == 1)
+ goto LBL_Stop;
+
+ FastTagFilter(truncated);
+ Sleep(100); // avoid 100% CPU
+
+ SendToRichEdit(hwndDlg, truncated, TextClr, BackgoundClr);
+ SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Processing data (Stage 4)"));
+ if (g_plugin.getByte(hContact, STOP_KEY, 1) == 1)
+ goto LBL_Stop;
+
+ NumSymbols(truncated);
+ Sleep(100); // avoid 100% CPU
+
+ SendToRichEdit(hwndDlg, truncated, TextClr, BackgoundClr);
+ SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Processing data (Stage 5)"));
+ if (g_plugin.getByte(hContact, STOP_KEY, 1) == 1)
+ goto LBL_Stop;
+
+ EraseSymbols(truncated);
+ Sleep(100); // avoid 100% CPU
+
+ SendToRichEdit(hwndDlg, truncated, TextClr, BackgoundClr);
+ SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Processing data (Stage 6)"));
+
+ AmountWspcRem = g_plugin.getByte(hContact, RWSPACE_KEY, 0);
+ if (g_plugin.getByte(hContact, STOP_KEY, 1) == 1)
+ goto LBL_Stop;
+
+ RemoveInvis(truncated, AmountWspcRem);
+ Sleep(100); // avoid 100% CPU
+
+ SendToRichEdit(hwndDlg, truncated, TextClr, BackgoundClr);
+ SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Processing data (Stage 7)"));
+ if (g_plugin.getByte(hContact, STOP_KEY, 1) == 1)
+ goto LBL_Stop;
+
+ Removewhitespace(truncated);
+
+ SendToRichEdit(hwndDlg, truncated, TextClr, BackgoundClr);
+ SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Processing data (Stage 8)"));
+
+ //data in popup
+ if (TherewasAlert)
+ if ( g_plugin.getByte(DATA_POPUP_KEY, 0))
+ WAlertPopup(hContact, _A2T(truncated));
+
+ if (g_plugin.getByte(hContact, STOP_KEY, 1) == 1)
+ goto LBL_Stop;
+
+ // removed any excess characters at the end.
+ if ((truncated[mir_strlen(truncated) - 1] == truncated[mir_strlen(truncated) - 2]) && (truncated[mir_strlen(truncated) - 2] == truncated[mir_strlen(truncated) - 3])) {
+ int counterx = 0;
+
+ while (true) {
+ counterx++;
+ if (truncated[mir_strlen(truncated) - counterx] != truncated[mir_strlen(truncated) - 1]) {
+ truncated[(mir_strlen(truncated) - counterx) + 2] = '\0';
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ if (TherewasAlert) {
+ g_plugin.setWord(hContact, "Status", ID_STATUS_OCCUPIED);
+ db_set_ws(hContact, "CList", "StatusMsg", TranslateT("Alert!"));
+ }
+ else {
+ g_plugin.setWord(hContact, "Status", ID_STATUS_ONLINE);
+ db_set_ws(hContact, "CList", "StatusMsg", TranslateT("Online"));
+ }
+ }
+
+ if (g_plugin.getByte(hContact, U_ALLSITE_KEY, 0) == 0) {
+ if (statpos > statposend)
+ DownloadSuccess = 0;
+ else if (statpos == 0 && statposend == 0)
+ DownloadSuccess = 0;
+ else
+ DownloadSuccess = 1;
+ }
+
+ AlreadyDownloading = 0;
+ } // end not already downloading
+
+ if (AlreadyDownloading)
+ SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("A site is already downloading, try again in a moment."));
+
+ if (DownloadSuccess) { // download success
+ char BytesString[128];
+
+ // update window if the update only on alert option isn't ticked or
+ // there was an alert or the update button was clicked
+ if ((!(g_plugin.getByte(UPDATE_ONALERT_KEY, 0))) || (TherewasAlert == 1) || (PosButnClick == 1)) {
+ SendToRichEdit(hwndDlg, truncated, TextClr, BackgoundClr);
+
+ if (TherewasAlert) {
+ // highlight text when part of change changes
+ if (eventIndex == 2) {
+ CHARRANGE sel2 = {location, location2};
+
+ SendDlgItemMessage(hwndDlg, IDC_DATA, EM_EXSETSEL, 0, (LPARAM)&sel2);
+ SetFocus(GetDlgItem(hwndDlg, IDC_DATA));
+
+ DWORD HiBackgoundClr = g_plugin.getDword(BG_COLOR_KEY, Def_color_bg);
+ DWORD HiTextClr = g_plugin.getDword(TXT_COLOR_KEY, Def_color_txt);
+
+ CHARFORMAT2 Format;
+ memset(&Format, 0, sizeof(Format));
+ Format.cbSize = sizeof(Format);
+ Format.dwMask = CFM_BOLD | CFM_COLOR | CFM_BACKCOLOR;
+ Format.dwEffects = CFE_BOLD;
+ Format.crBackColor = ((~HiBackgoundClr) & 0x00ffffff);
+ Format.crTextColor = ((~HiTextClr) & 0x00ffffff);
+ SendDlgItemMessage(hwndDlg, IDC_DATA, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&Format);
+ }
+ }
+
+ SetDlgItemTextA(hwndDlg, IDC_STATUSBAR, timestring);
+ sprintf(BytesString, "%s: %d | %s: %lu", (Translate("Bytes in display")), (GetWindowTextLength(GetDlgItem(hwndDlg, IDC_DATA))), (Translate("Bytes downloaded")), downloadsize);
+
+ SendDlgItemMessage(hwndDlg, IDC_STATUSBAR, SB_SETTEXT, 1, (LPARAM)BytesString);
+ }
+ else SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Alert test conditions not met; press the refresh button to view content."));
+ }
+ EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE_BUTTON), 1);
+
+ if (!Startingup)
+ g_plugin.setByte(HAS_CRASHED_KEY, 0);
+}
diff --git a/protocols/WebView/src/webview_opts.cpp b/protocols/WebView/src/webview_opts.cpp
new file mode 100644
index 0000000000..0c51759b42
--- /dev/null
+++ b/protocols/WebView/src/webview_opts.cpp
@@ -0,0 +1,1265 @@
+/*
+* 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"
+
+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") };
+
+#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) {
+ int i = SendMessage((HWND)lParam, CB_ADDSTRING, 0, (LPARAM)lpelfe->elfScript);
+
+ SendMessage((HWND)lParam, CB_SETITEMDATA, i, lpelfe->elfLogFont.lfCharSet);
+ }
+ return TRUE;
+}
+
+/*****************************************************************************/
+// copied and modified from NewStatusNotify
+INT_PTR CALLBACK DlgPopUpOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+
+ char str[512];
+ DWORD BGColour = 0;
+ DWORD TextColour = 0;
+ DWORD delay = 0;
+ static int test = 0;
+
+ switch (msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hdlg);
+
+ delay = g_plugin.getDword(POP_DELAY_KEY, 0);
+
+ // setting popup delay option
+ _itoa(delay, str, 10);
+ SetDlgItemTextA(hdlg, IDC_DELAY, str);
+
+ BGColour = g_plugin.getDword(POP_BG_CLR_KEY, Def_color_bg);
+ TextColour = g_plugin.getDword(POP_TXT_CLR_KEY, Def_color_txt);
+
+ // Colours. First step is configuring the colours.
+ SendDlgItemMessage(hdlg, IDC_POP_BGCOLOUR, CPM_SETCOLOUR, 0, BGColour);
+ SendDlgItemMessage(hdlg, IDC_POP_TEXTCOLOUR, CPM_SETCOLOUR, 0, TextColour);
+ // Second step is disabling them if we want to use default Windows
+ // ones.
+ CheckDlgButton(hdlg, IDC_POP_USEWINCOLORS, g_plugin.getByte(POP_USEWINCLRS_KEY, 0) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hdlg, IDC_POP_USESAMECOLORS, g_plugin.getByte(POP_USESAMECLRS_KEY, 1) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hdlg, IDC_POP_USECUSTCOLORS, g_plugin.getByte(POP_USECUSTCLRS_KEY, 0) ? BST_CHECKED : BST_UNCHECKED);
+
+ if (IsDlgButtonChecked(hdlg, IDC_POP_USEWINCOLORS) || IsDlgButtonChecked(hdlg, IDC_POP_USESAMECOLORS)) {
+ EnableWindow(GetDlgItem(hdlg, IDC_POP_BGCOLOUR), 0);
+ EnableWindow(GetDlgItem(hdlg, IDC_POP_TEXTCOLOUR), 0);
+ }
+
+ CheckDlgButton(hdlg, IDC_LCLK_WINDOW, g_plugin.getByte(LCLK_WINDOW_KEY, 0) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hdlg, IDC_LCLK_WEB_PGE, g_plugin.getByte(LCLK_WEB_PGE_KEY, 0) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hdlg, IDC_LCLK_DISMISS, g_plugin.getByte(LCLK_DISMISS_KEY, 1) ? BST_CHECKED : BST_UNCHECKED);
+
+ CheckDlgButton(hdlg, IDC_RCLK_WINDOW, g_plugin.getByte(RCLK_WINDOW_KEY, 0) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hdlg, IDC_RCLK_WEB_PGE, g_plugin.getByte(RCLK_WEB_PGE_KEY, 1) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hdlg, IDC_RCLK_DISMISS, g_plugin.getByte(RCLK_DISMISS_KEY, 0) ? BST_CHECKED : BST_UNCHECKED);
+ return TRUE;
+
+ case WM_COMMAND:
+ // enable the "apply" button
+ if (HIWORD(wParam) == BN_CLICKED && GetFocus() == (HWND)lParam)
+ SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
+ // These are simple clicks: we don't save, but we tell the Options Page
+ // to enable the "Apply" button.
+ switch (LOWORD(wParam)) {
+ case IDC_POP_BGCOLOUR: // Fall through
+ case IDC_POP_TEXTCOLOUR:
+ // select new colors
+ if (HIWORD(wParam) == CPN_COLOURCHANGED)
+ SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
+ break;
+
+ case IDC_POP_USESAMECOLORS:
+ // use same color as data window - enable/disable color selection
+ // controls
+ EnableWindow(GetDlgItem(hdlg, IDC_POP_BGCOLOUR), !((BYTE)IsDlgButtonChecked(hdlg, IDC_POP_USESAMECOLORS)));
+ EnableWindow(GetDlgItem(hdlg, IDC_POP_TEXTCOLOUR), !((BYTE)IsDlgButtonChecked(hdlg, IDC_POP_USESAMECOLORS)));
+ SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
+ break;
+
+ case IDC_POP_USEWINCOLORS:
+ // use window color - enable/disable color selection controls
+ EnableWindow(GetDlgItem(hdlg, IDC_POP_BGCOLOUR), !((BYTE)IsDlgButtonChecked(hdlg, IDC_POP_USEWINCOLORS)));
+ EnableWindow(GetDlgItem(hdlg, IDC_POP_TEXTCOLOUR), !((BYTE)IsDlgButtonChecked(hdlg, IDC_POP_USEWINCOLORS)));
+ SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
+ break;
+
+ case IDC_POP_USECUSTCOLORS:
+ EnableWindow(GetDlgItem(hdlg, IDC_POP_BGCOLOUR), ((BYTE)IsDlgButtonChecked(hdlg, IDC_POP_USECUSTCOLORS)));
+ EnableWindow(GetDlgItem(hdlg, IDC_POP_TEXTCOLOUR), ((BYTE)IsDlgButtonChecked(hdlg, IDC_POP_USECUSTCOLORS)));
+ break;
+
+ case IDC_PD1:
+ SetDlgItemText(hdlg, IDC_DELAY, L"0");
+ break;
+ case IDC_PD2:
+ // Popup delay = permanent
+ SetDlgItemText(hdlg, IDC_DELAY, L"-1");
+ break;
+
+ case IDC_DELAY:
+ if (HIWORD(wParam) == EN_CHANGE)
+ test++;
+ if (test > 1) {
+ //CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD3);
+ SendMessage(GetParent(hdlg), PSM_CHANGED, 0, 0);
+ }
+ break;
+
+ case IDC_PREVIEW:
+ wchar_t str3[512];
+ POPUPDATAW ppd = { 0 };
+
+ GetDlgItemText(hdlg, IDC_DELAY, str3, _countof(str3));
+
+ if (IsDlgButtonChecked(hdlg, IDC_POP_USECUSTCOLORS)) {
+ BGColour = (SendDlgItemMessage(hdlg, IDC_POP_BGCOLOUR, CPM_GETCOLOUR, 0, 0));
+ TextColour = (SendDlgItemMessage(hdlg, IDC_POP_TEXTCOLOUR, CPM_GETCOLOUR, 0, 0));
+ }
+ if (IsDlgButtonChecked(hdlg, IDC_POP_USEWINCOLORS)) {
+ BGColour = GetSysColor(COLOR_BTNFACE);
+ TextColour = GetSysColor(COLOR_WINDOWTEXT);
+ }
+ if (IsDlgButtonChecked(hdlg, IDC_POP_USESAMECOLORS)) {
+ BGColour = BackgoundClr;
+ TextColour = TextClr;
+ }
+ ppd.lchContact = NULL;
+ mir_wstrcpy(ppd.lpwzContactName, _A2W(MODULENAME));
+ ppd.lchIcon = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_SITE));
+ mir_wstrcpy(ppd.lpwzText, TranslateT("This is a preview popup."));
+ ppd.colorBack = BGColour;
+ ppd.colorText = TextColour;
+ ppd.PluginWindowProc = nullptr;
+ ppd.iSeconds = _wtol(str3);
+ // display popups
+ PUAddPopupW(&ppd);
+ }
+ break;
+
+ case WM_NOTIFY: // Here we have pressed either the OK or the APPLY button.
+ switch (((LPNMHDR)lParam)->code) {
+ case PSN_APPLY:
+ int popupdelayval = 0;
+ wchar_t str2[512];
+ GetDlgItemText(hdlg, IDC_DELAY, str2, _countof(str2));
+
+ popupdelayval = _wtol(str2);
+ g_plugin.setDword(POP_DELAY_KEY, popupdelayval);
+
+ g_plugin.setByte(LCLK_WINDOW_KEY, (BYTE)IsDlgButtonChecked(hdlg, IDC_LCLK_WINDOW));
+ g_plugin.setByte(LCLK_WEB_PGE_KEY, (BYTE)IsDlgButtonChecked(hdlg, IDC_LCLK_WEB_PGE));
+ g_plugin.setByte(LCLK_DISMISS_KEY, (BYTE)IsDlgButtonChecked(hdlg, IDC_LCLK_DISMISS));
+
+ g_plugin.setByte(RCLK_WINDOW_KEY, (BYTE)IsDlgButtonChecked(hdlg, IDC_RCLK_WINDOW));
+ g_plugin.setByte(RCLK_WEB_PGE_KEY, (BYTE)IsDlgButtonChecked(hdlg, IDC_RCLK_WEB_PGE));
+ g_plugin.setByte(RCLK_DISMISS_KEY, (BYTE)IsDlgButtonChecked(hdlg, IDC_RCLK_DISMISS));
+
+ g_plugin.setByte(POP_USECUSTCLRS_KEY, (BYTE)IsDlgButtonChecked(hdlg, IDC_POP_USECUSTCOLORS));
+ g_plugin.setByte(POP_USEWINCLRS_KEY, (BYTE)IsDlgButtonChecked(hdlg, IDC_POP_USEWINCOLORS));
+ g_plugin.setByte(POP_USESAMECLRS_KEY, (BYTE)IsDlgButtonChecked(hdlg, IDC_POP_USESAMECOLORS));
+
+ BGColour = (SendDlgItemMessage(hdlg, IDC_POP_BGCOLOUR, CPM_GETCOLOUR, 0, 0));
+ TextColour = (SendDlgItemMessage(hdlg, IDC_POP_TEXTCOLOUR, CPM_GETCOLOUR, 0, 0));
+
+ g_plugin.setDword(POP_BG_CLR_KEY, BGColour);
+ g_plugin.setDword(POP_TXT_CLR_KEY, TextColour);
+
+ test = 0;
+ return TRUE;
+ }
+ break;
+ }
+ 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)
+{
+ 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;
+
+ switch (uMsg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+ {
+ test = 0;
+
+ SendDlgItemMessage(hwndDlg, IDC_SPIN1, UDM_SETRANGE, 0, MAKELONG(999, 0));
+ SendDlgItemMessage(hwndDlg, IDC_SPIN2, UDM_SETRANGE, 0, MAKELONG(120, 0));
+
+ SetDlgItemInt(hwndDlg, IDC_TIME, g_plugin.getDword(REFRESH_KEY, TIME), FALSE);
+ SetDlgItemInt(hwndDlg, IDC_START_DELAY, g_plugin.getWord(START_DELAY_KEY, 0), FALSE);
+
+ 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);
+ CheckDlgButton(hwndDlg, IDC_HIDE_STATUS_ICON, g_plugin.getByte(HIDE_STATUS_ICON_KEY, 0) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_FONT_BOLD, g_plugin.getByte(FONT_BOLD_KEY, 0) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_FONT_ITALIC, g_plugin.getByte(FONT_ITALIC_KEY, 0) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_FONT_UNDERLINE, g_plugin.getByte(FONT_UNDERLINE_KEY, 0) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_ERROR_POPUP, g_plugin.getByte(ERROR_POPUP_KEY, 0) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_UPDATE_ONALERT, g_plugin.getByte(UPDATE_ONALERT_KEY, 0) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_SAVE_INDIVID_POS, g_plugin.getByte(SAVE_INDIVID_POS_KEY, 0) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_NO_PROTECT, g_plugin.getByte(NO_PROTECT_KEY, 0) ? BST_CHECKED : BST_UNCHECKED);
+ CheckDlgButton(hwndDlg, IDC_DATAPOPUP, g_plugin.getByte(DATA_POPUP_KEY, 0) ? BST_CHECKED : BST_UNCHECKED);
+
+ if (!g_plugin.getWString(FONT_FACE_KEY, &dbv)) {
+ SetDlgItemText(hwndDlg, IDC_TYPEFACE, dbv.pwszVal);
+ db_free(&dbv);
+ }
+ else SetDlgItemText(hwndDlg, IDC_TYPEFACE, Def_font_face);
+
+ for (int i = 0; i < _countof(fontSizes); i++)
+ SendDlgItemMessage(hwndDlg, IDC_FONTSIZE, CB_ADDSTRING, 0, (LPARAM)fontSizes[i]);
+
+ SendMessage(hwndDlg, M_FILLSCRIPTCOMBO, wParam, 0);
+
+ SetDlgItemInt(hwndDlg, IDC_FONTSIZE, g_plugin.getByte(FONT_SIZE_KEY, 14), FALSE);
+
+ EnableWindow(GetDlgItem(hwndDlg, IDC_FIND_BUTTON), 0);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_BUTTON), 0);
+
+ SendDlgItemMessage(hwndDlg, IDC_BGCOLOR, CPM_SETCOLOUR, 0, (BackgoundClr));
+ SendDlgItemMessage(hwndDlg, IDC_TXTCOLOR, CPM_SETCOLOUR, 0, (TextClr));
+
+ /*
+ * record bg value for later comparison
+ */
+ oldcolor = BackgoundClr;
+
+ if (g_plugin.getByte(SUPPRESS_ERR_KEY, 0)) {
+ CheckDlgButton(hwndDlg, IDC_SUPPRESS, BST_CHECKED);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_ERROR_POPUP), 0);
+ }
+ else {
+ CheckDlgButton(hwndDlg, IDC_SUPPRESS, BST_UNCHECKED);
+ if ((ServiceExists(MS_POPUP_ADDPOPUPW) != 0))
+ EnableWindow(GetDlgItem(hwndDlg, IDC_ERROR_POPUP), 1);
+ }
+
+ if (ServiceExists(MS_POPUP_ADDPOPUPW) == 0)
+ EnableWindow(GetDlgItem(hwndDlg, IDC_ERROR_POPUP), 0);
+
+ if (g_plugin.getByte(UPDATE_ONSTART_KEY, 0)) {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_START_DELAY), 1);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_SPIN2), 1);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_STARTDELAYTXT), 1);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_STDELAYSECTXT), 1);
+ }
+ else {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_START_DELAY), 0);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_SPIN2), 0);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_STARTDELAYTXT), 0);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_STDELAYSECTXT), 0);
+ }
+ }
+ break;
+
+ case M_FILLSCRIPTCOMBO: // fill the script combo box and set the
+ // selection to the value for fontid wParam
+
+ {
+ LOGFONT lf = { 0 };
+ int i;
+ HDC hdc = GetDC(hwndDlg);
+
+ lf.lfCharSet = DEFAULT_CHARSET;
+ GetDlgItemText(hwndDlg, IDC_TYPEFACE, lf.lfFaceName, _countof(lf.lfFaceName));
+ lf.lfPitchAndFamily = 0;
+ SendDlgItemMessage(hwndDlg, IDC_SCRIPT, CB_RESETCONTENT, 0, 0);
+ EnumFontFamiliesEx(hdc, &lf, (FONTENUMPROC)EnumFontScriptsProc, (LPARAM)GetDlgItem(hwndDlg, IDC_SCRIPT), 0);
+ ReleaseDC(hwndDlg, hdc);
+ for (i = SendDlgItemMessage(hwndDlg, IDC_SCRIPT, CB_GETCOUNT, 0, 0) - 1; i >= 0; i--) {
+ if (SendDlgItemMessage(hwndDlg, IDC_SCRIPT, CB_GETITEMDATA, i, 0) == (BYTE)((g_plugin.getByte(FONT_SCRIPT_KEY, 0)))) {
+ SendDlgItemMessage(hwndDlg, IDC_SCRIPT, CB_SETCURSEL, i, 0);
+ break;
+ }
+ }
+ if (i < 0)
+ SendDlgItemMessage(hwndDlg, IDC_SCRIPT, CB_SETCURSEL, 0, 0);
+ }
+ break;
+
+ case WM_COMMAND:
+ if (HIWORD(wParam) == BN_CLICKED && GetFocus() == (HWND)lParam)
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+
+ switch (LOWORD(wParam)) {
+ case IDC_TXTCOLOR:
+ TextClr = SendDlgItemMessage(hwndDlg, IDC_TXTCOLOR, CPM_GETCOLOUR, 0, 0);
+ g_plugin.setDword(TXT_COLOR_KEY, TextClr);
+ if (HIWORD(wParam) == CPN_COLOURCHANGED) {
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ TxtclrLoop();
+ }
+ break;
+
+ case IDC_BGCOLOR:
+ BackgoundClr = SendDlgItemMessage(hwndDlg, IDC_BGCOLOR, CPM_GETCOLOUR, 0, 0);
+ g_plugin.setDword(BG_COLOR_KEY, BackgoundClr);
+ if (HIWORD(wParam) == CPN_COLOURCHANGED) {
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ BGclrLoop();
+ }
+ break;
+
+ case IDC_HIDE_STATUS_ICON:
+ ShowWindow(GetDlgItem(hwndDlg, IDC_RESTART), SW_SHOW);
+ break;
+
+ case IDC_SUPPRESS:
+ if ((ServiceExists(MS_POPUP_ADDPOPUPW) != 0))
+ EnableWindow(GetDlgItem(hwndDlg, IDC_ERROR_POPUP), (!(IsDlgButtonChecked(hwndDlg, IDC_SUPPRESS))));
+ break;
+
+ case IDC_UPDATE_ONSTART:
+ EnableWindow(GetDlgItem(hwndDlg, IDC_START_DELAY), ((IsDlgButtonChecked(hwndDlg, IDC_UPDATE_ONSTART))));
+ EnableWindow(GetDlgItem(hwndDlg, IDC_SPIN2), ((IsDlgButtonChecked(hwndDlg, IDC_UPDATE_ONSTART))));
+ EnableWindow(GetDlgItem(hwndDlg, IDC_STARTDELAYTXT), ((IsDlgButtonChecked(hwndDlg, IDC_UPDATE_ONSTART))));
+ 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:
+ case IDC_SCRIPT:
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+
+ case IDC_START_DELAY:
+ if (HIWORD(wParam) == EN_CHANGE)
+ test++;
+ if (test > 1)
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+
+ case IDC_TIME:
+ if (HIWORD(wParam) == EN_CHANGE)
+ test2++;
+ if (test2 > 2)
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+ } // end WM_COMMAND
+ break;
+
+ case WM_DESTROY:
+ test = 0;
+ test2 = 0;
+ break;
+
+ 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));
+ g_plugin.setByte(HIDE_STATUS_ICON_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_HIDE_STATUS_ICON));
+ g_plugin.setByte(FONT_BOLD_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_FONT_BOLD));
+ g_plugin.setByte(FONT_ITALIC_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_FONT_ITALIC));
+ g_plugin.setByte(FONT_UNDERLINE_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_FONT_UNDERLINE));
+ g_plugin.setByte(UPDATE_ONALERT_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_UPDATE_ONALERT));
+ g_plugin.setByte(SAVE_INDIVID_POS_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SAVE_INDIVID_POS));
+ g_plugin.setByte(NO_PROTECT_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_NO_PROTECT));
+ g_plugin.setByte(DATA_POPUP_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_DATAPOPUP));
+
+ wchar_t str[100];
+ GetDlgItemText(hwndDlg, IDC_TYPEFACE, str, _countof(str));
+ g_plugin.setWString(FONT_FACE_KEY, str);
+
+ g_plugin.setByte(FONT_SIZE_KEY, (GetDlgItemInt(hwndDlg, IDC_FONTSIZE, nullptr, FALSE)));
+ g_plugin.setByte(FONT_SCRIPT_KEY, ((BYTE)SendDlgItemMessage(hwndDlg, IDC_SCRIPT, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_SCRIPT, CB_GETCURSEL, 0, 0), 0)));
+
+ g_plugin.setByte(ERROR_POPUP_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_ERROR_POPUP));
+
+ timerval = GetDlgItemInt(hwndDlg, IDC_TIME, nullptr, FALSE);
+ g_plugin.setDword(REFRESH_KEY, timerval);
+ g_plugin.setDword(COUNTDOWN_KEY, timerval);
+
+
+ delaytime = GetDlgItemInt(hwndDlg, IDC_START_DELAY, nullptr, FALSE);
+ g_plugin.setDword(START_DELAY_KEY, delaytime);
+
+ BackgoundClr = (SendDlgItemMessage(hwndDlg, IDC_BGCOLOR, CPM_GETCOLOUR, 0, 0));
+ TextClr = (SendDlgItemMessage(hwndDlg, IDC_TXTCOLOR, CPM_GETCOLOUR, 0, 0));
+
+ if ((g_plugin.getDword(REFRESH_KEY, 0) != 0)) {
+ KillTimer(nullptr, timerId);
+ KillTimer(nullptr, Countdown);
+ timerId = SetTimer(nullptr, 0, ((g_plugin.getDword(REFRESH_KEY, 0)) * MINUTE), timerfunc);
+ Countdown = SetTimer(nullptr, 0, MINUTE, Countdownfunc);
+ }
+ if ((g_plugin.getDword(REFRESH_KEY, 0) == 0)) {
+ KillTimer(nullptr, timerId);
+ KillTimer(nullptr, Countdown);
+ }
+ test = 0;
+ }
+ break; // end apply
+ }
+
+ return 0;
+}
diff --git a/protocols/WebView/src/webview_services.cpp b/protocols/WebView/src/webview_services.cpp
new file mode 100644
index 0000000000..4957120181
--- /dev/null
+++ b/protocols/WebView/src/webview_services.cpp
@@ -0,0 +1,458 @@
+/*
+* 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 int searchId = -1;
+
+/*****************************************************************************/
+static char szInvalidChars[] = { '\\', '/', ':', '*', '?', '\"', '<', '>', '|' };
+
+int DBSettingChanged(WPARAM wParam, LPARAM lParam)
+{
+ // We can't upload changes to NULL contact
+ MCONTACT hContact = wParam;
+ if (hContact == NULL)
+ return 0;
+
+ DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *)lParam;
+ if (!strcmp(cws->szModule, "CList")) {
+ int invalidpresent = 0;
+
+ char *szProto = GetContactProto(hContact);
+ if (szProto == nullptr || strcmp(szProto, MODULENAME))
+ return 0;
+
+ // A contact is renamed
+ if (!strcmp(cws->szSetting, "MyHandle")) {
+ ptrW oldName(g_plugin.getWStringA(hContact, PRESERVE_NAME_KEY));
+ if (oldName == NULL)
+ return 0;
+
+ wchar_t nick[100];
+ ptrW oldnick(db_get_wsa(hContact, "CList", "MyHandle"));
+ if (oldnick != NULL)
+ wcsncpy_s(nick, oldnick, _TRUNCATE);
+ else
+ nick[0] = 0;
+
+ for (int i = 0; i < _countof(szInvalidChars); i++) {
+ wchar_t *p = wcschr(nick, szInvalidChars[i]);
+ if (p != nullptr) {
+ WErrorPopup((UINT_PTR)"ERROR", TranslateT("Invalid symbol present in contact name."));
+ *p = '_';
+ invalidpresent = 1;
+ }
+ }
+
+ if (invalidpresent) {
+ srand((unsigned)time(0));
+ wchar_t ranStr[7];
+ _itow((int)10000 * rand() / (RAND_MAX + 1.0), ranStr, 10);
+ mir_wstrcat(nick, ranStr);
+ }
+
+ if (wcschr(nick, '(') == nullptr) {
+ g_plugin.setWString(hContact, PRESERVE_NAME_KEY, nick);
+ g_plugin.setWString(hContact, "Nick", nick);
+ db_set_ws(hContact, "CList", "MyHandle", nick);
+ }
+
+ // TEST GET NAME FOR CACHE
+ wchar_t cachepath[MAX_PATH], cachedirectorypath[MAX_PATH];
+ GetModuleFileName(g_plugin.getInst(), cachepath, _countof(cachepath));
+ wchar_t *cacheend = wcsrchr(cachepath, '\\');
+ cacheend++;
+ *cacheend = '\0';
+ mir_snwprintf(cachedirectorypath, L"%s" _A2W(MODULENAME) L"cache\\", cachepath);
+ CreateDirectory(cachedirectorypath, nullptr);
+
+ wchar_t newcachepath[MAX_PATH + 50], renamedcachepath[MAX_PATH + 50];
+ mir_snwprintf(newcachepath, L"%s" _A2W(MODULENAME) L"cache\\%s.txt", cachepath, oldName);
+ mir_snwprintf(renamedcachepath, L"%s" _A2W(MODULENAME) L"cache\\%s.txt", cachepath, nick);
+
+ // file exists?
+ if (_waccess(newcachepath, 0) != -1) {
+ FILE *pcachefile = _wfopen(newcachepath, L"r");
+ if (pcachefile != nullptr) {
+ fclose(pcachefile);
+ if (mir_wstrcmp(newcachepath, renamedcachepath)) {
+ MoveFile(newcachepath, renamedcachepath);
+ g_plugin.setWString(hContact, CACHE_FILE_KEY, renamedcachepath);
+ }
+ }
+ }
+ }
+ }
+ return 0;
+}
+
+/*****************************************************************************/
+int SiteDeleted(WPARAM wParam, LPARAM)
+{
+ MCONTACT hContact = wParam;
+ if (mir_strcmp(GetContactProto(hContact), MODULENAME))
+ return 0;
+
+ ptrW contactName(g_plugin.getWStringA(hContact, PRESERVE_NAME_KEY));
+
+ // TEST GET NAME FOR CACHE
+ wchar_t cachepath[MAX_PATH], cachedirectorypath[MAX_PATH], newcachepath[MAX_PATH + 50];
+ GetModuleFileName(g_plugin.getInst(), cachepath, _countof(cachepath));
+ wchar_t *cacheend = wcsrchr(cachepath, '\\');
+ cacheend++;
+ *cacheend = '\0';
+
+ mir_snwprintf(cachedirectorypath, L"%s" _A2W(MODULENAME) L"cache\\", cachepath);
+ CreateDirectory(cachedirectorypath, nullptr);
+ mir_snwprintf(newcachepath, L"%s" _A2W(MODULENAME) L"cache\\%s.txt", cachepath, contactName);
+ // file exists?
+ if (_waccess(newcachepath, 0) != -1) {
+ FILE *pcachefile = _wfopen(newcachepath, L"r");
+ if (pcachefile != nullptr) {
+ fclose(pcachefile);
+ DeleteFile(newcachepath);
+ g_plugin.setString(hContact, CACHE_FILE_KEY, "");
+ }
+ }
+ return 0;
+}
+
+/*****************************************************************************/
+INT_PTR OpenCacheDir(WPARAM, LPARAM)
+{
+ //GET NAME FOR CACHE
+ wchar_t cachepath[MAX_PATH], cachedirectorypath[MAX_PATH];
+ GetModuleFileName(g_plugin.getInst(), cachepath, _countof(cachepath));
+ wchar_t *cacheend = wcsrchr(cachepath, '\\');
+ cacheend++;
+ *cacheend = '\0';
+
+ mir_snwprintf(cachedirectorypath, L"%s" _A2W(MODULENAME) L"cache\\%s", cachepath, cacheend);
+
+ if (_waccess(cachedirectorypath, 0) != 0)
+ WErrorPopup((UINT_PTR)"ERROR", TranslateT("Cache folder does not exist."));
+ else
+ ShellExecute(nullptr, L"open", cachedirectorypath, nullptr, nullptr, SW_SHOWNORMAL);
+ return 0;
+}
+
+/*****************************************************************************/
+INT_PTR PingWebsiteMenuCommand(WPARAM wParam, LPARAM)
+{
+ FILE *pfile = fopen("psite.bat", "r");
+ if (pfile == nullptr) {
+ WErrorPopup((UINT_PTR)"ERROR", TranslateT("Missing \"psite.bat\" file."));
+ return 0;
+ }
+
+ ptrW url(g_plugin.getWStringA(wParam, "URL"));
+ if (url == NULL)
+ return 0;
+
+ wchar_t Cnick[200], *Oldnick;
+ wcsncpy(Cnick, url, _countof(Cnick));
+ if ((Oldnick = wcsstr(Cnick, L"://")) != nullptr)
+ Oldnick += 3;
+ else
+ Oldnick = Cnick;
+
+ wchar_t *Nend = wcschr(Oldnick, '/');
+ if (Nend) *Nend = '\0';
+
+ ShellExecute(nullptr, L"open", L"psite.bat", Oldnick, nullptr, SW_HIDE);
+ return 0;
+}
+
+/*****************************************************************************/
+INT_PTR StpPrcssMenuCommand(WPARAM wParam, LPARAM)
+{
+ g_plugin.setByte(wParam, STOP_KEY, 1);
+ return 0;
+}
+
+//=======================================================
+// GetCaps
+// =======================================================
+
+INT_PTR GetCaps(WPARAM wParam, LPARAM)
+{
+ switch (wParam) {
+ case PFLAGNUM_1:
+ return PF1_BASICSEARCH | PF1_ADDSEARCHRES | PF1_VISLIST;
+ case PFLAGNUM_2:
+ return g_plugin.getByte(HIDE_STATUS_ICON_KEY, 0) ? 0 : (PF2_ONLINE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_LIGHTDND | PF2_HEAVYDND);
+ case PFLAGNUM_3:
+ return 0;
+ case PFLAGNUM_4:
+ return PF4_NOCUSTOMAUTH | PF4_NOAUTHDENYREASON;
+ case PFLAGNUM_5:
+ return PF2_INVISIBLE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_LIGHTDND | PF2_HEAVYDND | PF2_FREECHAT | PF2_OUTTOLUNCH | PF2_ONTHEPHONE;
+ case PFLAG_UNIQUEIDTEXT:
+ return (INT_PTR)Translate("Site URL");
+ default:
+ return 0;
+ }
+}
+
+// =======================================================
+// GetName
+// =======================================================
+
+INT_PTR GetName(WPARAM wParam, LPARAM lParam)
+{
+ mir_strncpy((char*)lParam, MODULENAME, wParam);
+ return 0;
+}
+
+//=======================================================
+// SetStatus
+// =======================================================
+
+INT_PTR SetStatus(WPARAM wParam, LPARAM)
+{
+ int oldStatus = bpStatus;
+
+ if (wParam == ID_STATUS_ONLINE)
+ wParam = ID_STATUS_ONLINE;
+ else if (wParam == ID_STATUS_OFFLINE)
+ wParam = ID_STATUS_OFFLINE;
+ else
+ wParam = ID_STATUS_ONLINE;
+
+ // broadcast the message
+ bpStatus = wParam;
+
+ ProtoBroadcastAck(MODULENAME, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, wParam);
+
+ // Make sure no contact has offline status for any reason on first time run
+ if (g_plugin.getByte("FirstTime", 100) == 100) {
+ for (auto &hContact : Contacts(MODULENAME))
+ g_plugin.setWord(hContact, "Status", ID_STATUS_ONLINE);
+
+ g_plugin.setByte("FirstTime", 1);
+ }
+
+ g_plugin.setByte(OFFLINE_STATUS, bpStatus == ID_STATUS_OFFLINE);
+ return 0;
+}
+
+//=======================================================
+// GetStatus
+// =======================================================
+
+INT_PTR GetStatus(WPARAM, LPARAM)
+{
+ if (bpStatus == ID_STATUS_ONLINE)
+ return ID_STATUS_ONLINE;
+ if (bpStatus == ID_STATUS_AWAY)
+ return ID_STATUS_AWAY;
+ if (bpStatus == ID_STATUS_NA)
+ return ID_STATUS_NA;
+ if (bpStatus == ID_STATUS_OCCUPIED)
+ return ID_STATUS_OCCUPIED;
+ if (bpStatus == ID_STATUS_DND)
+ return ID_STATUS_DND;
+ return ID_STATUS_OFFLINE;
+}
+
+//=======================================================
+// BPLoadIcon
+// =======================================================
+
+INT_PTR BPLoadIcon(WPARAM wParam, LPARAM)
+{
+ UINT id;
+
+ switch (wParam & 0xFFFF) {
+ case PLI_PROTOCOL:
+ id = IDI_SITE;
+ break;
+ default:
+ return 0;
+ }
+ return (INT_PTR)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(id), IMAGE_ICON,
+ GetSystemMetrics(wParam & PLIF_SMALL ? SM_CXSMICON : SM_CXICON),
+ GetSystemMetrics(wParam & PLIF_SMALL ? SM_CYSMICON : SM_CYICON), 0);
+}
+
+/*****************************************************************************/
+static void __cdecl BasicSearchTimerProc(wchar_t *pszNick)
+{
+ PROTOSEARCHRESULT psr = { sizeof(psr) };
+ psr.flags = PSR_UNICODE;
+ psr.nick.w = pszNick;
+
+ // broadcast the search result
+ ProtoBroadcastAck(MODULENAME, NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)1, (LPARAM)&psr);
+ ProtoBroadcastAck(MODULENAME, NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)1, 0);
+
+ // exit the search
+ searchId = -1;
+ mir_free(pszNick);
+}
+
+INT_PTR BasicSearch(WPARAM, LPARAM lParam)
+{
+ if (searchId != -1)
+ return 0; // only one search at a time
+
+ searchId = 1;
+
+ // create a thread for the ID search
+ mir_forkThread<wchar_t>(BasicSearchTimerProc, mir_wstrdup((const wchar_t*)lParam));
+ return searchId;
+}
+
+/*****************************************************************************/
+INT_PTR AddToList(WPARAM, LPARAM lParam)
+{
+ PROTOSEARCHRESULT *psr = (PROTOSEARCHRESULT *)lParam;
+ DBVARIANT dbv;
+ int sameurl = 0;
+ int samename = 0;
+
+ if (psr == nullptr)
+ return 0;
+ if (psr->nick.w == nullptr) {
+ WErrorPopup((UINT_PTR)"ERROR", TranslateT("Please select site in Find/Add contacts..."));
+ return 0;
+ }
+ // if contact with the same ID was not found, add it
+ if (psr->cbSize != sizeof(PROTOSEARCHRESULT))
+ return NULL;
+ // search for existing contact
+ for (auto &hContact : Contacts(MODULENAME)) {
+ // check ID to see if the contact already exist in the database
+ if (g_plugin.getWString(hContact, "URL", &dbv))
+ continue;
+ if (!mir_wstrcmpi(psr->nick.w, dbv.pwszVal)) {
+ // remove the flag for not on list and hidden, thus make the
+ // contact visible
+ // and add them on the list
+ sameurl++;
+ if (db_get_b(hContact, "CList", "NotOnList", 1)) {
+ db_unset(hContact, "CList", "NotOnList");
+ db_unset(hContact, "CList", "Hidden");
+ }
+ }
+ db_free(&dbv);
+ }
+
+ MCONTACT hContact = db_add_contact();
+ Proto_AddToContact(hContact, MODULENAME);
+
+ /////////write to db
+ g_plugin.setByte(hContact, ON_TOP_KEY, 0);
+ g_plugin.setByte(hContact, DBLE_WIN_KEY, 1);
+ g_plugin.setString(hContact, END_STRING_KEY, "");
+ g_plugin.setByte(hContact, RWSPACE_KEY, 1);
+
+ //Convert url into a name for contact
+ wchar_t Cnick[255];
+ if (psr->nick.w != nullptr)
+ wcsncpy(Cnick, psr->nick.w, _countof(Cnick));
+ else
+ Cnick[0] = 0;
+
+ wchar_t *Oldnick = wcsstr(Cnick, L"://");
+ if (Oldnick != nullptr)
+ Oldnick += 3;
+ else
+ Oldnick = Cnick;
+
+ wchar_t *Newnick = wcsstr(Oldnick, L"www.");
+ if (Newnick != nullptr)
+ Newnick += 4;
+ else {
+ Newnick = wcsstr(Oldnick, L"WWW.");
+ if (Newnick != nullptr)
+ Newnick += 4;
+ else
+ Newnick = Oldnick;
+ }
+
+ wchar_t *Nend = wcschr(Newnick, '.');
+ if (Nend) *Nend = '\0';
+
+ for (auto &hContact2 : Contacts(MODULENAME)) {
+ if (!db_get_ws(hContact2, MODULENAME, PRESERVE_NAME_KEY, &dbv)) {
+ if (!mir_wstrcmpi(Newnick, dbv.pwszVal)) {
+ // remove the flag for not on list and hidden, thus make the
+ // contact visible
+ // and add them on the list
+ samename++;
+ if (db_get_b(hContact2, "CList", "NotOnList", 1)) {
+ db_unset(hContact2, "CList", "NotOnList");
+ db_unset(hContact2, "CList", "Hidden");
+ }
+ db_free(&dbv);
+ }
+ }
+ db_free(&dbv);
+ }
+
+ if ((sameurl > 0) || (samename > 0)) // contact has the same url or name as another contact, add rand num to name
+ {
+ srand((unsigned)time(0));
+
+ wchar_t ranStr[10];
+ _itow((int)10000 * rand() / (RAND_MAX + 1.0), ranStr, 10);
+ mir_wstrcat(Newnick, ranStr);
+ }
+ //end convert
+
+ db_set_ws(hContact, "CList", "MyHandle", Newnick);
+ g_plugin.setWString(hContact, PRESERVE_NAME_KEY, Newnick);
+ g_plugin.setWString(hContact, "Nick", Newnick);
+ g_plugin.setByte(hContact, CLEAR_DISPLAY_KEY, 1);
+ g_plugin.setString(hContact, START_STRING_KEY, "");
+ g_plugin.setWString(hContact, URL_KEY, psr->nick.w);
+ g_plugin.setWString(hContact, "Homepage", psr->nick.w);
+ g_plugin.setByte(hContact, U_ALLSITE_KEY, 1);
+ g_plugin.setWord(hContact, "Status", ID_STATUS_ONLINE);
+
+ // ignore status change
+ db_set_dw(hContact, "Ignore", "Mask", 8);
+
+ Sleep(2);
+
+ db_free(&dbv);
+
+
+ return (INT_PTR)hContact;
+}
+
+/*****************************************************************************/
+
+static void __cdecl AckFunc(void*)
+{
+ for (auto &hContact : Contacts(MODULENAME))
+ ProtoBroadcastAck(MODULENAME, hContact, ACKTYPE_GETINFO, ACKRESULT_SUCCESS, (HANDLE)1, 0);
+}
+
+INT_PTR GetInfo(WPARAM, LPARAM)
+{
+ mir_forkthread(AckFunc);
+ return 1;
+}