summaryrefslogtreecommitdiff
path: root/plugins/WebView/src
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-07-28 18:37:34 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-07-28 18:37:34 +0000
commit2bf7e3ba50b1bf547c726523cf842e9263d5db18 (patch)
tree20c9611472a634e8e7b62f9135ad79b84bdb23f1 /plugins/WebView/src
parent2dacbc70df142b6a63606585468994fb5fec77e0 (diff)
first version of WebView that compiles in Unicode (but certaily doesn't work)
git-svn-id: http://svn.miranda-ng.org/main/trunk@5516 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/WebView/src')
-rw-r--r--plugins/WebView/src/Version.h8
-rw-r--r--plugins/WebView/src/main.cpp73
-rw-r--r--plugins/WebView/src/resource.h3
-rw-r--r--plugins/WebView/src/stdafx.cpp35
-rw-r--r--plugins/WebView/src/stdafx.h1
-rw-r--r--plugins/WebView/src/webview.cpp1356
-rw-r--r--plugins/WebView/src/webview.h540
-rw-r--r--plugins/WebView/src/webview_alerts.cpp1393
-rw-r--r--plugins/WebView/src/webview_cleanup.cpp1339
-rw-r--r--plugins/WebView/src/webview_common.h174
-rw-r--r--plugins/WebView/src/webview_datawnd.cpp1655
-rw-r--r--plugins/WebView/src/webview_getdata.cpp1479
-rw-r--r--plugins/WebView/src/webview_opts.cpp3005
-rw-r--r--plugins/WebView/src/webview_private.h23
-rw-r--r--plugins/WebView/src/webview_services.cpp1089
15 files changed, 4779 insertions, 7394 deletions
diff --git a/plugins/WebView/src/Version.h b/plugins/WebView/src/Version.h
index 65c0ab9893..45f77112a3 100644
--- a/plugins/WebView/src/Version.h
+++ b/plugins/WebView/src/Version.h
@@ -6,9 +6,9 @@
#define __FILEVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
#define __PLUGIN_NAME "Webview Protocol"
-#define __FILENAME "Webview.dll"
+#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 __AUTHOR "Vincent Joyce"
#define __AUTHOREMAIL "ungoliante666@hotmail.com"
-#define __AUTHORWEB "http://miranda-ng.org/p/WebView/"
-#define __COPYRIGHT "© 2011 Vincent Joyce"
+#define __AUTHORWEB "http://miranda-ng.org/p/WebView/"
+#define __COPYRIGHT "© 2011 Vincent Joyce"
diff --git a/plugins/WebView/src/main.cpp b/plugins/WebView/src/main.cpp
index 4fd58a9e79..5048e2bf2d 100644
--- a/plugins/WebView/src/main.cpp
+++ b/plugins/WebView/src/main.cpp
@@ -21,14 +21,14 @@
*/
#include "stdafx.h"
-#include "webview_common.h"
+#include "webview.h"
-static HANDLE hAddSite = NULL;
-static HANDLE hAutoUpdate = NULL;
-static HANDLE hNetlibUser = NULL;
-static HANDLE hWindowList = NULL;
-HMODULE hRichEd = NULL;
-int hLangpack = 0;
+HANDLE hNetlibUser;
+HANDLE hWindowList;
+HANDLE hHookDisplayDataAlert, hHookAlertPopup, hHookAlertWPopup, hHookErrorPopup, hHookAlertOSD;
+int hLangpack = 0;
+
+static HMODULE hRichEd = NULL;
PLUGININFOEX pluginInfoEx = {
sizeof(PLUGININFOEX),
@@ -44,18 +44,7 @@ PLUGININFOEX pluginInfoEx = {
{0xcd5427fb, 0x5320, 0x4f65, { 0xb4, 0xbf, 0x86, 0xb7, 0xcf, 0x7b, 0x50, 0x87}}
};
-/********************************/
-
-int WebsiteContactCommand(WPARAM wParam, LPARAM lParam)
-{
- WebsiteMenuCommand((WPARAM) wParam, (LPARAM) lParam);
- return 0;
-}
-
-/*******************************/
-
-/*******************************/
-
+/*****************************************************************************/
void InitServices()
{
char SvcFunc[100];
@@ -93,7 +82,7 @@ void InitServices()
CreateServiceFunction(SvcFunc, GetInfo);
}
-/*******************************/
+/*****************************************************************************/
void ChangeContactStatus(int con_stat)
{
WORD status_code = 0;
@@ -110,23 +99,22 @@ void ChangeContactStatus(int con_stat)
db_set_w(hContact, MODULENAME, "Status", status_code);
}
-/***********************/
+/*****************************************************************************/
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
hInst = hinstDLL;
return TRUE;
}
-/*******************/
+/*****************************************************************************/
+extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOCOL, MIID_LAST };
+
extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion)
{
return &pluginInfoEx;
}
-/******************/
-extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOCOL, MIID_LAST };
-
-/************************/
+/*****************************************************************************/
extern "C" int __declspec(dllexport) Unload(void)
{
ChangeContactStatus(0);
@@ -139,39 +127,30 @@ extern "C" int __declspec(dllexport) Unload(void)
if (hRichEd)
FreeLibrary(hRichEd);
- if (hNetlibUser)
+ if (hNetlibUser) {
Netlib_CloseHandle(hNetlibUser);
+ hNetlibUser = NULL;
+ }
+
if (hHookDisplayDataAlert)
- UnhookEvent(hHookDisplayDataAlert);
+ DestroyHookableEvent(hHookDisplayDataAlert);
if (hHookAlertPopup)
- UnhookEvent(hHookAlertPopup);
+ DestroyHookableEvent(hHookAlertPopup);
if (hHookAlertWPopup)
- UnhookEvent(hHookAlertWPopup);
+ DestroyHookableEvent(hHookAlertWPopup);
- hNetlibUser = NULL;
if (h_font != NULL)
DeleteObject(h_font);
if (hMenu)
DestroyMenu(hMenu);
- if (hAddSite)
- UnhookEvent(hAddSite);
- if (hWindowList )
- UnhookEvent(hWindowList);
-
- DestroyServiceFunction(0);
-
return 0;
}
-/***************************************/
+/*****************************************************************************/
extern "C" int __declspec(dllexport) Load()
{
mir_getLP(&pluginInfoEx);
- char countername[100];
- DBVARIANT dbv;
- HGENMENU hRoot;
-
strncpy_s(optionsname, MODULENAME, sizeof(optionsname));
optionsname[0] = toupper(optionsname[0]);
@@ -181,13 +160,12 @@ extern "C" int __declspec(dllexport) Load()
hRichEd = LoadLibraryA("Riched20.dll");
/*TIMERS*/
- if ((db_get_dw(NULL, MODULENAME, REFRESH_KEY, 0) != 0)) {
- timerId = SetTimer(NULL, 0, ((db_get_dw(NULL, MODULENAME, REFRESH_KEY, 0)) * MINUTE), (TIMERPROC) timerfunc);
+ if ((db_get_dw(NULL, MODULENAME, REFRESH_KEY, TIME) != 0)) {
+ timerId = SetTimer(NULL, 0, ((db_get_dw(NULL, MODULENAME, REFRESH_KEY, TIME)) * MINUTE), (TIMERPROC) timerfunc);
db_set_dw(NULL, MODULENAME, COUNTDOWN_KEY, 0);
Countdown = SetTimer(NULL, 0, MINUTE, (TIMERPROC) Countdownfunc);
}
- CheckDbKeys();
InitialiseGlobals();
// register netlib handle
@@ -278,10 +256,11 @@ extern "C" int __declspec(dllexport) Load()
CreateServiceFunction("Countdown", CountdownMenuCommand);
+ char countername[100];
+ mir_snprintf(countername, SIZEOF(countername), "%d Minutes to Update", db_get_dw(NULL, MODULENAME, COUNTDOWN_KEY, 0));
mi.position = 600090099;;
mi.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_UPDATEALL));
mi.pszContactOwner = NULL;
- sprintf(countername, "%d Minutes to Update", db_get_dw(NULL, MODULENAME, COUNTDOWN_KEY, 0));
mi.pszName = countername;
mi.pszService = "Countdown";
diff --git a/plugins/WebView/src/resource.h b/plugins/WebView/src/resource.h
index 108b7303b8..75379a22e5 100644
--- a/plugins/WebView/src/resource.h
+++ b/plugins/WebView/src/resource.h
@@ -1,5 +1,7 @@
#define UNI 1
+#define IDC_STATIC -1
+
#define IDI_SITE 101
#define IDI_STICK 102
#define IDI_UNSTICK 103
@@ -23,7 +25,6 @@
#define IDC_UPDATE_ONALERT 304
#define IDD_OPT 443
-#define IDC_STATIC 444
#define IDC_DISABLEMENU 446
#define IDC_OPEN_WEBPAGE 447
#define IDC_TIME 450
diff --git a/plugins/WebView/src/stdafx.cpp b/plugins/WebView/src/stdafx.cpp
index 1ddfafbbbd..a04913aacd 100644
--- a/plugins/WebView/src/stdafx.cpp
+++ b/plugins/WebView/src/stdafx.cpp
@@ -1,18 +1,23 @@
/*
-Copyright (C) 2012-13 Miranda NG Project (http://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/>.
-*/
+ * 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" \ No newline at end of file
diff --git a/plugins/WebView/src/stdafx.h b/plugins/WebView/src/stdafx.h
index 3a9966067a..fc6c4130e4 100644
--- a/plugins/WebView/src/stdafx.h
+++ b/plugins/WebView/src/stdafx.h
@@ -31,6 +31,7 @@
#include <m_options.h>
#include <m_clui.h>
#include <m_popup.h>
+#include <m_popup2.h>
#include <m_netlib.h>
#include <m_langpack.h>
#include <m_findadd.h>
diff --git a/plugins/WebView/src/webview.cpp b/plugins/WebView/src/webview.cpp
index 6e693b5726..54107f0600 100644
--- a/plugins/WebView/src/webview.cpp
+++ b/plugins/WebView/src/webview.cpp
@@ -1,1083 +1,527 @@
/*
- * 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.
- */
+* 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 HANDLE hAddSite = NULL;
-static HANDLE hAutoUpdate = NULL;
-char*WndClass = "WEBWnd";
+char* WndClass = "WEBWnd";
WNDCLASSEX wincl;
MSG messages;
DWORD winheight;
int StartUpDelay = 0;
-/*************************/
+DWORD Xposition, Yposition;
+DWORD BackgoundClr, TextClr;
+DWORD WindowHeight, WindowWidth;
+
+UINT_PTR timerId;
+UINT_PTR Countdown;
+LOGFONT lf;
+HFONT h_font;
+HWND ContactHwnd;
+HINSTANCE hInst;
+HMENU hMenu;
+int bpStatus;
+HANDLE hMenuItem1;
+HANDLE hMenuItemCountdown;
+char optionsname[80];
+
+/*****************************************************************************/
void ChangeMenuItem1()
{
- /*
- * Enable or Disable auto updates
- */
- ZeroMemory(&mi, sizeof(mi));
- mi.cbSize = sizeof(mi);
- mi.flags = CMIM_NAME | CMIM_ICON;
- mi.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_SITE));
-
- if (!(db_get_b(NULL, MODULENAME, DISABLE_AUTOUPDATE_KEY, 0)))
- mi.pszName = Translate("Auto Update Enabled");
-
- if ((db_get_b(NULL, MODULENAME, DISABLE_AUTOUPDATE_KEY, 0)))
- mi.pszName = Translate("Auto Update Disabled");
-
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM) hMenuItem1, (LPARAM) & mi);
-}
+ /*
+ * Enable or Disable auto updates
+ */
+
+ CLISTMENUITEM mi = { sizeof(mi) };
+ mi.flags = CMIM_NAME | CMIM_ICON;
+ mi.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_SITE));
-/**********************/
+ if ( !db_get_b(NULL, MODULENAME, DISABLE_AUTOUPDATE_KEY, 0))
+ mi.pszName = Translate("Auto Update Enabled");
+ else
+ mi.pszName = Translate("Auto Update Disabled");
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuItem1, (LPARAM)&mi);
+}
-/*************************/
+/*****************************************************************************/
void ChangeMenuItemCountdown()
{
- /*
- * countdown
- */
-
- ZeroMemory(&mi, sizeof(mi));
- mi.cbSize = sizeof(mi);
- mi.flags = CMIM_NAME | CMIM_ICON;
- mi.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_UPDATEALL));
-
- char countername[100];
- sprintf(countername, "%d Minutes to Update", db_get_dw(NULL, MODULENAME, COUNTDOWN_KEY, 0));
- mi.pszName = countername;
-
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM) hMenuItemCountdown, (LPARAM) & mi);
-}
+ /*
+ * countdown
+ */
-/**********************/
+ CLISTMENUITEM mi = { sizeof(mi) };
+ mi.flags = CMIM_NAME | CMIM_ICON;
+ mi.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_UPDATEALL));
+ char countername[100];
+ sprintf(countername, "%d Minutes to Update", db_get_dw(NULL, MODULENAME, COUNTDOWN_KEY, 0));
+ mi.pszName = countername;
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuItemCountdown, (LPARAM)&mi);
+}
-/*********************/
+/*****************************************************************************/
static int CALLBACK EnumFontsProc(ENUMLOGFONTEX * lpelfe, NEWTEXTMETRICEX * lpntme, int FontType, 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;
+ 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(HWND hwndDlg)
+void FillFontListThread(void *param)
{
- LOGFONT lf = {0};
- HDC hdc = GetDC(hwndDlg);
-
- lf.lfCharSet = DEFAULT_CHARSET;
- lf.lfFaceName[0] = 0;
- lf.lfPitchAndFamily = 0;
- EnumFontFamiliesEx(hdc, &lf, (FONTENUMPROC) EnumFontsProc, (LPARAM) GetDlgItem(hwndDlg, IDC_TYPEFACE), 0);
- ReleaseDC(hwndDlg, hdc);
- return;
+ HDC hdc = GetDC((HWND)param);
+
+ LOGFONT lf = {0};
+ lf.lfCharSet = DEFAULT_CHARSET;
+ lf.lfFaceName[0] = 0;
+ lf.lfPitchAndFamily = 0;
+ EnumFontFamiliesEx(hdc, &lf, (FONTENUMPROC) EnumFontsProc, (LPARAM) GetDlgItem((HWND)param, IDC_TYPEFACE), 0);
+ ReleaseDC((HWND)param, hdc);
}
-/*********************/
-
-/*******************************/
+/*****************************************************************************/
void TxtclrLoop()
{
- HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
- char*szProto;
-
- while (hContact != NULL)
- {
- szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0);
- //
- if (szProto != NULL && !lstrcmp(MODULENAME, szProto))
- {
-
- HWND hwndDlg = (WindowList_Find(hWindowList, hContact));
-
- SetDlgItemText(hwndDlg, IDC_DATA, "");
- InvalidateRect(hwndDlg, NULL, 1);
- }
- //
- hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0);
- }
-
+ for (HANDLE hContact = db_find_first(MODULENAME); hContact != NULL; hContact = db_find_next(hContact, MODULENAME)) {
+ HWND hwndDlg = WindowList_Find(hWindowList, hContact);
+ SetDlgItemTextA(hwndDlg, IDC_DATA, "");
+ InvalidateRect(hwndDlg, NULL, 1);
+ }
}
-/***************************/
-/*******************************/
+/*****************************************************************************/
void BGclrLoop()
{
- HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
- char*szProto;
-
- while (hContact != NULL)
- {
- szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0);
- //
- if (szProto != NULL && !lstrcmp(MODULENAME, szProto))
- {
-
- HWND hwndDlg = (WindowList_Find(hWindowList, hContact));
-
- SetDlgItemText(hwndDlg, IDC_DATA, "");
- SendMessage(GetDlgItem(hwndDlg, IDC_DATA), EM_SETBKGNDCOLOR, 0, BackgoundClr);
- InvalidateRect(hwndDlg, NULL, 1);
- }
- //
- hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0);
- }
-
+ for (HANDLE hContact = db_find_first(MODULENAME); hContact != NULL; hContact = db_find_next(hContact, MODULENAME)) {
+ HWND hwndDlg = (WindowList_Find(hWindowList, hContact));
+ SetDlgItemTextA(hwndDlg, IDC_DATA, "");
+ SendMessage(GetDlgItem(hwndDlg, IDC_DATA), EM_SETBKGNDCOLOR, 0, BackgoundClr);
+ InvalidateRect(hwndDlg, NULL, 1);
+ }
}
-/***************************/
+/*****************************************************************************/
void StartUpdate(void *dummy)
{
- HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
- char*szProto;
-
- StartUpDelay = 1;
-
- Sleep(((db_get_dw(NULL, MODULENAME, START_DELAY_KEY, 0)) * SECOND));
-
- while (hContact != NULL)
- {
- szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0);
- //
- if (szProto != NULL && !lstrcmp(MODULENAME, szProto))
- GetData(hContact);
- //
- hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0);
- }
- StartUpDelay = 0;
+ StartUpDelay = 1;
+ Sleep(((db_get_dw(NULL, MODULENAME, START_DELAY_KEY, 0)) * SECOND));
+
+ for (HANDLE hContact = db_find_first(MODULENAME); hContact != NULL; hContact = db_find_next(hContact, MODULENAME))
+ GetData(hContact);
+
+ StartUpDelay = 0;
}
-/*******************************/
+/*****************************************************************************/
void ContactLoop(void *dummy)
{
- HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
- char*szProto;
- char galert[300];
-
- if (StartUpDelay == 0)
- {
-
- while (hContact != NULL)
- {
- szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0);
- //
- if (szProto != NULL && !lstrcmp(MODULENAME, szProto))
-
- GetData(hContact);
- //forkthread(GetData, 0, hContact);
- Sleep(10); // avoid 100% CPU
- //
-
- hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0);
- }
- }
- sprintf(galert, "%s", (Translate("All Webview sites have been updated.")));
- WAlertPopup((WPARAM) NULL, galert);
+ if (StartUpDelay == 0) {
+ for (HANDLE hContact = db_find_first(MODULENAME); hContact != NULL; hContact = db_find_next(hContact, MODULENAME)) {
+ GetData(hContact);
+ Sleep(10); // avoid 100% CPU
+ }
+ }
+
+ WAlertPopup(NULL, TranslateT("All Webview sites have been updated."));
}
-/***************************/
-
-
-/****************************/
- /**********************/
-int MarkAllReadMenuCommand(WPARAM wParam, LPARAM lParam)
+/*****************************************************************************/
+INT_PTR MarkAllReadMenuCommand(WPARAM wParam, LPARAM lParam)
{
- ChangeContactStatus(1);
- return 0;
+ ChangeContactStatus(1);
+ return 0;
}
-/*************************/
-
-/****************************/
-
-
-
-/**********************/
+/*****************************************************************************/
void InitialiseGlobals(void)
{
+ Xposition = db_get_dw(NULL, MODULENAME, Xpos_WIN_KEY, 0);
+ Yposition = db_get_dw(NULL, MODULENAME, Ypos_WIN_KEY, 0);
- Xposition = db_get_dw(NULL, MODULENAME, Xpos_WIN_KEY, 0);
+ if (Yposition == -32000)
+ Yposition = 100;
- Yposition = db_get_dw(NULL, MODULENAME, Ypos_WIN_KEY, 0);
+ if (Xposition == -32000)
+ Xposition = 100;
- if (Yposition == -32000)
- Yposition = 100;
-
- if (Xposition == -32000)
- Xposition = 100;
-
- BackgoundClr = db_get_dw(NULL, MODULENAME, BG_COLOR_KEY, 0);
-
- TextClr = db_get_dw(NULL, MODULENAME, TXT_COLOR_KEY, 0);
-
- WindowHeight = db_get_dw(NULL, MODULENAME, WIN_HEIGHT_KEY, 0);
-
- WindowWidth = db_get_dw(NULL, MODULENAME, WIN_WIDTH_KEY, 0);
+ BackgoundClr = db_get_dw(NULL, MODULENAME, BG_COLOR_KEY, Def_color_bg);
+ TextClr = db_get_dw(NULL, MODULENAME, TXT_COLOR_KEY, Def_color_txt);
+ WindowHeight = db_get_dw(NULL, MODULENAME, WIN_HEIGHT_KEY, Def_win_height);
+ WindowWidth = db_get_dw(NULL, MODULENAME, WIN_WIDTH_KEY, Def_win_width);
}
-/********************************/
-/***************************/
+/*****************************************************************************/
int Doubleclick(WPARAM wParam, LPARAM lParam)
{
- DBVARIANT dbv;
- char*szProto = NULL;
- char url[300];
-
- url[0] = '\0';
-
- szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0);
-
-// write default values first time contact is double clicked
- if (DBGetContactSetting((HANDLE) wParam, MODULENAME, DBLE_WIN_KEY, &dbv))
- {
- if (!(lstrcmp(MODULENAME, szProto)))
- db_set_b((HANDLE) wParam, MODULENAME, DBLE_WIN_KEY, 1);
- }
-
- //szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0);
-
- if (szProto != NULL)
- {
- if (!(lstrcmp(MODULENAME, szProto)))
- {
- //
- if (!(db_get_b((HANDLE) wParam, MODULENAME, DBLE_WIN_KEY, 0)))
- {
- DBGetContactSetting((HANDLE) wParam, MODULENAME, "URL", &dbv);
- wsprintf(url, "%s", dbv.pszVal);
- CallService(MS_UTILS_OPENURL, 1, (WPARAM) url);
- DBFreeVariant(&dbv);
- db_set_w((HANDLE) wParam, MODULENAME, "Status", ID_STATUS_ONLINE);
- }
- //
-
- if ((db_get_b((HANDLE) wParam, MODULENAME, DBLE_WIN_KEY, 0)))
- {
- HWND hwndDlg;
-
- if ((hwndDlg = (WindowList_Find(hWindowList, (HANDLE) wParam))))
- {
- SetForegroundWindow(hwndDlg);
- SetFocus(hwndDlg);
- } else
- {
- hwndDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_DISPLAY_DATA), NULL, DlgProcDisplayData, (LPARAM) (HANDLE) wParam);
-
- if (db_get_b((HANDLE) wParam, MODULENAME, ON_TOP_KEY, 0))
- {
- SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_STICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)));
-
- if ((db_get_b(NULL, MODULENAME, SAVE_INDIVID_POS_KEY, 0)))
- {
- SetWindowPos(
- hwndDlg,
- HWND_TOPMOST,
- db_get_dw((HANDLE) wParam, MODULENAME, "WVx", 100), // Xposition,
- db_get_dw((HANDLE) wParam, MODULENAME, "WVy", 100), // Yposition,
- db_get_dw((HANDLE) wParam, MODULENAME, "WVwidth", 412), // WindowWidth,
- db_get_dw((HANDLE) wParam, MODULENAME, "WVheight", 350), // WindowHeight,
- 0);
- } else
- {
- SetWindowPos(
- hwndDlg,
- HWND_TOPMOST,
- Xposition,
- Yposition,
- WindowWidth,
- WindowHeight,
- 0);
- }
-
- }
- if (!(db_get_b((HANDLE) wParam, MODULENAME, ON_TOP_KEY, 0)))
- {//
- SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_UNSTICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)));
-
- if ((db_get_b(NULL, MODULENAME, SAVE_INDIVID_POS_KEY, 0)))
- {
- SetWindowPos(
- hwndDlg,
- HWND_NOTOPMOST,
- db_get_dw((HANDLE) wParam, MODULENAME, "WVx", 100), // Xposition,
- db_get_dw((HANDLE) wParam, MODULENAME, "WVy", 100), // Yposition,
- db_get_dw((HANDLE) wParam, MODULENAME, "WVwidth", 412), // WindowWidth,
- db_get_dw((HANDLE) wParam, MODULENAME, "WVheight", 350), // WindowHeight,
- 0);
- } else
- {
- SetWindowPos(
- hwndDlg,
- HWND_NOTOPMOST,
- Xposition,
- Yposition,
- WindowWidth,
- WindowHeight,
- 0);
- }
-
- }
- }
- //
- ShowWindow(hwndDlg, SW_SHOW);
- SetActiveWindow(hwndDlg);
- //
-
- if ((db_get_b(NULL, MODULENAME, UPDATE_ON_OPEN_KEY, 0)))
- {
- if ((db_get_b((HANDLE) wParam, MODULENAME, ENABLE_ALERTS_KEY, 0)))
- forkthread(ReadFromFile, 0, (HANDLE) wParam);
- else
- forkthread(GetData, 0, (HANDLE) wParam);
- db_set_w((HANDLE) wParam, MODULENAME, "Status", ID_STATUS_ONLINE);
- }
- }
- //
- return 1;
- }
- }
- return 0;
+ HANDLE hContact = (HANDLE)wParam;
+ char *szProto = GetContactProto(hContact);
+ if ( lstrcmpA(MODULENAME, szProto))
+ return 0;
+
+ if ( db_get_b(hContact, MODULENAME, DBLE_WIN_KEY, 1)) {
+ ptrT url( db_get_tsa(hContact, MODULENAME, "URL"));
+ CallService(MS_UTILS_OPENURL, OUF_TCHAR, (WPARAM)url);
+
+ db_set_w(hContact, MODULENAME, "Status", ID_STATUS_ONLINE);
+ }
+
+ if ( db_get_b(hContact, MODULENAME, DBLE_WIN_KEY, 1)) {
+ HWND hwndDlg;
+ if (hwndDlg = WindowList_Find(hWindowList, hContact)) {
+ SetForegroundWindow(hwndDlg);
+ SetFocus(hwndDlg);
+ }
+ else {
+ hwndDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_DISPLAY_DATA), NULL, DlgProcDisplayData, (LPARAM) hContact);
+ HWND hTopmost = db_get_b(hContact, MODULENAME, ON_TOP_KEY, 0) ? HWND_TOPMOST : HWND_NOTOPMOST;
+ SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_STICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)));
+
+ if ( db_get_b(NULL, MODULENAME, SAVE_INDIVID_POS_KEY, 0))
+ SetWindowPos(hwndDlg, hTopmost,
+ db_get_dw(hContact, MODULENAME, "WVx", 100), // Xposition,
+ db_get_dw(hContact, MODULENAME, "WVy", 100), // Yposition,
+ db_get_dw(hContact, MODULENAME, "WVwidth", 412), // WindowWidth,
+ db_get_dw(hContact, MODULENAME, "WVheight", 350), 0); // WindowHeight,
+ else
+ SetWindowPos(hwndDlg, HWND_TOPMOST, Xposition, Yposition, WindowWidth, WindowHeight, 0);
+ }
+
+ ShowWindow(hwndDlg, SW_SHOW);
+ SetActiveWindow(hwndDlg);
+
+ if ( db_get_b(NULL, MODULENAME, UPDATE_ON_OPEN_KEY, 0)) {
+ if ( db_get_b(hContact, MODULENAME, ENABLE_ALERTS_KEY, 0))
+ mir_forkthread(ReadFromFile, hContact);
+ else
+ mir_forkthread(GetData, hContact);
+ db_set_w(hContact, MODULENAME, "Status", ID_STATUS_ONLINE);
+ }
+ }
+
+ return 1;
}
-/**************************/
-/***************************/
-//int SendToRichEdit(HWND hWindow, char *truncated, COLORREF rgbText, COLORREF rgbBack)
-int SendToRichEdit(HWND hWindow, TCHAR *truncated, COLORREF rgbText, COLORREF rgbBack)
+/*****************************************************************************/
+int SendToRichEdit(HWND hWindow, char *truncated, COLORREF rgbText, COLORREF rgbBack)
{
-
- CHARFORMAT2 cfFM;
- DBVARIANT dbv;
- DWORD bold = 0;
- DWORD italic = 0;
- DWORD underline = 0;
-
- //
-
- // //////
- int len;
-
- //MessageBox(NULL, "Test", "0", MB_OK);
-
-
- len = GetWindowTextLength(GetDlgItem(hWindow, IDC_DATA));
-
- //
- SetDlgItemText(hWindow, IDC_DATA, "");
-
- //MessageBox(NULL, "Test", "1", MB_OK);
-
- //
- ZeroMemory(&cfFM, 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 ((db_get_b(NULL, MODULENAME, FONT_BOLD_KEY, 0)))
- bold = CFE_BOLD;
-
- if ((db_get_b(NULL, MODULENAME, FONT_ITALIC_KEY, 0)))
- italic = CFE_ITALIC;
-
- if ((db_get_b(NULL, MODULENAME, FONT_UNDERLINE_KEY, 0)))
- underline = CFE_UNDERLINE;
-
- cfFM.dwEffects = bold | italic | underline;
-
- // /////////
-
- //MessageBox(NULL, "Test", "2", MB_OK);
-
- /**/
- if (!DBGetContactSetting(NULL, MODULENAME, FONT_FACE_KEY, &dbv))
- {
-/*
-#ifdef UNICODE_VERISON
- MultiByteToWideChar(CP_ACP, 0, (TCHAR *) cfFM.szFaceName, -1, (wchar_t *) dbv.pszVal, 200);
-#endif
-*/
-//#ifndef UNICODE_VERISON
- lstrcpy(cfFM.szFaceName, dbv.pszVal);
-//#endif
- DBFreeVariant(&dbv);
- }
- /**/
-
- //MessageBox(NULL, "Test", "3", MB_OK);
-//
-
- HDC hDC;
- hDC = GetDC(hWindow);
- cfFM.yHeight = (BYTE) MulDiv(abs(lf.lfHeight), 120, GetDeviceCaps(GetDC(hWindow), LOGPIXELSY)) * (db_get_b(NULL, MODULENAME, FONT_SIZE_KEY, 0));
- ReleaseDC(hWindow, hDC);
-//
- cfFM.bCharSet = db_get_b(NULL, MODULENAME, FONT_SCRIPT_KEY, 1);
-
- cfFM.bPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
-
- cfFM.crTextColor = rgbText;
-
- cfFM.crBackColor = rgbBack;
-
- SendMessage(GetDlgItem(hWindow, IDC_DATA), EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM) & cfFM);
-
- //MessageBox(NULL, "Test", "4", MB_OK);
-
-// //////////////////////////
-
- SendDlgItemMessage(hWindow, IDC_DATA, EM_SETSEL, 0, -1);
-
- // MessageBox(NULL, "Test", "5", MB_OK);
-////
-#ifdef UNICODE_VERISON
-
- wchar_t tmp4[strlen(truncated)];
-
-
- int c = lstrlenA(truncated);
-
-MultiByteToWideChar(CP_UTF8, 0, (CHAR *)truncated, -1, tmp4, strlen(truncated));
-
-
-
-//SetDlgItemTextW(hwndDlg, IDC_DATA, (wchar_t *)&tmp2);
-//MessageBoxW(NULL, tmp2, L"OOOO", MB_OK);
-SendDlgItemMessageW(hWindow, IDC_DATA, EM_REPLACESEL, FALSE, (LPARAM) tmp4);
- #endif
-
-#ifndef UNICODE_VERISON
- SendDlgItemMessage(hWindow, IDC_DATA, EM_REPLACESEL, FALSE, (LPARAM) truncated);
- #endif
-////
- // MessageBox(NULL, "Test", "6", MB_OK);
-
- SendMessage(GetDlgItem(hWindow, IDC_DATA), EM_SETCHARFORMAT, SCF_ALL, (LPARAM) & cfFM);
- // MessageBox(NULL, "Test", "7", MB_OK);
-
- return 1;
+ DBVARIANT dbv;
+ DWORD bold = 0;
+ DWORD italic = 0;
+ DWORD underline = 0;
+
+ int len = GetWindowTextLength(GetDlgItem(hWindow, IDC_DATA));
+ SetDlgItemTextA(hWindow, IDC_DATA, "");
+
+ CHARFORMAT2 cfFM;
+ ZeroMemory(&cfFM, 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 ( db_get_b(NULL, MODULENAME, FONT_BOLD_KEY, 0))
+ bold = CFE_BOLD;
+
+ if ( db_get_b(NULL, MODULENAME, FONT_ITALIC_KEY, 0))
+ italic = CFE_ITALIC;
+
+ if ( db_get_b(NULL, MODULENAME, FONT_UNDERLINE_KEY, 0))
+ underline = CFE_UNDERLINE;
+
+ cfFM.dwEffects = bold | italic | underline;
+
+ if (!db_get_ts(NULL, MODULENAME, FONT_FACE_KEY, &dbv)) {
+ lstrcpy(cfFM.szFaceName, dbv.ptszVal);
+ db_free(&dbv);
+ }
+ else lstrcpy(cfFM.szFaceName, Def_font_face);
+
+ HDC hDC;
+ hDC = GetDC(hWindow);
+ cfFM.yHeight = (BYTE)MulDiv(abs(lf.lfHeight), 120, GetDeviceCaps(GetDC(hWindow), LOGPIXELSY)) * (db_get_b(NULL, MODULENAME, FONT_SIZE_KEY, 14));
+ ReleaseDC(hWindow, hDC);
+
+ cfFM.bCharSet = db_get_b(NULL, MODULENAME, FONT_SCRIPT_KEY, 0);
+ cfFM.bPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
+ cfFM.crTextColor = rgbText;
+ cfFM.crBackColor = rgbBack;
+ SendMessage(GetDlgItem(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 timerfunc(void)
{
- db_set_b(NULL, MODULENAME, HAS_CRASHED_KEY, 0);
-
- if (!(db_get_b(NULL, MODULENAME, OFFLINE_STATUS, 0)))
- {
- if (!(db_get_b(NULL, MODULENAME, DISABLE_AUTOUPDATE_KEY, 0)))
- forkthread(ContactLoop, 0, NULL);
- }
-
- db_set_dw(NULL, MODULENAME, COUNTDOWN_KEY, 0);
-}
-/*******************************/
+ db_set_b(NULL, MODULENAME, HAS_CRASHED_KEY, 0);
+ if (!(db_get_b(NULL, MODULENAME, OFFLINE_STATUS, 1)))
+ if (!(db_get_b(NULL, MODULENAME, DISABLE_AUTOUPDATE_KEY, 0)))
+ mir_forkthread(ContactLoop, NULL);
-/*******************************/
+ db_set_dw(NULL, MODULENAME, COUNTDOWN_KEY, 0);
+}
+
+/*****************************************************************************/
void Countdownfunc(void)
{
-DWORD timetemp=100;
-//char tempcnterchar[100];
-DBVARIANT dbv;
-
-timetemp=(db_get_dw(NULL, MODULENAME, COUNTDOWN_KEY, (DWORD)&dbv));
- DBFreeVariant(&dbv);
-
-// sprintf(tempcnterchar, "%d", timetemp);
-//MessageBox(NULL, tempcnterchar, "1", MB_OK);
-
- if((timetemp < 0) || (timetemp ==0))
- {
- timetemp=(db_get_dw(NULL, MODULENAME, REFRESH_KEY, (DWORD)&dbv));
- db_set_dw(NULL, MODULENAME, COUNTDOWN_KEY, timetemp);
- DBFreeVariant(&dbv);
- }
-
-//sprintf(tempcnterchar, "%d", timetemp);
-//MessageBox(NULL, tempcnterchar, "2", MB_OK);
-
-timetemp = timetemp - 1;
-
-
-
-db_set_dw(NULL, MODULENAME, COUNTDOWN_KEY, timetemp);
-
-//sprintf(tempcnterchar, "%d", timetemp);
-//MessageBox(NULL, tempcnterchar, "3", MB_OK);
+ DWORD timetemp = db_get_dw(NULL, MODULENAME, COUNTDOWN_KEY, 100);
+ if(timetemp < 0 || timetemp == 0) {
+ timetemp = db_get_dw(NULL, MODULENAME, REFRESH_KEY, TIME);
+ db_set_dw(NULL, MODULENAME, COUNTDOWN_KEY, timetemp);
+ }
- ChangeMenuItemCountdown();
+ timetemp = timetemp - 1;
+ db_set_dw(NULL, MODULENAME, COUNTDOWN_KEY, timetemp);
+ ChangeMenuItemCountdown();
}
-/*******************************/
-/****************/
-static int OptInitialise(WPARAM wParam, LPARAM lParam)
+/*****************************************************************************/
+
+static int OptInitialise(WPARAM wParam, LPARAM lParam)
{
- OPTIONSDIALOGPAGE odp = {0};
-
- ZeroMemory(&odp, sizeof(odp));
- odp.cbSize = sizeof(odp);
- odp.position = 0;
- odp.hInstance = hInst;
- odp.pszTemplate = MAKEINTRESOURCE(IDD_OPT);
- odp.pszGroup = Translate("Network");
- odp.pszTitle = optionsname;
- odp.pfnDlgProc = DlgProcOpt;
- odp.flags = ODPF_BOLDGROUPS;
- odp.expertOnlyControls = expertOnlyControls;
- odp.nExpertOnlyControls = sizeof(expertOnlyControls) / sizeof(expertOnlyControls[0]);
- CallService(MS_OPT_ADDPAGE, wParam, (LPARAM) & odp);
-
- // if popup service exists
- if ((ServiceExists(MS_POPUP_ADDPOPUP)))
- {
- ZeroMemory(&odp, sizeof(odp));
- odp.cbSize = sizeof(odp);
- odp.position = 100000000;
- odp.hInstance = hInst;
- odp.pszTemplate = MAKEINTRESOURCE(IDD_POPUP);
- odp.pszTitle = optionsname;
- odp.pszGroup = Translate("PopUps");
- odp.groupPosition = 910000000;
- odp.flags = ODPF_BOLDGROUPS;
- odp.pfnDlgProc = DlgPopUpOpts;
- CallService(MS_OPT_ADDPAGE, wParam, (LPARAM) & odp);
- }
- return 0;
+ OPTIONSDIALOGPAGE odp = { sizeof(odp) };
+ odp.hInstance = hInst;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT);
+ odp.pszGroup = Translate("Network");
+ odp.pszTitle = optionsname;
+ odp.pfnDlgProc = DlgProcOpt;
+ odp.flags = ODPF_BOLDGROUPS;
+ Options_AddPage(wParam, &odp);
+
+ // if popup service exists
+ if ((ServiceExists(MS_POPUP_ADDPOPUP))) {
+ ZeroMemory(&odp, sizeof(odp));
+ odp.cbSize = sizeof(odp);
+ odp.position = 100000000;
+ odp.hInstance = hInst;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_POPUP);
+ odp.pszTitle = optionsname;
+ odp.pszGroup = Translate("PopUps");
+ odp.groupPosition = 910000000;
+ odp.flags = ODPF_BOLDGROUPS;
+ odp.pfnDlgProc = DlgPopUpOpts;
+ Options_AddPage(wParam, &odp);
+ }
+ return 0;
}
-/***************/
-
-/**********/
+/*****************************************************************************/
void FontSettings(void)
{
- char fontfacename[20];
-
- ZeroMemory(&fontfacename, sizeof(fontfacename));
-
- lf.lfHeight = 16;
- lf.lfWidth = 0;
- lf.lfEscapement = 0;
- lf.lfOrientation = 0;
- lf.lfWeight = FW_NORMAL;
- lf.lfItalic = FALSE;
- lf.lfUnderline = FALSE;
- lf.lfStrikeOut = 0;
- lf.lfCharSet = ANSI_CHARSET;
- lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
- lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
- lf.lfQuality = DEFAULT_QUALITY;
- lf.lfPitchAndFamily = FIXED_PITCH | FF_MODERN;
- lstrcpy(lf.lfFaceName, "Courier");
-
+ lf.lfHeight = 16;
+ lf.lfWidth = 0;
+ lf.lfEscapement = 0;
+ lf.lfOrientation = 0;
+ lf.lfWeight = FW_NORMAL;
+ lf.lfItalic = FALSE;
+ lf.lfUnderline = FALSE;
+ lf.lfStrikeOut = 0;
+ lf.lfCharSet = ANSI_CHARSET;
+ lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
+ lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
+ lf.lfQuality = DEFAULT_QUALITY;
+ lf.lfPitchAndFamily = FIXED_PITCH | FF_MODERN;
+ lstrcpy(lf.lfFaceName, Def_font_face);
}
-/************/
+/*****************************************************************************/
int ModulesLoaded(WPARAM wParam, LPARAM lParam)
{
- HookEvent(ME_OPT_INITIALISE, OptInitialise);
-
- hHookDisplayDataAlert = CreateHookableEvent(ME_DISPLAYDATA_ALERT);
- HookEvent(ME_DISPLAYDATA_ALERT, DataWndAlertCommand);
-
- hHookAlertPopup = CreateHookableEvent(ME_POPUP_ALERT);
- HookEvent(ME_POPUP_ALERT, PopupAlert);
-
- hHookAlertWPopup = CreateHookableEvent(ME_WPOPUP_ALERT);
- HookEvent(ME_WPOPUP_ALERT, WPopupAlert);
+ HookEvent(ME_OPT_INITIALISE, OptInitialise);
- hHookErrorPopup = CreateHookableEvent(ME_POPUP_ERROR);
- HookEvent(ME_POPUP_ERROR, ErrorMsgs);
+ hHookDisplayDataAlert = CreateHookableEvent(ME_DISPLAYDATA_ALERT);
+ HookEvent(ME_DISPLAYDATA_ALERT, DataWndAlertCommand);
- hHookAlertOSD = CreateHookableEvent(ME_OSD_ALERT);
- HookEvent(ME_OSD_ALERT, OSDAlert);
+ hHookAlertPopup = CreateHookableEvent(ME_POPUP_ALERT);
+ HookEvent(ME_POPUP_ALERT, PopupAlert);
- FontSettings();
+ hHookErrorPopup = CreateHookableEvent(ME_POPUP_ERROR);
+ HookEvent(ME_POPUP_ERROR, ErrorMsgs);
- h_font = CreateFontIndirect(&lf);
+ hHookAlertOSD = CreateHookableEvent(ME_OSD_ALERT);
+ HookEvent(ME_OSD_ALERT, OSDAlert);
-// get data on startup
- if ((db_get_b(NULL, MODULENAME, UPDATE_ONSTART_KEY, 0)))
- forkthread(StartUpdate, 0, NULL);
+ FontSettings();
+ h_font = CreateFontIndirect(&lf);
-/****END ALWAYS****/
+ // get data on startup
+ if ( db_get_b(NULL, MODULENAME, UPDATE_ONSTART_KEY, 0))
+ mir_forkthread(StartUpdate, NULL);
- return 0;
+ return 0;
}
-/*********/
-/***********************/
-int DataWndMenuCommand(WPARAM wParam, LPARAM lParam)
+/*****************************************************************************/
+INT_PTR DataWndMenuCommand(WPARAM wParam, LPARAM lParam)
{
- HWND hwndDlg;
-
- if ((hwndDlg = (WindowList_Find(hWindowList, (HANDLE) wParam))))
- {
- DestroyWindow(hwndDlg);
- return 0;
- } else
- {
-
- hwndDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_DISPLAY_DATA), NULL, DlgProcDisplayData, (LPARAM) (HANDLE) wParam);
-
- if (db_get_b((HANDLE) wParam, MODULENAME, ON_TOP_KEY, 0))
- {
- SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_STICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)));
- if ((db_get_b(NULL, MODULENAME, SAVE_INDIVID_POS_KEY, 0)))
- {
- SetWindowPos(
- hwndDlg,
- HWND_TOPMOST,
- db_get_dw((HANDLE) wParam, MODULENAME, "WVx", 100), // Xposition,
- db_get_dw((HANDLE) wParam, MODULENAME, "WVy", 100), // Yposition,
- db_get_dw((HANDLE) wParam, MODULENAME, "WVwidth", 100), // WindowWidth,
- db_get_dw((HANDLE) wParam, MODULENAME, "WVheight", 100), // WindowHeight,
- 0);
- } else
- {
- SetWindowPos(
- hwndDlg,
- HWND_TOPMOST,
- Xposition,
- Yposition,
- WindowWidth,
- WindowHeight,
- 0);
-
- }
- }
- if (!(db_get_b((HANDLE) wParam, MODULENAME, ON_TOP_KEY, 0)))
- {//
- SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_UNSTICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)));
-
- if ((db_get_b(NULL, MODULENAME, SAVE_INDIVID_POS_KEY, 0)))
- {
- SetWindowPos(
- hwndDlg,
- HWND_NOTOPMOST,
- db_get_dw((HANDLE) wParam, MODULENAME, "WVx", 100), // Xposition,
- db_get_dw((HANDLE) wParam, MODULENAME, "WVy", 100), // Yposition,
- db_get_dw((HANDLE) wParam, MODULENAME, "WVwidth", 100), // WindowWidth,
- db_get_dw((HANDLE) wParam, MODULENAME, "WVheight", 100), // WindowHeight,
- 0);
- } else
- {
- SetWindowPos(
- hwndDlg,
- HWND_NOTOPMOST,
- Xposition,
- Yposition,
- WindowWidth,
- WindowHeight,
- 0);
- }
-
- }
- }
-
- //
- ShowWindow(hwndDlg, SW_SHOW);
- SetActiveWindow(hwndDlg);
- //
- if ((db_get_b(NULL, MODULENAME, UPDATE_ON_OPEN_KEY, 0)))
- {
- if ((db_get_b((HANDLE) wParam, MODULENAME, ENABLE_ALERTS_KEY, 0)))
- forkthread(ReadFromFile, 0, (HANDLE) wParam);
- else
- forkthread(GetData, 0, (HANDLE) wParam);
- db_set_w((HANDLE) wParam, MODULENAME, "Status", ID_STATUS_ONLINE);
- }
-
- return 0;
+ HANDLE hContact = (HANDLE)wParam;
+ HWND hwndDlg = WindowList_Find(hWindowList, hContact);
+ if (hwndDlg != NULL) {
+ DestroyWindow(hwndDlg);
+ return 0;
+ }
+
+ HWND hTopmost = db_get_b(hContact, MODULENAME, ON_TOP_KEY, 0) ? HWND_TOPMOST : HWND_NOTOPMOST;
+ hwndDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_DISPLAY_DATA), NULL, DlgProcDisplayData, (LPARAM) hContact);
+ SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_STICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)));
+ if ( db_get_b(NULL, MODULENAME, SAVE_INDIVID_POS_KEY, 0))
+ SetWindowPos(hwndDlg, hTopmost,
+ db_get_dw(hContact, MODULENAME, "WVx", 100), // Xposition,
+ db_get_dw(hContact, MODULENAME, "WVy", 100), // Yposition,
+ db_get_dw(hContact, MODULENAME, "WVwidth", 100), // WindowWidth,
+ db_get_dw(hContact, MODULENAME, "WVheight", 100), 0); // WindowHeight,
+ else
+ SetWindowPos(hwndDlg, HWND_TOPMOST, Xposition, Yposition, WindowWidth, WindowHeight, 0);
+
+ ShowWindow(hwndDlg, SW_SHOW);
+ SetActiveWindow(hwndDlg);
+
+ if ( db_get_b(NULL, MODULENAME, UPDATE_ON_OPEN_KEY, 0)) {
+ if ( db_get_b(hContact, MODULENAME, ENABLE_ALERTS_KEY, 0))
+ mir_forkthread(ReadFromFile, hContact);
+ else
+ mir_forkthread(GetData, hContact);
+ db_set_w(hContact, MODULENAME, "Status", ID_STATUS_ONLINE);
+ }
+
+ return 0;
}
-/***********************/
-
-/**********************/
+/*****************************************************************************/
INT_PTR UpdateAllMenuCommand(WPARAM wParam, LPARAM lParam)
{
- forkthread(ContactLoop, 0, NULL);
- return 0;
+ mir_forkthread(ContactLoop, NULL);
+ return 0;
}
-/*************************/
-/************************/
+/*****************************************************************************/
INT_PTR AutoUpdateMCmd(WPARAM wParam, LPARAM lParam)
{
- if (db_get_b(NULL, MODULENAME, DISABLE_AUTOUPDATE_KEY, 0))
- db_set_b(NULL, MODULENAME, DISABLE_AUTOUPDATE_KEY, 0);
- else if (!(db_get_b(NULL, MODULENAME, DISABLE_AUTOUPDATE_KEY, 0)))
- db_set_b(NULL, MODULENAME, DISABLE_AUTOUPDATE_KEY, 1);
+ if (db_get_b(NULL, MODULENAME, DISABLE_AUTOUPDATE_KEY, 0))
+ db_set_b(NULL, MODULENAME, DISABLE_AUTOUPDATE_KEY, 0);
+ else if (!(db_get_b(NULL, MODULENAME, DISABLE_AUTOUPDATE_KEY, 0)))
+ db_set_b(NULL, MODULENAME, DISABLE_AUTOUPDATE_KEY, 1);
- ChangeMenuItem1();
- return 0;
+ ChangeMenuItem1();
+ return 0;
}
-/**********************/
-/***************************/
-int AddContactMenuCommand(WPARAM wParam, LPARAM lParam)
+/*****************************************************************************/
+INT_PTR AddContactMenuCommand(WPARAM wParam, LPARAM lParam)
{
- db_set_s(NULL, "FindAdd", "LastSearched", MODULENAME);
- CallService(MS_FINDADD_FINDADD, 0, 0);
- return 0;
+ db_set_s(NULL, "FindAdd", "LastSearched", MODULENAME);
+ CallService(MS_FINDADD_FINDADD, 0, 0);
+ return 0;
}
-/***************************/
-/***********************/
+/*****************************************************************************/
int OnTopMenuCommand(WPARAM wParam, LPARAM lParam, HANDLE singlecontact)
{
- int ontop = 0;
- int done = 0;
-
- if (((db_get_b(singlecontact, MODULENAME, ON_TOP_KEY, 0))) && done == 0)
- {
- db_set_b(singlecontact, MODULENAME, ON_TOP_KEY, 0);
- ontop = 0;
- done = 1;
- }
- if ((!(db_get_b(singlecontact, MODULENAME, ON_TOP_KEY, 0))) && done == 0)
- {
- db_set_b(singlecontact, MODULENAME, ON_TOP_KEY, 1);
- ontop = 1;
- done = 1;
- }
- return 0;
+ int ontop = 0;
+ int done = 0;
+
+ if (((db_get_b(singlecontact, MODULENAME, ON_TOP_KEY, 0))) && done == 0)
+ {
+ db_set_b(singlecontact, MODULENAME, ON_TOP_KEY, 0);
+ ontop = 0;
+ done = 1;
+ }
+ if ((!(db_get_b(singlecontact, MODULENAME, ON_TOP_KEY, 0))) && done == 0)
+ {
+ db_set_b(singlecontact, MODULENAME, ON_TOP_KEY, 1);
+ ontop = 1;
+ done = 1;
+ }
+ return 0;
}
-/*********************/
-
-/********************/
-int WebsiteMenuCommand(WPARAM wParam, LPARAM lParam)
-{
- DBVARIANT dbv;
- char url[300];
-
- url[0] = '\0';
-//
- DBGetContactSetting((HANDLE) wParam, MODULENAME, "URL", &dbv);
- wsprintf(url, "%s", dbv.pszVal);
- CallService(MS_UTILS_OPENURL, 1, (WPARAM) url);
- DBFreeVariant(&dbv);
- db_set_w((HANDLE) wParam, MODULENAME, "Status", ID_STATUS_ONLINE);
-// /
-
- return 0;
-}
-/*******************/
-
-
-/****************/
-int UpdateMenuCommand(WPARAM wParam, LPARAM lParam, HANDLE singlecontact)
+/*****************************************************************************/
+INT_PTR WebsiteMenuCommand(WPARAM wParam, LPARAM lParam)
{
+ HANDLE hContact = (HANDLE)wParam;
+ ptrT url( db_get_tsa(hContact, MODULENAME, "URL"));
+ if (url)
+ CallService(MS_UTILS_OPENURL, OUF_TCHAR, (WPARAM)url);
- forkthread(GetData, 0, singlecontact);
-
- return 0;
+ db_set_w(hContact, MODULENAME, "Status", ID_STATUS_ONLINE);
+ return 0;
}
-/***************/
-
-
-/*******************/
-int ContactMenuItemUpdateData (WPARAM wParam, LPARAM lParam)
+/*****************************************************************************/
+int UpdateMenuCommand(WPARAM wParam, LPARAM lParam, HANDLE singlecontact)
{
-UpdateMenuCommand(wParam, lParam, (HANDLE) wParam);
-return 0;
+ mir_forkthread(GetData, singlecontact);
+ return 0;
}
-/*******************/
-
-
-/********************/
-int CntOptionsMenuCommand(WPARAM wParam, LPARAM lParam)
+/*****************************************************************************/
+int ContactMenuItemUpdateData(WPARAM wParam, LPARAM lParam)
{
-
-HWND hwndDlg;
-
- if ((hwndDlg = (WindowList_Find(hWindowList, (HANDLE) wParam))))
- {
- DestroyWindow(hwndDlg);
- return 0;
- } else
- {
- hwndDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_CONTACT_OPT ), NULL, DlgProcContactOpt, (LPARAM) (HANDLE) wParam);
- ShowWindow(hwndDlg, SW_SHOW);
- SetActiveWindow(hwndDlg);
- }
- return 0;
+ UpdateMenuCommand(wParam, lParam, (HANDLE)wParam);
+ return 0;
}
-/*******************/
-/********************/
-int CntAlertMenuCommand(WPARAM wParam, LPARAM lParam)
+/*****************************************************************************/
+INT_PTR CntOptionsMenuCommand(WPARAM wParam, LPARAM lParam)
{
-
-HWND hwndDlg;
-
- if ((hwndDlg = (WindowList_Find(hWindowList, (HANDLE) wParam))))
- {
- DestroyWindow(hwndDlg);
- return 0;
- } else
- {
- hwndDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ALRT_OPT), NULL, DlgProcAlertOpt, (LPARAM) (HANDLE) wParam);
- ShowWindow(hwndDlg, SW_SHOW);
- SetActiveWindow(hwndDlg);
- }
- return 0;
+ HWND hwndDlg = WindowList_Find(hWindowList, (HANDLE)wParam);
+ if (hwndDlg) {
+ DestroyWindow(hwndDlg);
+ return 0;
+ }
+
+ hwndDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_CONTACT_OPT ), NULL, DlgProcContactOpt, (LPARAM) (HANDLE) wParam);
+ ShowWindow(hwndDlg, SW_SHOW);
+ SetActiveWindow(hwndDlg);
+ return 0;
}
-/*******************/
-int CountdownMenuCommand(WPARAM wParam, LPARAM lParam)
+/*****************************************************************************/
+INT_PTR CntAlertMenuCommand(WPARAM wParam, LPARAM lParam)
{
-
- return 0;
+ HWND hwndDlg = WindowList_Find(hWindowList, (HANDLE) wParam);
+ if (hwndDlg) {
+ DestroyWindow(hwndDlg);
+ return 0;
+ }
+
+ hwndDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ALRT_OPT), NULL, DlgProcAlertOpt, (LPARAM) (HANDLE) wParam);
+ ShowWindow(hwndDlg, SW_SHOW);
+ SetActiveWindow(hwndDlg);
+ return 0;
}
-/**************/
-
-void CheckDbKeys(void)
+/*****************************************************************************/
+INT_PTR CountdownMenuCommand(WPARAM wParam, LPARAM lParam)
{
- DBVARIANT dbv;
-
- if (DBGetContactSetting(NULL, MODULENAME, HAS_CRASHED_KEY, &dbv))
- {
- db_set_b(NULL, MODULENAME, HAS_CRASHED_KEY, 0);
- DBFreeVariant(&dbv);
- }
- if (DBGetContactSetting(NULL, MODULENAME, UPDATE_ONSTART_KEY, &dbv))
- {
- db_set_b(NULL, MODULENAME, UPDATE_ONSTART_KEY, 0);
- DBFreeVariant(&dbv);
- }
- if (DBGetContactSetting(NULL, MODULENAME, MENU_OFF, &dbv))
- {
- db_set_b(NULL, MODULENAME, MENU_OFF, 0);
- DBFreeVariant(&dbv);
- }
- if (DBGetContactSetting(NULL, MODULENAME, Ypos_WIN_KEY, &dbv))
- {
- db_set_dw(NULL, MODULENAME, Ypos_WIN_KEY, 0);
- DBFreeVariant(&dbv);
- }
- if (DBGetContactSetting(NULL, MODULENAME, Xpos_WIN_KEY, &dbv))
- {
- db_set_dw(NULL, MODULENAME, Xpos_WIN_KEY, 0);
- DBFreeVariant(&dbv);
- }
- if (DBGetContactSetting(NULL, MODULENAME, REFRESH_KEY, &dbv))
- {
- db_set_dw(NULL, MODULENAME, REFRESH_KEY, TIME);
- DBFreeVariant(&dbv);
- }
-
- if (DBGetContactSetting(NULL, MODULENAME, BG_COLOR_KEY, &dbv))
- {
- db_set_dw(NULL, MODULENAME, BG_COLOR_KEY, Def_color_bg);
- DBFreeVariant(&dbv);
- }
- if (DBGetContactSetting(NULL, MODULENAME, TXT_COLOR_KEY, &dbv))
- {
- db_set_dw(NULL, MODULENAME, TXT_COLOR_KEY, Def_color_txt);
- DBFreeVariant(&dbv);
- }
- if (DBGetContactSetting(NULL, MODULENAME, WIN_HEIGHT_KEY, &dbv))
- {
- db_set_dw(NULL, MODULENAME, WIN_HEIGHT_KEY, 152);
- DBFreeVariant(&dbv);
- }
- if (DBGetContactSetting(NULL, MODULENAME, SUPPRESS_ERR_KEY, &dbv))
- {
- db_set_b(NULL, MODULENAME, SUPPRESS_ERR_KEY, 0);
- DBFreeVariant(&dbv);
- }
- if (DBGetContactSetting(NULL, MODULENAME, WIN_WIDTH_KEY, &dbv))
- {
- db_set_dw(NULL, MODULENAME, WIN_WIDTH_KEY, 250);
- DBFreeVariant(&dbv);
- }
- if (DBGetContactSetting(NULL, MODULENAME, OFFLINE_STATUS, &dbv))
- {
- db_set_b(NULL, MODULENAME, OFFLINE_STATUS, 1);
- DBFreeVariant(&dbv);
- }
- if (DBGetContactSetting(NULL, MODULENAME, UPDATE_ON_OPEN_KEY, &dbv))
- {
- db_set_b(NULL, MODULENAME, UPDATE_ON_OPEN_KEY, 0);
- DBFreeVariant(&dbv);
- }
- if (DBGetContactSetting(NULL, MODULENAME, FONT_FACE_KEY, &dbv))
- {
- db_set_s(NULL, MODULENAME, FONT_FACE_KEY, "Courier");
- DBFreeVariant(&dbv);
- }
- if (DBGetContactSetting(NULL, MODULENAME, FONT_BOLD_KEY, &dbv))
- {
- db_set_b(NULL, MODULENAME, FONT_BOLD_KEY, 0);
- DBFreeVariant(&dbv);
- }
- if (DBGetContactSetting(NULL, MODULENAME, FONT_ITALIC_KEY, &dbv))
- {
- db_set_b(NULL, MODULENAME, FONT_ITALIC_KEY, 0);
- DBFreeVariant(&dbv);
- }
- if (DBGetContactSetting(NULL, MODULENAME, FONT_UNDERLINE_KEY, &dbv))
- {
- db_set_b(NULL, MODULENAME, FONT_UNDERLINE_KEY, 0);
- DBFreeVariant(&dbv);
- }
- if (DBGetContactSetting(NULL, MODULENAME, FONT_SIZE_KEY, &dbv))
- {
- db_set_b(NULL, MODULENAME, FONT_SIZE_KEY, 14);
- DBFreeVariant(&dbv);
- }
- if (DBGetContactSetting(NULL, MODULENAME, ERROR_POPUP_KEY, &dbv))
- {
- db_set_b(NULL, MODULENAME, ERROR_POPUP_KEY, 0);
- DBFreeVariant(&dbv);
- }
- if (DBGetContactSetting(NULL, MODULENAME, POP_DELAY_KEY, &dbv))
- {
- db_set_dw(NULL, MODULENAME, POP_DELAY_KEY, 0);
- DBFreeVariant(&dbv);
- }
- if (DBGetContactSetting(NULL, MODULENAME, POP_BG_CLR_KEY, &dbv))
- {
- db_set_dw(NULL, MODULENAME, POP_BG_CLR_KEY, Def_color_bg);
- DBFreeVariant(&dbv);
- }
- if (DBGetContactSetting(NULL, MODULENAME, POP_TXT_CLR_KEY, &dbv))
- {
- db_set_dw(NULL, MODULENAME, POP_TXT_CLR_KEY, Def_color_txt);
- DBFreeVariant(&dbv);
- }
- if (DBGetContactSetting(NULL, MODULENAME, POP_USEWINCLRS_KEY, &dbv))
- {
- db_set_b(NULL, MODULENAME, POP_USEWINCLRS_KEY, 0);
- DBFreeVariant(&dbv);
- }
- if (DBGetContactSetting(NULL, MODULENAME, MENU_IS_DISABLED_KEY, &dbv))
- {
- db_set_b(NULL, MODULENAME, MENU_IS_DISABLED_KEY, 0);
- DBFreeVariant(&dbv);
- }
- if (DBGetContactSetting(NULL, MODULENAME, UPDATE_ONALERT_KEY, &dbv))
- {
- db_set_b(NULL, MODULENAME, UPDATE_ONALERT_KEY, 0);
- DBFreeVariant(&dbv);
- }
- if (DBGetContactSetting(NULL, MODULENAME, DISABLE_AUTOUPDATE_KEY, &dbv))
- {
- db_set_b(NULL, MODULENAME, DISABLE_AUTOUPDATE_KEY, 0);
- DBFreeVariant(&dbv);
- }
- if (DBGetContactSetting(NULL, MODULENAME, POP_USESAMECLRS_KEY, &dbv))
- {
- db_set_b(NULL, MODULENAME, POP_USESAMECLRS_KEY, 1);
- DBFreeVariant(&dbv);
- }
- if (DBGetContactSetting(NULL, MODULENAME, POP_USECUSTCLRS_KEY, &dbv))
- {
- db_set_b(NULL, MODULENAME, POP_USECUSTCLRS_KEY, 0);
- DBFreeVariant(&dbv);
- }
- //
- if (DBGetContactSetting(NULL, MODULENAME, LCLK_WINDOW_KEY, &dbv))
- {
- db_set_b(NULL, MODULENAME, LCLK_WINDOW_KEY, 0);
- DBFreeVariant(&dbv);
- }
- if (DBGetContactSetting(NULL, MODULENAME, LCLK_WEB_PGE_KEY, &dbv))
- {
- db_set_b(NULL, MODULENAME, LCLK_WEB_PGE_KEY, 0);
- DBFreeVariant(&dbv);
- }
- if (DBGetContactSetting(NULL, MODULENAME, LCLK_DISMISS_KEY, &dbv))
- {
- db_set_b(NULL, MODULENAME, LCLK_DISMISS_KEY, 1);
- DBFreeVariant(&dbv);
- }
- if (DBGetContactSetting(NULL, MODULENAME, RCLK_WINDOW_KEY, &dbv))
- {
- db_set_b(NULL, MODULENAME, RCLK_WINDOW_KEY, 0);
- DBFreeVariant(&dbv);
- }
- if (DBGetContactSetting(NULL, MODULENAME, RCLK_WEB_PGE_KEY, &dbv))
- {
- db_set_b(NULL, MODULENAME, RCLK_WEB_PGE_KEY, 1);
- DBFreeVariant(&dbv);
- }
- if (DBGetContactSetting(NULL, MODULENAME, RCLK_DISMISS_KEY, &dbv))
- {
- db_set_b(NULL, MODULENAME, RCLK_DISMISS_KEY, 0);
- DBFreeVariant(&dbv);
- }
- if (DBGetContactSetting(NULL, MODULENAME, START_DELAY_KEY, &dbv))
- {
- db_set_dw(NULL, MODULENAME, START_DELAY_KEY, 0);
- DBFreeVariant(&dbv);
- }
- if (DBGetContactSetting(NULL, MODULENAME, SAVE_INDIVID_POS_KEY, &dbv))
- {
- db_set_b(NULL, MODULENAME, SAVE_INDIVID_POS_KEY, 0);
- DBFreeVariant(&dbv);
- }
- if (DBGetContactSetting(NULL, MODULENAME, NO_PROTECT_KEY, &dbv))
- {
- db_set_b(NULL, MODULENAME, NO_PROTECT_KEY, 0);
- DBFreeVariant(&dbv);
- }
- if (DBGetContactSetting(NULL, MODULENAME, FONT_SCRIPT_KEY, &dbv))
- {
- db_set_b(NULL, MODULENAME, FONT_SCRIPT_KEY, 0);
- DBFreeVariant(&dbv);
- }
-
- if (DBGetContactSetting(NULL, MODULENAME, DATA_POPUP_KEY, &dbv))
- {
- db_set_b(NULL, MODULENAME, DATA_POPUP_KEY, 0);
- DBFreeVariant(&dbv);
- }
-
-// if (DBGetContactSetting(NULL, MODULENAME, INBUILTPOP_KEY, &dbv))
-// {
-// db_set_b(NULL, MODULENAME, INBUILTPOP_KEY, 0);
-// DBFreeVariant(&dbv);
-// }
-
-
+ return 0;
}
-
-/***************/
diff --git a/plugins/WebView/src/webview.h b/plugins/WebView/src/webview.h
index d78adc247c..0e5dd41f3d 100644
--- a/plugins/WebView/src/webview.h
+++ b/plugins/WebView/src/webview.h
@@ -1,25 +1,69 @@
/*
- * A plugin for Miranda IM which displays web page text in a window Copyright
+ * 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
+ * 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
+ * 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.
+ * with this program; if not, write to the Free Software Foundation, Inc., 59
+ * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+#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"
@@ -60,364 +104,138 @@
#define TIME 60
#define Def_color_bg 0x00ffffff
#define Def_color_txt 0x00000000
+#define Def_font_face _T("Courier")
+#define Def_font_size 14
#define HK_SHOWHIDE 3001
#define MAXSIZE1 250000
#define MAXSIZE2 500000
#define MAXSIZE3 1000000
-static UINT expertOnlyControls[] =
-{IDC_ADV_GRP,
- IDC_NO_PROTECT,
-IDC_NOT_RECOMND_TXT};
+#define Def_win_height 152
+#define Def_win_width 250
//lets get rid of some warnings
-void ErrorMsgs(char *contactname, char *displaytext);
void CodetoSymbol(char *truncated);
-static void GetData(void *hContact);
-BOOL CALLBACK DlgProcDisplayData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
-void FillFontListThread(HWND hwndDlg);
-static BOOL CALLBACK DlgProcAlertOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
-int DataWndAlertCommand(void *AContact);
-
-
- // ///////////////////////
-// 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 GetData(HANDLE hContact);
+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 WPopupAlert(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 DWORD Xposition, Yposition, BackgoundClr, TextClr, WindowHeight, WindowWidth;
+extern UINT_PTR timerId, Countdown;
+extern LOGFONT lf;
+extern HFONT h_font;
+extern HWND ContactHwnd;
+extern HINSTANCE hInst;
+extern HMENU hMenu;
+extern int bpStatus;
+extern HANDLE hNetlibUser, hWindowList;
+extern HANDLE hMenuItem1, hMenuItemCountdown;
+extern char optionsname[80];
+
+//lets get rid of some warnings
+void timerfunc(void);
+void Countdownfunc(void);
+void SavewinSettings(void);
+void ValidatePosition(HWND hwndDlg);
+int ModulesLoaded(WPARAM wParam, LPARAM lParam);
+void ChangeMenuItem3();
+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 ContactOptionsMenuCommand(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 ShowHideContactCommand(WPARAM wParam, LPARAM lParam);
+INT_PTR PingWebsiteMenuCommand(WPARAM wParam, LPARAM lParam);
+INT_PTR StpPrcssMenuCommand(WPARAM wParam, LPARAM lParam);
+
+int UpdateMenuCommand(WPARAM wParam, LPARAM lParam, HANDLE singlecontact);
+int OnTopMenuCommand(WPARAM wParam, LPARAM lParam, HANDLE 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(HANDLE 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);
+
+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);
+void AckFunc(void *dummy);
+int SiteDeleted(WPARAM wParam, LPARAM lParam);
+
+int WErrorPopup(HANDLE hContact, TCHAR *textdisplay);
+int WAlertPopup(HANDLE hContact, TCHAR *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"
diff --git a/plugins/WebView/src/webview_alerts.cpp b/plugins/WebView/src/webview_alerts.cpp
index 285d3d34ea..fb2e287127 100644
--- a/plugins/WebView/src/webview_alerts.cpp
+++ b/plugins/WebView/src/webview_alerts.cpp
@@ -1,376 +1,239 @@
/*
- * 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.
- */
+* 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 HANDLE hWindowList = NULL;
-
-/**********************************/
-int CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
+/*****************************************************************************/
+int CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
- HANDLE hContact;
- char popupurl[300];
- DBVARIANT dbv;
-
- hContact = PUGetContact(hWnd);
-
- ZeroMemory(&popupurl, sizeof(popupurl));
- DBGetContactSetting(hContact, MODULENAME, URL_KEY, &dbv);
- _snprintf(popupurl, sizeof(popupurl), "%s", dbv.pszVal);
- DBFreeVariant(&dbv);
-
- switch (message)
- {
+ switch (message) {
case WM_COMMAND:
case WM_CONTEXTMENU:
- {
- if (message == WM_COMMAND) // left click
- {
- if(hContact != NULL)
- {
- // open data window
-
- if ((db_get_b(NULL, MODULENAME, LCLK_WINDOW_KEY, 0)))
- {
- NotifyEventHooks(hHookDisplayDataAlert, (int) hContact, 0);
- forkthread(GetData, 0, hContact);
- PUDeletePopUp(hWnd);
- }
- // open url
- if ((db_get_b(NULL, MODULENAME, LCLK_WEB_PGE_KEY, 0)))
- {
- CallService(MS_UTILS_OPENURL, (WPARAM) 1, (LPARAM) popupurl);
- PUDeletePopUp(hWnd);
- db_set_w((HANDLE) wParam, MODULENAME, "Status", ID_STATUS_ONLINE);
- }
- // dismiss
- if ((db_get_b(NULL, MODULENAME, LCLK_DISMISS_KEY, 0)))
- {
- PUDeletePopUp(hWnd);
- }
-
-
- }
-
- else if(hContact == NULL)
- PUDeletePopUp(hWnd);
-
+ HANDLE hContact = PUGetContact(hWnd);
+ ptrT url( db_get_tsa(hContact, MODULENAME, URL_KEY));
+
+ if (message == WM_COMMAND) { // left click
+ if(hContact != NULL) {
+ // open data window
+ if ( db_get_b(NULL, MODULENAME, LCLK_WINDOW_KEY, 0)) {
+ NotifyEventHooks(hHookDisplayDataAlert, (int) hContact, 0);
+ mir_forkthread(GetData, hContact);
+ PUDeletePopup(hWnd);
+ }
+ // open url
+ if ( db_get_b(NULL, MODULENAME, LCLK_WEB_PGE_KEY, 0)) {
+ CallService(MS_UTILS_OPENURL, OUF_TCHAR, (LPARAM)url);
+ PUDeletePopup(hWnd);
+ db_set_w((HANDLE)wParam, MODULENAME, "Status", ID_STATUS_ONLINE);
+ }
+ // dismiss
+ if ( db_get_b(NULL, MODULENAME, 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 ((db_get_b(NULL, MODULENAME, RCLK_WINDOW_KEY, 0)))
- {
- NotifyEventHooks(hHookDisplayDataAlert, (int) hContact, 0);
- forkthread(GetData, 0, hContact);
- PUDeletePopUp(hWnd);
- }
- // open url
- if ((db_get_b(NULL, MODULENAME, RCLK_WEB_PGE_KEY, 0)))
- {
- CallService(MS_UTILS_OPENURL, (WPARAM) 1, (LPARAM) popupurl);
- PUDeletePopUp(hWnd);
- db_set_w((HANDLE) wParam, MODULENAME, "Status", ID_STATUS_ONLINE);
- }
- // dismiss
- if ((db_get_b(NULL, MODULENAME, RCLK_DISMISS_KEY, 0)))
- {
- PUDeletePopUp(hWnd);
+ else if (message == WM_CONTEXTMENU) { // right click
+ if (hContact != NULL) {
+ // open datA window
+ if ( db_get_b(NULL, MODULENAME, RCLK_WINDOW_KEY, 0)) {
+ NotifyEventHooks(hHookDisplayDataAlert, (int) hContact, 0);
+ mir_forkthread(GetData, hContact);
+ PUDeletePopup(hWnd);
+ }
+ // open url
+ if ( db_get_b(NULL, MODULENAME, RCLK_WEB_PGE_KEY, 1)) {
+ CallService(MS_UTILS_OPENURL, OUF_TCHAR, (LPARAM)url);
+ PUDeletePopup(hWnd);
+ db_set_w((HANDLE)wParam, MODULENAME, "Status", ID_STATUS_ONLINE);
+ }
+ // dismiss
+ if ( db_get_b(NULL, MODULENAME, RCLK_DISMISS_KEY, 0))
+ PUDeletePopup(hWnd);
}
+ else if(hContact == NULL)
+ PUDeletePopup(hWnd);
}
- else if(hContact == NULL)
- PUDeletePopUp(hWnd);
- }
-
-
-
- }
- break;
+ break;
}
return DefWindowProc(hWnd, message, wParam, lParam);
}
-/*********************************/
-/*******************/
-int WDisplayDataAlert(void *AContact)
+/*****************************************************************************/
+int WDisplayDataAlert(void *hContact)
{
- NotifyEventHooks(hHookDisplayDataAlert, (int) AContact, 0);
+ NotifyEventHooks(hHookDisplayDataAlert, (int) hContact, 0);
return 0;
}
-/**************/
-/*******************/
-int WAlertPopup(WPARAM hContact, char *displaytext)
+/*****************************************************************************/
+int WAlertPopup(HANDLE hContact, TCHAR *displaytext)
{
- NotifyEventHooks(hHookAlertPopup, (WPARAM) hContact, (LPARAM) displaytext);
+ NotifyEventHooks(hHookAlertPopup, (WPARAM)hContact, (LPARAM)displaytext);
return 0;
}
-/**************/
-/*******************/
-//int WAlertPopup(WPARAM hContact, char *displaytext)
-int WAlertWPopup(WPARAM hContact, WCHAR *displaytext)
+/*****************************************************************************/
+int WErrorPopup(HANDLE hContact, TCHAR *textdisplay)
{
- NotifyEventHooks(hHookAlertWPopup, (WPARAM) hContact, (LPARAM) displaytext);
+ NotifyEventHooks(hHookErrorPopup, (WPARAM)hContact, (LPARAM) textdisplay);
return 0;
}
-/**************/
-
-/*******************/
-int WErrorPopup(char *namecontact, char *textdisplay)
+/*****************************************************************************/
+int WAlertOSD(HANDLE hContact, TCHAR *displaytext)
{
- NotifyEventHooks(hHookErrorPopup, (WPARAM) namecontact, (LPARAM) textdisplay);
+ NotifyEventHooks(hHookAlertOSD, (WPARAM)hContact, (LPARAM) displaytext);
return 0;
}
-/**************/
-/*******************/
-int WAlertOSD(WPARAM hContact, char *displaytext)
+
+/*****************************************************************************/
+int WPopupAlert(WPARAM wParam, LPARAM lParam)
{
- NotifyEventHooks(hHookAlertOSD, (WPARAM) hContact, (LPARAM) displaytext);
- return 0;
-}
-/**************/
+ POPUPDATAW ppd = { 0 };
-/********************/
+ if( ((HANDLE)wParam) != NULL) {
+ DBVARIANT dbv;
+ db_get_ts((HANDLE)wParam, MODULENAME, PRESERVE_NAME_KEY, &dbv);
+ lstrcpyn(ppd.lptzContactName, dbv.ptszVal, SIZEOF(ppd.lptzContactName));
+ db_free(&dbv);
+ }
+ else lstrcpy(ppd.lptzContactName, _A2T(MODULENAME));
-int WPopupAlert(WPARAM wParam, WCHAR *displaytext)
-{
- POPUPDATAW ppd;
- DWORD delay = 0;
- DWORD colorBack, colorText;
- char contactname[255];
- DBVARIANT dbv;
- char delaystr[4];
-
- // setup the popup
- ZeroMemory(&ppd, sizeof(POPUPDATAW));
- ZeroMemory(&contactname, sizeof(contactname));
+ ppd.lchContact = (HANDLE)wParam;
+ ppd.lchIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_SITE));
-if( ((HANDLE)wParam) != NULL)
-{
- DBGetContactSetting((HANDLE) wParam, MODULENAME, PRESERVE_NAME_KEY, &dbv);
- _snprintf(contactname, sizeof(contactname), "%s", dbv.pszVal);
- DBFreeVariant(&dbv);
-}
-else
-_snprintf(contactname, sizeof(contactname), "%s", MODULENAME);
-
-
- ppd.lchContact = (HANDLE) wParam;
- //
- MultiByteToWideChar(CP_UTF8, 0, contactname, -1, ppd.lptzContactName, strlen(contactname));
- //
- ppd.lchIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_SITE));
- //
- if ((wcslen(displaytext) == MAX_SECONDLINE) || (wcslen(displaytext) > MAX_SECONDLINE))
- _snwprintf(ppd.lptzText,MAX_SECONDLINE -1, displaytext);
- else if (wcslen(displaytext) < MAX_SECONDLINE)
- swprintf(ppd.lptzText, displaytext);
-
- //
- if ((db_get_b(NULL, MODULENAME, POP_USECUSTCLRS_KEY, 0)))
- {
- colorBack = db_get_dw(NULL, MODULENAME, POP_BG_CLR_KEY, 0);
- colorText = db_get_dw(NULL, MODULENAME, POP_TXT_CLR_KEY, 0);
+ TCHAR *displaytext = (TCHAR*)lParam;
+ if ((wcslen(displaytext) == MAX_SECONDLINE) || (wcslen(displaytext) > MAX_SECONDLINE))
+ mir_snwprintf(ppd.lptzText, SIZEOF(ppd.lptzText), displaytext);
+ else if (wcslen(displaytext) < MAX_SECONDLINE)
+ mir_snwprintf(ppd.lptzText, SIZEOF(ppd.lptzText), displaytext);
+
+ if ( db_get_b(NULL, MODULENAME, POP_USECUSTCLRS_KEY, 0)) {
+ ppd.colorBack = db_get_dw(NULL, MODULENAME, POP_BG_CLR_KEY, Def_color_bg);
+ ppd.colorBack = db_get_dw(NULL, MODULENAME, POP_TXT_CLR_KEY, Def_color_txt);
}
- if ((db_get_b(NULL, MODULENAME, POP_USEWINCLRS_KEY, 0)))
- {
- colorBack = GetSysColor(COLOR_BTNFACE);
- colorText = GetSysColor(COLOR_WINDOWTEXT);
+ if ( db_get_b(NULL, MODULENAME, POP_USEWINCLRS_KEY, 0)) {
+ ppd.colorBack = GetSysColor(COLOR_BTNFACE);
+ ppd.colorBack = GetSysColor(COLOR_WINDOWTEXT);
}
- if ((db_get_b(NULL, MODULENAME, POP_USESAMECLRS_KEY, 0)))
- {
- colorBack = BackgoundClr;
- colorText = TextClr;
+ if ( db_get_b(NULL, MODULENAME, POP_USESAMECLRS_KEY, 1)) {
+ ppd.colorBack = BackgoundClr;
+ ppd.colorBack = TextClr;
}
- ppd.colorBack = colorBack;
- ppd.colorText = colorText;
- //
- ppd.PluginWindowProc = NULL;
- //
- //ppd.iSeconds = (atol("5"));
- delay = db_get_dw(NULL, MODULENAME, POP_DELAY_KEY, 0);
- ppd.iSeconds = delay;
- //
-
- if (ServiceExists(MS_POPUP_ADDPOPUPW))
- CallService(MS_POPUP_ADDPOPUPW, (WPARAM) &ppd, 0);
-
-
-
-
-
- //////////////////////////////////////////////////////////////////////
-
-// if ((db_get_b(NULL, MODULENAME, INBUILTPOP_KEY, 0)))
-// PUShowMessage(displaytext, SM_NOTIFY);
-// else
-// {
-// }
+
+ ppd.PluginWindowProc = NULL;
+ ppd.iSeconds = db_get_dw(NULL, MODULENAME, POP_DELAY_KEY, 0);
+
+ if (ServiceExists(MS_POPUP_ADDPOPUPW))
+ CallService(MS_POPUP_ADDPOPUPW, (WPARAM)&ppd, 0);
return 0;
-
}
-/********************/
-/********************/
-int PopupAlert(WPARAM wParam, char *displaytext)
+/*****************************************************************************/
+int PopupAlert(WPARAM wParam, LPARAM lParam)
{
- POPUPDATAEX ppd;
- DWORD delay = 0;
- DWORD colorBack, colorText;
- char contactname[255];
- DBVARIANT dbv;
- char delaystr[4];
-
- // setup the popup
- ZeroMemory(&ppd, sizeof(POPUPDATA));
- ZeroMemory(&contactname, sizeof(contactname));
+ POPUPDATA ppd = { 0 };
+ if (((HANDLE)wParam) != NULL) {
+ DBVARIANT dbv;
+ db_get_s((HANDLE)wParam, MODULENAME, PRESERVE_NAME_KEY, &dbv);
+ lstrcpynA(ppd.lptzContactName, dbv.pszVal, SIZEOF(ppd.lptzContactName));
+ db_free(&dbv);
+ }
+ else lstrcpyA(ppd.lptzContactName, MODULENAME);
-if( ((HANDLE)wParam) != NULL)
-{
- DBGetContactSetting((HANDLE) wParam, MODULENAME, PRESERVE_NAME_KEY, &dbv);
- _snprintf(contactname, sizeof(contactname), "%s", dbv.pszVal);
- DBFreeVariant(&dbv);
-}
-else
-_snprintf(contactname, sizeof(contactname), "%s", MODULENAME);
-
-
-
- ppd.lchContact = (HANDLE) wParam;
- strcpy(ppd.lpzContactName, contactname);
- ppd.lchIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_SITE));
- //
- //sprintf(ppd.lpzText, Translate("This is a preview popup."));
- if ((strlen(displaytext) == MAX_SECONDLINE) || (strlen(displaytext) > MAX_SECONDLINE))
- _snprintf(ppd.lpzText,MAX_SECONDLINE -1, "%s", displaytext);
- else if (strlen(displaytext) < MAX_SECONDLINE)
- sprintf(ppd.lpzText, Translate(displaytext));
- //
- if ((db_get_b(NULL, MODULENAME, POP_USECUSTCLRS_KEY, 0)))
- {
- colorBack = db_get_dw(NULL, MODULENAME, POP_BG_CLR_KEY, 0);
- colorText = db_get_dw(NULL, MODULENAME, POP_TXT_CLR_KEY, 0);
+ ppd.lchContact = (HANDLE)wParam;
+ ppd.lchIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_SITE));
+
+ char *displaytext = (char*)lParam;
+ if ((strlen(displaytext) == MAX_SECONDLINE) || (strlen(displaytext) > MAX_SECONDLINE))
+ mir_snprintf(ppd.lpzText, SIZEOF(ppd.lpzText), "%s", displaytext);
+ else if (strlen(displaytext) < MAX_SECONDLINE)
+ mir_snprintf(ppd.lpzText, SIZEOF(ppd.lpzText), Translate(displaytext));
+
+ if ( db_get_b(NULL, MODULENAME, POP_USECUSTCLRS_KEY, 0)) {
+ ppd.colorBack = db_get_dw(NULL, MODULENAME, POP_BG_CLR_KEY, Def_color_bg);
+ ppd.colorText = db_get_dw(NULL, MODULENAME, POP_TXT_CLR_KEY, Def_color_txt);
}
- if ((db_get_b(NULL, MODULENAME, POP_USEWINCLRS_KEY, 0)))
- {
- colorBack = GetSysColor(COLOR_BTNFACE);
- colorText = GetSysColor(COLOR_WINDOWTEXT);
+ if ( db_get_b(NULL, MODULENAME, POP_USEWINCLRS_KEY, 0)) {
+ ppd.colorBack = GetSysColor(COLOR_BTNFACE);
+ ppd.colorText = GetSysColor(COLOR_WINDOWTEXT);
}
- if ((db_get_b(NULL, MODULENAME, POP_USESAMECLRS_KEY, 0)))
- {
- colorBack = BackgoundClr;
- colorText = TextClr;
+ if ( db_get_b(NULL, MODULENAME, POP_USESAMECLRS_KEY, 1)) {
+ ppd.colorBack = BackgoundClr;
+ ppd.colorText = TextClr;
}
- ppd.colorBack = colorBack;
- ppd.colorText = colorText;
- //
- ppd.PluginWindowProc = NULL;
- //
- //ppd.iSeconds = (atol("5"));
- delay = db_get_dw(NULL, MODULENAME, POP_DELAY_KEY, 0);
- ppd.iSeconds = delay;
- //
-
- if (ServiceExists(MS_POPUP_ADDPOPUPEX))
- CallService(MS_POPUP_ADDPOPUPEX, (WPARAM) &ppd, 0);
-
-
-
-
- //////////////////////////////////////////////////////////////////////
-
-// if ((db_get_b(NULL, MODULENAME, INBUILTPOP_KEY, 0)))
-// PUShowMessage(displaytext, SM_NOTIFY);
-// else
-// {
-// }
-
- return 0;
-
-}
-/********************/
-
-/********************/
-int OSDAlert(WPARAM wParam, char *displaytext)
-{
- char contactname[255];
- DBVARIANT dbv;
- char newdisplaytext[2000];
+ ppd.PluginWindowProc = NULL;
+ ppd.iSeconds = db_get_dw(NULL, MODULENAME, POP_DELAY_KEY, 0);
- ZeroMemory(&contactname, sizeof(contactname));
- ZeroMemory(&newdisplaytext, sizeof(newdisplaytext));
+ if (ServiceExists(MS_POPUP_ADDPOPUP))
+ CallService(MS_POPUP_ADDPOPUP, (WPARAM)&ppd, 0);
+ return 0;
+}
-if(((HANDLE)wParam) != NULL)
+/*****************************************************************************/
+int OSDAlert(WPARAM wParam, LPARAM lParam)
{
- DBGetContactSetting((HANDLE) wParam, MODULENAME, PRESERVE_NAME_KEY, &dbv);
- _snprintf(contactname, sizeof(contactname), "%s", dbv.pszVal);
- DBFreeVariant(&dbv);
-}
-else
-_snprintf(contactname, sizeof(contactname), "%s", MODULENAME);
+ char contactname[255], newdisplaytext[2000];
+ if (((HANDLE)wParam) != NULL) {
+ DBVARIANT dbv;
+ db_get_s((HANDLE)wParam, MODULENAME, PRESERVE_NAME_KEY, &dbv);
+ lstrcpynA(contactname, dbv.pszVal, SIZEOF(contactname));
+ db_free(&dbv);
+ }
+ else lstrcpyA(contactname, MODULENAME);
- _snprintf(newdisplaytext, sizeof(newdisplaytext), "%s: %s", contactname, Translate(displaytext));
+ char *displaytext = (char*)lParam;
+ mir_snprintf(newdisplaytext, sizeof(newdisplaytext), "%s: %s", contactname, Translate(displaytext));
if (ServiceExists("OSD/Announce"))
CallService("OSD/Announce", (WPARAM) newdisplaytext, 0);
return 0;
}
-/********************/
-/*****************/
-void ErrorMsgs(char *contactname, char *displaytext)
+/*****************************************************************************/
+int ErrorMsgs(WPARAM wParam, LPARAM lParam)
{
char newdisplaytext[2000];
+ char *contactname = (char*)wParam, *displaytext = (char*)lParam;
- if (!(db_get_b(NULL, MODULENAME, SUPPRESS_ERR_KEY, 0)))
- {
- if ((ServiceExists(MS_POPUP_ADDPOPUP) != 0) && ((db_get_b(NULL, MODULENAME, ERROR_POPUP_KEY, 0))))
- {
+ if ( !db_get_b(NULL, MODULENAME, SUPPRESS_ERR_KEY, 0)) {
+ if ((ServiceExists(MS_POPUP_ADDPOPUP) != 0) && ((db_get_b(NULL, MODULENAME, ERROR_POPUP_KEY, 0)))) {
_snprintf(newdisplaytext, sizeof(newdisplaytext), "%s\n%s", contactname, displaytext);
PUShowMessage(newdisplaytext, SM_WARNING);
- } else if ((ServiceExists("OSD/Announce") != 0) && ((db_get_b(NULL, MODULENAME, ERROR_POPUP_KEY, 0))))
- {
+ }
+ else if ( ServiceExists("OSD/Announce") && db_get_b(NULL, MODULENAME, ERROR_POPUP_KEY, 0)) {
_snprintf(newdisplaytext, sizeof(newdisplaytext), "%s: %s", contactname, Translate(displaytext));
CallService("OSD/Announce", (WPARAM) newdisplaytext, 0);
- } else if (ServiceExists(MS_CLIST_SYSTRAY_NOTIFY))
- {
+ }
+ else if (ServiceExists(MS_CLIST_SYSTRAY_NOTIFY)) {
MIRANDASYSTRAYNOTIFY webview_tip = {0};
-
webview_tip.cbSize = sizeof(MIRANDASYSTRAYNOTIFY);
webview_tip.szProto = NULL;
webview_tip.szInfoTitle = contactname;
@@ -378,115 +241,73 @@ void ErrorMsgs(char *contactname, char *displaytext)
webview_tip.dwInfoFlags = NIIF_ERROR;
webview_tip.uTimeout = 15000;
CallService(MS_CLIST_SYSTRAY_NOTIFY, 0, (LPARAM) &webview_tip);
- } // ////////////
-
+ }
}
+ return 0;
}
-/********************/
-/***************************/
-void SaveToFile(char *AContact, char *truncated)
+/*****************************************************************************/
+void SaveToFile(HANDLE hContact, char *truncated)
{
- FILE *pfile;
- char*mode;
- DBVARIANT dbv;
- char url[300];
- char contactname[100];
-
- ZeroMemory(&contactname, sizeof(contactname));
- DBGetContactSetting(AContact, "CList", "MyHandle", &dbv);
- _snprintf(contactname, sizeof(contactname), "%s", dbv.pszVal);
- DBFreeVariant(&dbv);
-
- if (!(db_get_b(AContact, MODULENAME, APPEND_KEY, 0)))
+ char *mode;
+ if (!db_get_b(hContact, MODULENAME, APPEND_KEY, 0))
mode = "w";
else
mode = "a";
- url[0] = '\0';
-
- DBGetContactSetting(AContact, MODULENAME, URL_KEY, &dbv);
+ char url[300]; url[0] = '\0';
+ DBVARIANT dbv;
+ db_get_s(hContact, MODULENAME, URL_KEY, &dbv);
_snprintf(url, sizeof(url), "%s", dbv.pszVal);
+ db_free(&dbv);
- DBFreeVariant(&dbv);
-
- DBGetContactSetting(AContact, MODULENAME, FILE_KEY, &dbv);
- if ((pfile = fopen(dbv.pszVal, mode)) == NULL)
- {
- WErrorPopup(contactname, Translate("Cannot write to file"));
- } else
- {
-//
-
- char tstr[128];
- char timestring[128];
- char timeprefix[32];
- char temptime1[32];
- char temptime2[32];
- char temptime[128];
- time_t ftime;
- struct tm *nTime;
-
- ZeroMemory(&tstr, sizeof(tstr));
- ZeroMemory(&temptime, sizeof(temptime));
- ZeroMemory(&timeprefix, sizeof(timeprefix));
- ZeroMemory(&temptime1, sizeof(temptime1));
- ZeroMemory(&temptime2, sizeof(temptime2));
- ZeroMemory(&timestring, sizeof(timestring));
+ db_get_s(hContact, MODULENAME, FILE_KEY, &dbv);
+ FILE *pfile = fopen(dbv.pszVal, mode);
+ if (pfile == NULL)
+ WErrorPopup(hContact, TranslateT("Cannot write to file"));
+ else {
+ char timestring[128], timeprefix[32];
+ char temptime1[32], temptime2[32];
setlocale(LC_ALL, "");
- ftime = time(NULL);
- nTime = localtime(&ftime);
+ time_t ftime = time(NULL);
+ struct tm *nTime = localtime(&ftime);
- _snprintf(timeprefix, sizeof(timeprefix), " %s ", (Translate("Last updated on")));
+ mir_snprintf(timeprefix, sizeof(timeprefix), " %s ", Translate("Last updated on"));
strftime(temptime1, 32, " %a, %b %d, %Y ", nTime);
strftime(temptime2, 32, " %I:%M %p.", nTime);
- _snprintf(timestring, sizeof(timestring), "(%s)%s\n%s,%s\n", MODULENAME, url, temptime1, temptime2);
+ mir_snprintf(timestring, sizeof(timestring), "(%s)%s\n%s,%s\n", MODULENAME, url, temptime1, temptime2);
fputs(timestring, pfile);
-//
-
fwrite(truncated, strlen(truncated), 1, pfile);
-
fputs("\n\n", pfile);
-
fclose(pfile);
}
- DBFreeVariant(&dbv);
+ db_free(&dbv);
}
-/***************************/
-
-/**************************/
-int ProcessAlerts(HANDLE AContact, char *truncated, char *tstr, char *contactname, int notpresent)
+/*****************************************************************************/
+int ProcessAlerts(HANDLE hContact, char *truncated, char *tstr, char *contactname, int notpresent)
{
-
char alertstring[255];
- char displaystring[300];
+ TCHAR displaystring[300];
FILE *pcachefile;
- char cachepath[MAX_PATH];
- char cachedirectorypath[MAX_PATH];
- char newcachepath[MAX_PATH + 50];
- char*cacheend;
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];
- //
char tempraw[MAXSIZE1];
- char statustext[200];
int alertIndex = 0;
int eventIndex = 0;
-//MessageBox(NULL, contactname, "pro-contname2", MB_OK);
+ //MessageBox(NULL, contactname, "pro-contname2", MB_OK);
ZeroMemory(&tempraw, sizeof(tempraw));
ZeroMemory(&raw, sizeof(raw));
@@ -494,61 +315,33 @@ int ProcessAlerts(HANDLE AContact, char *truncated, char *tstr, char *contactnam
strncpy(tempraw, truncated, sizeof(tempraw));
ZeroMemory(&alertstring, sizeof(alertstring));
- ZeroMemory(&cachepath, sizeof(cachepath));
- ZeroMemory(&cachedirectorypath, sizeof(cachedirectorypath));
- ZeroMemory(&newcachepath, sizeof(newcachepath));
ZeroMemory(&Alerttempstring, sizeof(Alerttempstring));
ZeroMemory(&Alerttempstring2, sizeof(Alerttempstring2));
ZeroMemory(&cachecompare, sizeof(cachecompare));
- //
-
// alerts
- if ((db_get_b(AContact, MODULENAME, ENABLE_ALERTS_KEY, 0))) // ALERTS
- //
- // ARE
- // ENABLED
-
- {
-
- if (!DBGetContactSetting(AContact, MODULENAME, ALRT_INDEX_KEY, &tdbv)) // TYPES
- //
- // OF
- // ALERTS
-
- {
- alertIndex = db_get_b(AContact, MODULENAME, ALRT_INDEX_KEY, 0);
- DBFreeVariant(&tdbv);
-
- if (!DBGetContactSetting(AContact, MODULENAME, EVNT_INDEX_KEY, &tdbv))
- {
-
- eventIndex = db_get_b(AContact, MODULENAME, EVNT_INDEX_KEY, 0);
- DBFreeVariant(&tdbv);
+ if ( db_get_b(hContact, MODULENAME, ENABLE_ALERTS_KEY, 0)) { // ALERTS
+ if (!db_get_s(hContact, MODULENAME, ALRT_INDEX_KEY, &tdbv)) { // TYPES
+ alertIndex = db_get_b(hContact, MODULENAME, ALRT_INDEX_KEY, 0);
+ db_free(&tdbv);
+
+ if (!db_get_s(hContact, MODULENAME, EVNT_INDEX_KEY, &tdbv)) {
+ eventIndex = db_get_b(hContact, MODULENAME, EVNT_INDEX_KEY, 0);
+ db_free(&tdbv);
}
- if ((notpresent))
- {
- if (alertIndex == 0) // Popup
-
- {
+ if ((notpresent)) {
+ if (alertIndex == 0) { // Popup
Sleep(1000);
- sprintf(displaystring, "%s", (Translate("Start/end strings not found or strings not set.")));
- WAlertPopup((WPARAM) AContact, displaystring);
+ WAlertPopup(hContact, TranslateT("Start/end strings not found or strings not set."));
// contactlist name//
- if ((db_get_b(AContact, MODULENAME, APND_DATE_NAME_KEY, 0)))
- db_set_s(AContact, "CList", "MyHandle", tstr);
- } //
-
- else if (alertIndex == 1) // log to file
-
- {
- if (!DBGetContactSetting(AContact, MODULENAME, FILE_KEY, &tdbv))
- {
+ if ( db_get_b(hContact, MODULENAME, APND_DATE_NAME_KEY, 0))
+ db_set_s(hContact, "CList", "MyHandle", tstr);
+ }
+ else if (alertIndex == 1) { // log to file
+ if ( !db_get_s(hContact, MODULENAME, FILE_KEY, &tdbv)) {
int AmountWspcRem = 0;
- if (!(db_get_b(AContact, MODULENAME, SAVE_AS_RAW_KEY, 0)))
- {
- //
+ if ( !db_get_b(hContact, MODULENAME, SAVE_AS_RAW_KEY, 0)) {
CodetoSymbol(tempraw);
Sleep(100); // avoid 100% CPU
@@ -564,89 +357,63 @@ int ProcessAlerts(HANDLE AContact, char *truncated, char *tstr, char *contactnam
EraseSymbols(tempraw);
Sleep(100); // avoid 100% CPU
- AmountWspcRem = db_get_b(AContact, MODULENAME, RWSPACE_KEY, 0);
+ AmountWspcRem = db_get_b(hContact, MODULENAME, RWSPACE_KEY, 0);
RemoveInvis(tempraw, AmountWspcRem);
Sleep(100); // avoid 100% CPU
Removewhitespace(tempraw);
}
- //
- SaveToFile(AContact, tempraw);
- DBFreeVariant(&tdbv);
- // contactlist name//
- if ((db_get_b(AContact, MODULENAME, APND_DATE_NAME_KEY, 0)))
- db_set_s(AContact, "CList", "MyHandle", tstr);
- }
- } //
-
- else if (alertIndex == 3) // osd
- {
- WAlertOSD((WPARAM) AContact, Translate("Alert start/end strings not found or strings not set."));
- // contactlist name//
- if ((db_get_b(AContact, MODULENAME, APND_DATE_NAME_KEY, 0)))
- db_set_s(AContact, "CList", "MyHandle", tstr);
- } else if (eventIndex == 2) // window
+ SaveToFile(hContact, tempraw);
+ db_free(&tdbv);
- {
- WDisplayDataAlert(AContact);
- // contactlist name//
- if ((db_get_b(AContact, MODULENAME, APND_DATE_NAME_KEY, 0)))
- db_set_s(AContact, "CList", "MyHandle", tstr);
+ if ( db_get_b(hContact, MODULENAME, 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 ( db_get_b(hContact, MODULENAME, APND_DATE_NAME_KEY, 0))
+ db_set_s(hContact, "CList", "MyHandle", tstr);
+ }
+ else if (eventIndex == 2) {
+ WDisplayDataAlert(hContact);
- HWND hwndDlg = (WindowList_Find(hWindowList, AContact));
+ if ( db_get_b(hContact, MODULENAME, APND_DATE_NAME_KEY, 0))
+ db_set_s(hContact, "CList", "MyHandle", tstr);
- ZeroMemory(&statustext, sizeof(statustext));
- _snprintf(statustext, sizeof(statustext), " %s", Translate("Start/end strings not found or strings not set."));
- SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext);
- } //
+ HWND hwndDlg = (WindowList_Find(hWindowList, hContact));
- else
- MessageBox(NULL, Translate("Start/end strings not found or strings not set."), MODULENAME, MB_OK);
+ SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Start/end strings not found or strings not set."));
+ }
+ else MessageBox(NULL, TranslateT("Start/end strings not found or strings not set."), _T(MODULENAME), MB_OK);
}
- if (eventIndex == 0) // string present
-
- {
- if (!DBGetContactSetting(AContact, MODULENAME, ALERT_STRING_KEY, &tdbv))
- {
+ if (eventIndex == 0) { // string present
+ if ( !db_get_s(hContact, MODULENAME, ALERT_STRING_KEY, &tdbv)) {
strncpy(alertstring, tdbv.pszVal, sizeof(alertstring));
- DBFreeVariant(&tdbv);
-
- if ((strstr(tempraw, alertstring)) != 0)
- { // // ENDALERT EVENT:CHECK FOR STRING
+ db_free(&tdbv);
+ if ((strstr(tempraw, alertstring)) != 0) { // // ENDALERT EVENT:CHECK FOR STRING
// there was an alert
wasAlert = 1;
// play sound?
SkinPlaySound("webviewalert");
//
- if ((!notpresent))
- {
-
- if (alertIndex == 0) // popup
-
- {
- sprintf(displaystring, "%s \"%s\" %s.", (Translate("The string")), alertstring, (Translate("has been found on the web page")));
- WAlertPopup((WPARAM) AContact, displaystring);
+ if ((!notpresent)) {
+ if (alertIndex == 0) { // popup
+ mir_sntprintf(displaystring, SIZEOF(displaystring), _T("%s \"%S\" %s."), Translate("The string"), alertstring, Translate("has been found on the web page"));
+ WAlertPopup(hContact, displaystring);
// contactlist name//
- if ((db_get_b(AContact, MODULENAME, APND_DATE_NAME_KEY, 0)))
- db_set_s(AContact, "CList", "MyHandle", tstr);
+ if ( db_get_b(hContact, MODULENAME, APND_DATE_NAME_KEY, 0))
+ db_set_s(hContact, "CList", "MyHandle", tstr);
} //
-
- else if (alertIndex == 1) // LOG
-
- {
- if (!DBGetContactSetting(AContact, MODULENAME, FILE_KEY, &tdbv))
- {
-
+ else if (alertIndex == 1) {
+ if (!db_get_s(hContact, MODULENAME, FILE_KEY, &tdbv)) {
int AmountWspcRem = 0;
-
- if (!(db_get_b(AContact, MODULENAME, SAVE_AS_RAW_KEY, 0)))
- {
- //
+ if ( !db_get_b(hContact, MODULENAME, SAVE_AS_RAW_KEY, 0)) {
CodetoSymbol(tempraw);
Sleep(100); // avoid 100% CPU
@@ -662,130 +429,96 @@ int ProcessAlerts(HANDLE AContact, char *truncated, char *tstr, char *contactnam
EraseSymbols(tempraw);
Sleep(100); // avoid 100% CPU
- AmountWspcRem = db_get_b(AContact, MODULENAME, RWSPACE_KEY, 0);
+ AmountWspcRem = db_get_b(hContact, MODULENAME, RWSPACE_KEY, 0);
RemoveInvis(tempraw, AmountWspcRem);
Sleep(100); // avoid 100% CPU
Removewhitespace(tempraw);
- //
}
- SaveToFile(AContact, tempraw);
- DBFreeVariant(&tdbv);
- // contactlist name//
- if ((db_get_b(AContact, MODULENAME, APND_DATE_NAME_KEY, 0)))
- db_set_s(AContact, "CList", "MyHandle", tstr);
- }
- } //
-
- else if (alertIndex == 3) // osd
+ SaveToFile(hContact, tempraw);
+ db_free(&tdbv);
- {
- sprintf(displaystring, "%s \"%s\" %s.", (Translate("The string")), alertstring, (Translate("has been found on the web page")));
- WAlertOSD((WPARAM) AContact, displaystring);
+ if ( db_get_b(hContact, MODULENAME, APND_DATE_NAME_KEY, 0))
+ db_set_s(hContact, "CList", "MyHandle", tstr);
+ }
+ }
+ else if (alertIndex == 3) {
+ mir_sntprintf(displaystring, SIZEOF(displaystring), _T("%s \"%s\" %s."), TranslateT("The string"), alertstring, TranslateT("has been found on the web page"));
+ WAlertOSD(hContact, displaystring);
// contactlist name//
- if ((db_get_b(AContact, MODULENAME, APND_DATE_NAME_KEY, 0)))
- db_set_s(AContact, "CList", "MyHandle", tstr);
- } else if (alertIndex == 2) // window
-
- {
- WDisplayDataAlert(AContact);
+ if ( db_get_b(hContact, MODULENAME, APND_DATE_NAME_KEY, 0))
+ db_set_s(hContact, "CList", "MyHandle", tstr);
+ }
+ else if (alertIndex == 2) {
+ WDisplayDataAlert(hContact);
// contactlist name//
- if ((db_get_b(AContact, MODULENAME, APND_DATE_NAME_KEY, 0)))
- db_set_s(AContact, "CList", "MyHandle", tstr);
-
- HWND hwndDlg = (WindowList_Find(hWindowList, AContact));
+ if ( db_get_b(hContact, MODULENAME, APND_DATE_NAME_KEY, 0))
+ db_set_s(hContact, "CList", "MyHandle", tstr);
- ZeroMemory(&statustext, sizeof(statustext));
- _snprintf(statustext, sizeof(statustext), " %s", Translate("Download successful; about to process data..."));
- SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext);
- } //
-
- else
- MessageBox(NULL, Translate("Unknown Alert Type."), MODULENAME, MB_OK);
+ HWND hwndDlg = WindowList_Find(hWindowList, hContact);
+ SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Download successful; about to process data..."));
+ }
+ else MessageBox(NULL, TranslateT("Unknown Alert Type."), _T(MODULENAME), MB_OK);
}
- //
- } // // END ALERT EVENT:CHECK FOR STRING
-
- } // alert string
-
- } else if (eventIndex == 1) // webpage changed
-
- {
-
+ }
+ }
+ }
+ else if (eventIndex == 1) { // webpage changed
// TEST GET NAME FOR CACHE
+ TCHAR cachepath[MAX_PATH], cachedirectorypath[MAX_PATH], newcachepath[MAX_PATH + 50];
GetModuleFileName(hInst, cachepath, sizeof(cachepath));
- cacheend = strrchr(cachepath, '\\');
+ TCHAR *cacheend = _tcsrchr(cachepath, '\\');
cacheend++;
*cacheend = '\0';
- _snprintf(cachedirectorypath, sizeof(cachedirectorypath), "%s%s%s", cachepath, MODULENAME, "cache\\");
+ mir_sntprintf(cachedirectorypath, SIZEOF(cachedirectorypath), _T("%s%S%S"), cachepath, MODULENAME, "cache\\");
CreateDirectory(cachedirectorypath, NULL);
- _snprintf(newcachepath, sizeof(newcachepath), "%s%s%s%s%s", cachepath, MODULENAME, "cache\\", contactname, ".txt");
+ mir_sntprintf(newcachepath, SIZEOF(newcachepath), _T("%s%S%S%S%S"), cachepath, MODULENAME, "cache\\", contactname, ".txt");
// file exists?
- if ((_access(newcachepath, 0)) != -1)
- {
- if ((pcachefile = fopen(newcachepath, "r")) == NULL)
- {
- WErrorPopup(contactname, Translate("Cannot read from file"));
- } else
- {
+ if ( _taccess(newcachepath, 0) != -1) {
+ if ((pcachefile = _tfopen(newcachepath, _T("r"))) == NULL)
+ WErrorPopup(contactname, TranslateT("Cannot read from file"));
+ else {
ZeroMemory(&cachecompare, sizeof(cachecompare));
fread(cachecompare, sizeof(cachecompare), 1, pcachefile);
fclose(pcachefile);
}
}
// write to cache
- if ((pcachefile = fopen(newcachepath, "w")) == NULL)
- {
- WErrorPopup(contactname, Translate("Cannot write to file 1"));
- MessageBox(NULL, newcachepath, "1", MB_OK);
- } else
- {
-
+ if ((pcachefile = _tfopen(newcachepath, _T("w"))) == NULL)
+ WErrorPopup(contactname, TranslateT("Cannot write to file 1"));
+ else {
fwrite(tempraw, strlen(tempraw), 1, pcachefile); //smaller cache
fclose(pcachefile);
- db_set_s(AContact, MODULENAME, CACHE_FILE_KEY, newcachepath);
+ db_set_ts(hContact, MODULENAME, CACHE_FILE_KEY, newcachepath);
}
// end write to cache
- if (strncmp(tempraw, cachecompare, (strlen(tempraw))) != 0) //lets try this instead
- {
-
+ if (strncmp(tempraw, cachecompare, strlen(tempraw)) != 0) { //lets try this instead
// play sound?
SkinPlaySound("webviewalert");
// there was an alert
wasAlert = 1;
- if ((!notpresent))
- {
-
- if (alertIndex == 0) // popup
-
- {
- WAlertPopup((WPARAM) AContact, Translate("The Web Page Has Changed."));
+ if (!notpresent) {
+ if (alertIndex == 0) { // popup
+ WAlertPopup(hContact, TranslateT("The Web Page Has Changed."));
// contactlist name//
- if ((db_get_b(AContact, MODULENAME, APND_DATE_NAME_KEY, 0)))
- db_set_s(AContact, "CList", "MyHandle", tstr);
- } //
-
- else if (alertIndex == 3) // osd
-
- {
- WAlertOSD((WPARAM) AContact, Translate("The Web Page Has Changed."));
+ if ( db_get_b(hContact, MODULENAME, 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 ((db_get_b(AContact, MODULENAME, APND_DATE_NAME_KEY, 0)))
- db_set_s(AContact, "CList", "MyHandle", tstr);
- } else if (alertIndex == 1) // log
-
- {
- if (!DBGetContactSetting(AContact, MODULENAME, FILE_KEY, &tdbv))
- {
+ if ( db_get_b(hContact, MODULENAME, APND_DATE_NAME_KEY, 0))
+ db_set_s(hContact, "CList", "MyHandle", tstr);
+ }
+ else if (alertIndex == 1) { // log
+ if (!db_get_s(hContact, MODULENAME, FILE_KEY, &tdbv)) {
int AmountWspcRem = 0;
- if (!(db_get_b(AContact, MODULENAME, SAVE_AS_RAW_KEY, 0)))
- {
- //
+ if ( !db_get_b(hContact, MODULENAME, SAVE_AS_RAW_KEY, 0)) {
CodetoSymbol(tempraw);
Sleep(100); // avoid 100% CPU
@@ -801,131 +534,96 @@ int ProcessAlerts(HANDLE AContact, char *truncated, char *tstr, char *contactnam
EraseSymbols(tempraw);
Sleep(100); // avoid 100% CPU
- AmountWspcRem = db_get_b(AContact, MODULENAME, RWSPACE_KEY, 0);
+ AmountWspcRem = db_get_b(hContact, MODULENAME, RWSPACE_KEY, 0);
RemoveInvis(tempraw, AmountWspcRem);
Sleep(100); // avoid 100% CPU
Removewhitespace(tempraw);
}
- //
- SaveToFile(AContact, tempraw);
- DBFreeVariant(&tdbv);
+
+ SaveToFile(hContact, tempraw);
+ db_free(&tdbv);
// contactlist name//
- if ((db_get_b(AContact, MODULENAME, APND_DATE_NAME_KEY, 0)))
- db_set_s(AContact, "CList", "MyHandle", tstr);
+ if ( db_get_b(hContact, MODULENAME, APND_DATE_NAME_KEY, 0))
+ db_set_s(hContact, "CList", "MyHandle", tstr);
}
- } //
-
- else if (alertIndex == 2) // window
-
- {
- WDisplayDataAlert(AContact);
+ }
+ else if (alertIndex == 2) { // window
+ WDisplayDataAlert(hContact);
// contactlist name//
- if ((db_get_b(AContact, MODULENAME, APND_DATE_NAME_KEY, 0)))
- db_set_s(AContact, "CList", "MyHandle", tstr);
- } //
-
- else
- MessageBox(NULL, Translate("Unknown Alert Type."), MODULENAME, MB_OK);
+ if ( db_get_b(hContact, MODULENAME, APND_DATE_NAME_KEY, 0))
+ db_set_s(hContact, "CList", "MyHandle", tstr);
+ }
+ else MessageBox(NULL, TranslateT("Unknown Alert Type."), _T(MODULENAME), MB_OK);
}
}
}
-//
- if (eventIndex == 2) // part of webpage changed
+ if (eventIndex == 2) { // part of webpage changed
+ db_get_s(hContact, MODULENAME, ALRT_S_STRING_KEY, &tdbv);
+ mir_snprintf(Alerttempstring, sizeof(Alerttempstring), "%s", tdbv.pszVal);
+ db_free(&tdbv);
- {
-
- // //////////
- //
- DBGetContactSetting(AContact, MODULENAME, ALRT_S_STRING_KEY, &tdbv);
- _snprintf(Alerttempstring, sizeof(Alerttempstring), "%s", tdbv.pszVal);
- DBFreeVariant(&tdbv);
- //
- DBGetContactSetting(AContact, MODULENAME, ALRT_E_STRING_KEY, &tdbv);
- _snprintf(Alerttempstring2, sizeof(Alerttempstring2), "%s", tdbv.pszVal);
- DBFreeVariant(&tdbv);
- //
+ db_get_s(hContact, MODULENAME, ALRT_E_STRING_KEY, &tdbv);
+ mir_snprintf(Alerttempstring2, sizeof(Alerttempstring2), "%s", tdbv.pszVal);
+ db_free(&tdbv);
// putting data into string
- if (((strstr(tempraw, Alerttempstring)) != 0) && ((strstr(tempraw, Alerttempstring2)) != 0))
- {
+ if (((strstr(tempraw, Alerttempstring)) != 0) && ((strstr(tempraw, Alerttempstring2)) != 0)) {
-//start string
+ //start string
alertpos = strstr(tempraw, Alerttempstring);
statalertpos = alertpos - tempraw;
-//
+
ZeroMemory(&alertpos, sizeof(alertpos));
-//end string
+ //end string
alertpos = strstr(tempraw, Alerttempstring2);
- statalertposend = alertpos - tempraw + strlen(Alerttempstring2);
-//
- if (statalertpos > statalertposend)
- {
+ statalertposend = alertpos - tempraw + (int)strlen(Alerttempstring2);
+
+ if (statalertpos > statalertposend) {
memset(&tempraw, ' ', statalertpos);
ZeroMemory(&alertpos, sizeof(alertpos));
alertpos = strstr(tempraw, Alerttempstring2);
- statalertposend = alertpos - tempraw + strlen(Alerttempstring2);
+ statalertposend = alertpos - tempraw + (int)strlen(Alerttempstring2);
}
- if (statalertpos < statalertposend)
- {
+
+ if (statalertpos < statalertposend) {
ZeroMemory(&raw, sizeof(raw));
-//start string
+ //start string
alertpos = strstr(tempraw, Alerttempstring);
statalertpos = alertpos - tempraw;
-//
-//end string
+ //end string
alertpos = strstr(tempraw, Alerttempstring2);
- statalertposend = alertpos - tempraw + strlen(Alerttempstring2);
-//
+ statalertposend = alertpos - tempraw + (int)strlen(Alerttempstring2);
- if (statalertpos > statalertposend)
- {
+ if (statalertpos > statalertposend) {
memset(&tempraw, ' ', statalertpos);
ZeroMemory(&alertpos, sizeof(alertpos));
alertpos = strstr(tempraw, Alerttempstring2);
- statalertposend = alertpos - tempraw + strlen(Alerttempstring2);
+ statalertposend = alertpos - tempraw + (int)strlen(Alerttempstring2);
}
disalertpos = 0;
-//write selected data to string
+ //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
-
- {
+ else { // start and/or end string not present
+ if (alertIndex == 0) { // popup
Sleep(1000);
- sprintf(displaystring, "%s", (Translate("Alert start/end strings not found or strings not set.")));
- WAlertPopup((WPARAM) AContact, displaystring);
+ WAlertPopup(hContact, TranslateT("Alert start/end strings not found or strings not set."));
// contactlist name//
- if ((db_get_b(AContact, MODULENAME, APND_DATE_NAME_KEY, 0)))
- db_set_s(AContact, "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 (!DBGetContactSetting(AContact, MODULENAME, FILE_KEY, &tdbv))
- {
+ if ( db_get_b(hContact, MODULENAME, 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 ( !db_get_s(hContact, MODULENAME, FILE_KEY, &tdbv)) {
int AmountWspcRem = 0;
-
- if (!(db_get_b(AContact, MODULENAME, SAVE_AS_RAW_KEY, 0)))
- {
- //
+ if ( !db_get_b(hContact, MODULENAME, SAVE_AS_RAW_KEY, 0)) {
CodetoSymbol(tempraw);
Sleep(100); // avoid 100% CPU
@@ -941,124 +639,95 @@ int ProcessAlerts(HANDLE AContact, char *truncated, char *tstr, char *contactnam
EraseSymbols(tempraw);
Sleep(100); // avoid 100% CPU
- AmountWspcRem = db_get_b(AContact, MODULENAME, RWSPACE_KEY, 0);
+ AmountWspcRem = db_get_b(hContact, MODULENAME, RWSPACE_KEY, 0);
RemoveInvis(tempraw, AmountWspcRem);
Sleep(100); // avoid 100% CPU
Removewhitespace(tempraw);
}
- //
- SaveToFile(AContact, tempraw);
- DBFreeVariant(&tdbv);
- // contactlist name//
- if ((db_get_b(AContact, MODULENAME, APND_DATE_NAME_KEY, 0)))
- db_set_s(AContact, "CList", "MyHandle", tstr);
+
+ SaveToFile(hContact, tempraw);
+ db_free(&tdbv);
+ // contactlist name
+ if ( db_get_b(hContact, MODULENAME, APND_DATE_NAME_KEY, 0))
+ db_set_s(hContact, "CList", "MyHandle", tstr);
}
}
- } //
-
- else if (alertIndex == 3) // osd
-
- {
- WAlertOSD((WPARAM) AContact, Translate("Alert start/end strings not found or strings not set."));
+ }
+ else if (alertIndex == 3) { // osd
+ WAlertOSD(hContact, TranslateT("Alert start/end strings not found or strings not set."));
// contactlist name//
- if ((db_get_b(AContact, MODULENAME, APND_DATE_NAME_KEY, 0)))
- db_set_s(AContact, "CList", "MyHandle", tstr);
- } else if (alertIndex == 2) // window
-
- {
- WDisplayDataAlert(AContact);
+ if ( db_get_b(hContact, MODULENAME, APND_DATE_NAME_KEY, 0))
+ db_set_s(hContact, "CList", "MyHandle", tstr);
+ }
+ else if (alertIndex == 2) { // window
+ WDisplayDataAlert(hContact);
// contactlist name//
- if ((db_get_b(AContact, MODULENAME, APND_DATE_NAME_KEY, 0)))
- db_set_s(AContact, "CList", "MyHandle", tstr);
-
- HWND hwndDlg = (WindowList_Find(hWindowList, AContact));
+ if ( db_get_b(hContact, MODULENAME, APND_DATE_NAME_KEY, 0))
+ db_set_s(hContact, "CList", "MyHandle", tstr);
- ZeroMemory(&statustext, sizeof(statustext));
- _snprintf(statustext, sizeof(statustext), " %s", Translate("Alert start/end strings not found or strings not set."));
- SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext);
- } //
+ HWND hwndDlg = (WindowList_Find(hWindowList, hContact));
+ SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Alert start/end strings not found or strings not set."));
+ }
+ else MessageBox(NULL, TranslateT("Alert start/end strings not found or strings not set."), _T(MODULENAME), MB_OK);
- else
- MessageBox(NULL, Translate("Alert start/end strings not found or strings not set."), MODULENAME, MB_OK);
- db_set_w(AContact, MODULENAME, "Status", ID_STATUS_AWAY);
+ db_set_w(hContact, MODULENAME, "Status", ID_STATUS_AWAY);
}
-///////////////
-
- if (((strstr(tempraw, Alerttempstring)) != 0) && ((strstr(tempraw, Alerttempstring2)) != 0))
- {
-
+ ///////////////
+ if (((strstr(tempraw, Alerttempstring)) != 0) && ((strstr(tempraw, Alerttempstring2)) != 0)) {
// TEST GET NAME FOR CACHE
- GetModuleFileName(hInst, cachepath, sizeof(cachepath));
- cacheend = strrchr(cachepath, '\\');
+ TCHAR cachepath[MAX_PATH], cachedirectorypath[MAX_PATH], newcachepath[MAX_PATH + 50];
+ GetModuleFileName(hInst, cachepath, SIZEOF(cachepath));
+ TCHAR *cacheend = _tcsrchr(cachepath, '\\');
cacheend++;
*cacheend = '\0';
- _snprintf(cachedirectorypath, sizeof(cachedirectorypath), "%s%s%s", cachepath, MODULENAME, "cache\\");
+ mir_sntprintf(cachedirectorypath, SIZEOF(cachedirectorypath), _T("%s%S%S"), cachepath, MODULENAME, "cache\\");
CreateDirectory(cachedirectorypath, NULL);
- _snprintf(newcachepath, sizeof(newcachepath), "%s%s%s%s%s", cachepath, MODULENAME, "cache\\", contactname, ".txt");
+ mir_sntprintf(newcachepath, SIZEOF(newcachepath), _T("%s%S%S%S%S"), cachepath, MODULENAME, "cache\\", contactname, ".txt");
// file exists?
- if ((_access(newcachepath, 0)) != -1)
- {
- if ((pcachefile = fopen(newcachepath, "r")) == NULL)
- {
- WErrorPopup(contactname, Translate("Cannot read from file"));
- } else
- {
+ if ( _taccess(newcachepath, 0) != -1) {
+ if ((pcachefile = _tfopen(newcachepath, _T("r"))) == NULL)
+ WErrorPopup(contactname, TranslateT("Cannot read from file"));
+ else {
ZeroMemory(&cachecompare, sizeof(cachecompare));
fread(cachecompare, sizeof(cachecompare), 1, pcachefile);
fclose(pcachefile);
}
}
// write to cache
- if ((pcachefile = fopen(newcachepath, "w")) == NULL)
- {
- WErrorPopup(contactname, Translate("Cannot write to file 2"));
- } else
- {
- fwrite(raw, strlen(raw), 1, pcachefile); //smaller cache
- db_set_s(AContact, MODULENAME, CACHE_FILE_KEY, newcachepath);
+ if ((pcachefile = _tfopen(newcachepath, _T("w"))) == NULL)
+ WErrorPopup(contactname, TranslateT("Cannot write to file 2"));
+ else {
+ fwrite(raw, strlen(raw), 1, pcachefile); //smaller cache
+ db_set_ts(hContact, MODULENAME, CACHE_FILE_KEY, newcachepath);
fclose(pcachefile);
}
// end write to cache
- if (strncmp(raw, cachecompare, (strlen(raw))) != 0) //lets try this instead
- {
-
+ if (strncmp(raw, cachecompare, (strlen(raw))) != 0) { //lets try this instead
// play sound?
SkinPlaySound("webviewalert");
// there was an alert
wasAlert = 1;
- if ((!notpresent))
- {
-
- if (alertIndex == 0) // popup
-
- {
- WAlertPopup((WPARAM) AContact, Translate("Specific Part Of The Web Page Has Changed."));
+ if (!notpresent) {
+ if (alertIndex == 0) { // popup
+ WAlertPopup(hContact, TranslateT("Specific Part Of The Web Page Has Changed."));
// contactlist name//
- if ((db_get_b(AContact, MODULENAME, APND_DATE_NAME_KEY, 0)))
- db_set_s(AContact, "CList", "MyHandle", tstr);
- } //
-
- else if (alertIndex == 3) // osd
-
- {
- WAlertOSD((WPARAM) AContact, Translate("Specific Part Of The Web Page Has Changed."));
+ if ( db_get_b(hContact, MODULENAME, 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 ((db_get_b(AContact, MODULENAME, APND_DATE_NAME_KEY, 0)))
- db_set_s(AContact, "CList", "MyHandle", tstr);
- } else if (alertIndex == 1) // log to file
-
- {
- if (!DBGetContactSetting(AContact, MODULENAME, FILE_KEY, &tdbv))
- {
+ if ( db_get_b(hContact, MODULENAME, APND_DATE_NAME_KEY, 0))
+ db_set_s(hContact, "CList", "MyHandle", tstr);
+ }
+ else if (alertIndex == 1) { // log to file
+ if (!db_get_s(hContact, MODULENAME, FILE_KEY, &tdbv)) {
int AmountWspcRem = 0;
-
- if (!(db_get_b(AContact, MODULENAME, SAVE_AS_RAW_KEY, 0)))
- {
- //
+ if ( !db_get_b(hContact, MODULENAME, SAVE_AS_RAW_KEY, 0)) {
CodetoSymbol(tempraw);
Sleep(100); // avoid 100% CPU
@@ -1074,233 +743,149 @@ int ProcessAlerts(HANDLE AContact, char *truncated, char *tstr, char *contactnam
EraseSymbols(tempraw);
Sleep(100); // avoid 100% CPU
- AmountWspcRem = db_get_b(AContact, MODULENAME, RWSPACE_KEY, 0);
+ AmountWspcRem = db_get_b(hContact, MODULENAME, RWSPACE_KEY, 0);
RemoveInvis(tempraw, AmountWspcRem);
Sleep(100); // avoid 100% CPU
Removewhitespace(tempraw);
}
- //
- SaveToFile(AContact, tempraw);
- DBFreeVariant(&tdbv);
- // contactlist name//
- if ((db_get_b(AContact, MODULENAME, APND_DATE_NAME_KEY, 0)))
- db_set_s(AContact, "CList", "MyHandle", tstr);
- }
- } //
- else if (alertIndex == 2) // window
-
- {
- WDisplayDataAlert(AContact);
+ SaveToFile(hContact, tempraw);
+ db_free(&tdbv);
+ // contactlist name
+ if ( db_get_b(hContact, MODULENAME, APND_DATE_NAME_KEY, 0))
+ db_set_s(hContact, "CList", "MyHandle", tstr);
+ }
+ }
+ else if (alertIndex == 2) { // window
+ WDisplayDataAlert(hContact);
// contactlist name//
- if ((db_get_b(AContact, MODULENAME, APND_DATE_NAME_KEY, 0)))
- db_set_s(AContact, "CList", "MyHandle", tstr);
- } //
-
- else
- MessageBox(NULL, Translate("Unknown Alert Type."), MODULENAME, MB_OK);
+ if ( db_get_b(hContact, MODULENAME, APND_DATE_NAME_KEY, 0))
+ db_set_s(hContact, "CList", "MyHandle", tstr);
+ }
+ else MessageBox(NULL, TranslateT("Unknown Alert Type."), _T(MODULENAME), MB_OK);
}
}
}
}
-//
} // alert type
-
}
// end alerts
-//if always log to file option is enabled do this
- if (wasAlert)
- {
- if (alertIndex != 1) // dont do for log to file alert
-
- {
- if ((db_get_b(AContact, MODULENAME, ALWAYS_LOG_KEY, 0)))
- {
- if (!DBGetContactSetting(AContact, MODULENAME, FILE_KEY, &tdbv))
- {
- int AmountWspcRem = 0;
+ //if always log to file option is enabled do this
+ if (wasAlert && alertIndex != 1) { // dont do for log to file alert
+ if ( db_get_b(hContact, MODULENAME, ALWAYS_LOG_KEY, 0)) {
+ if (!db_get_s(hContact, MODULENAME, FILE_KEY, &tdbv)) {
+ int AmountWspcRem = 0;
- if (!(db_get_b(AContact, MODULENAME, SAVE_AS_RAW_KEY, 0)))
- {
- //
- CodetoSymbol(tempraw);
- Sleep(100); // avoid 100% CPU
+ if ( !db_get_b(hContact, MODULENAME, SAVE_AS_RAW_KEY, 0)) {
+ CodetoSymbol(tempraw);
+ Sleep(100); // avoid 100% CPU
- EraseBlock(tempraw);
- Sleep(100); // avoid 100% CPU
+ EraseBlock(tempraw);
+ Sleep(100); // avoid 100% CPU
- FastTagFilter(tempraw);
- Sleep(100); // avoid 100% CPU
+ FastTagFilter(tempraw);
+ Sleep(100); // avoid 100% CPU
- NumSymbols(tempraw);
- Sleep(100); // avoid 100% CPU
+ NumSymbols(tempraw);
+ Sleep(100); // avoid 100% CPU
- EraseSymbols(tempraw);
- Sleep(100); // avoid 100% CPU
+ EraseSymbols(tempraw);
+ Sleep(100); // avoid 100% CPU
- AmountWspcRem = db_get_b(AContact, MODULENAME, RWSPACE_KEY, 0);
- RemoveInvis(tempraw, AmountWspcRem);
- Sleep(100); // avoid 100% CPU
+ AmountWspcRem = db_get_b(hContact, MODULENAME, RWSPACE_KEY, 0);
+ RemoveInvis(tempraw, AmountWspcRem);
+ Sleep(100); // avoid 100% CPU
- Removewhitespace(tempraw);
- }
- //
- SaveToFile(AContact, tempraw);
- DBFreeVariant(&tdbv);
+ Removewhitespace(tempraw);
}
+
+ SaveToFile(hContact, tempraw);
+ db_free(&tdbv);
}
}
}
strncpy(truncated, tempraw, strlen(truncated));
-
return wasAlert;
}
-/**************************/
-/***********************/
-int DataWndAlertCommand(void *AContact)
+/*****************************************************************************/
+int DataWndAlertCommand(WPARAM wParam, LPARAM lParam)
{
- HWND hwndDlg;
-
- if ((hwndDlg = (WindowList_Find(hWindowList, (HANDLE) AContact))))
- {
+ HANDLE hContact = (HANDLE)wParam;
+ if ( WindowList_Find(hWindowList, hContact))
return 0;
- }
- hwndDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_DISPLAY_DATA), NULL, DlgProcDisplayData, (LPARAM) (HANDLE) AContact);
-
- if (db_get_b(AContact, MODULENAME, ON_TOP_KEY, 0))
- {
- SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_STICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)));
- if ((db_get_b(NULL, MODULENAME, SAVE_INDIVID_POS_KEY, 0)))
- {
- SetWindowPos(
- hwndDlg,
- HWND_TOPMOST,
- db_get_dw(AContact, MODULENAME, "WVx", 100), // Xposition,
- db_get_dw(AContact, MODULENAME, "WVy", 100), // Yposition,
- db_get_dw(AContact, MODULENAME, "WVwidth", 100), // WindowWidth,
- db_get_dw(AContact, MODULENAME, "WVheight", 100), // WindowHeight,
- 0);
- } else
- {
- SetWindowPos(
- hwndDlg,
- HWND_TOPMOST,
- Xposition,
- Yposition,
- WindowWidth,
- WindowHeight,
- 0);
- }
- }
- if (!(db_get_b(AContact, MODULENAME, ON_TOP_KEY, 0)))
- {//
- SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_UNSTICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)));
-
- if ((db_get_b(NULL, MODULENAME, SAVE_INDIVID_POS_KEY, 0)))
- {
- SetWindowPos(
- hwndDlg,
- HWND_NOTOPMOST,
- db_get_dw(AContact, MODULENAME, "WVx", 100), // Xposition,
- db_get_dw(AContact, MODULENAME, "WVy", 100), // Yposition,
- db_get_dw(AContact, MODULENAME, "WVwidth", 100), // WindowWidth,
- db_get_dw(AContact, MODULENAME, "WVheight", 100), // WindowHeight,
- 0);
- } else
- {
- SetWindowPos(
- hwndDlg,
- HWND_NOTOPMOST,
- Xposition,
- Yposition,
- WindowWidth,
- WindowHeight,
- 0);
- }
- }
+ HWND hwndDlg = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_DISPLAY_DATA), NULL, DlgProcDisplayData, (LPARAM)hContact);
+ HWND hTopmost = db_get_b(hContact, MODULENAME, ON_TOP_KEY, 0) ? HWND_TOPMOST : HWND_NOTOPMOST;
+ SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_STICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)));
+ if ( db_get_b(NULL, MODULENAME, SAVE_INDIVID_POS_KEY, 0))
+ SetWindowPos(hwndDlg, hTopmost,
+ db_get_dw(hContact, MODULENAME, "WVx", 100), // Xposition,
+ db_get_dw(hContact, MODULENAME, "WVy", 100), // Yposition,
+ db_get_dw(hContact, MODULENAME, "WVwidth", 100), // WindowWidth,
+ db_get_dw(hContact, MODULENAME, "WVheight", 100), 0); // WindowHeight,
+ else
+ SetWindowPos(hwndDlg, HWND_TOPMOST, Xposition, Yposition, WindowWidth, WindowHeight, 0);
+
ShowWindow(hwndDlg, SW_SHOW);
SetActiveWindow(hwndDlg);
-
return 0;
}
-/***********************/
-/***************************/
-static void ReadFromFile(void *AContact)
+/*****************************************************************************/
+void ReadFromFile(HANDLE hContact)
{
- FILE *pfile;
DBVARIANT dbv;
- char contactname[100];
char truncated[MAXSIZE1];
- int AmountWspcRem = 0;
- int fileexists = 0;
-
-
- HWND hwndDlg = (WindowList_Find(hWindowList, AContact));
-
- ZeroMemory(&contactname, sizeof(contactname));
- DBGetContactSetting(AContact, "CList", "MyHandle", &dbv);
- _snprintf(contactname, sizeof(contactname), "%s", dbv.pszVal);
- DBFreeVariant(&dbv);
-
-
-
-////
- DBGetContactSetting(AContact, MODULENAME, CACHE_FILE_KEY, &dbv);
-////
- if ((pfile = fopen(dbv.pszVal, "r")) == NULL)
- {
- //WErrorPopup(contactname, Translate("Cannot read from cache file"));
- SendToRichEdit(hwndDlg,
- Translate("Cannot read from cache file"),
- TextClr,
- BackgoundClr);
- fileexists =0;
+ int AmountWspcRem = 0;
+ int fileexists = 0;
+
+ HWND hwndDlg = WindowList_Find(hWindowList, hContact);
+
+ char contactname[100];
+ db_get_s(hContact, "CList", "MyHandle", &dbv);
+ mir_snprintf(contactname, sizeof(contactname), "%s", dbv.pszVal);
+ db_free(&dbv);
+
+ db_get_s(hContact, MODULENAME, CACHE_FILE_KEY, &dbv);
+ FILE *pfile;
+ if ((pfile = fopen(dbv.pszVal, "r")) == NULL) {
+ SendToRichEdit(hwndDlg, Translate("Cannot read from cache file"), TextClr, BackgoundClr);
+ fileexists = 0;
}
- else
- {
- fread(truncated, sizeof(truncated), 1, pfile);
- fclose(pfile);
- fileexists =1;
+ else {
+ fread(truncated, sizeof(truncated), 1, pfile);
+ fclose(pfile);
+ fileexists =1;
}
- DBFreeVariant(&dbv);
-
- if(fileexists) {///
-
- CodetoSymbol(truncated);
- Sleep(100); // avoid 100% CPU
+ db_free(&dbv);
- EraseBlock(truncated);
- Sleep(100); // avoid 100% CPU
+ if(fileexists) {
+ CodetoSymbol(truncated);
+ Sleep(100); // avoid 100% CPU
- FastTagFilter(truncated);
- Sleep(100); // avoid 100% CPU
+ EraseBlock(truncated);
+ Sleep(100); // avoid 100% CPU
- NumSymbols(truncated);
- Sleep(100); // avoid 100% CPU
+ FastTagFilter(truncated);
+ Sleep(100); // avoid 100% CPU
- EraseSymbols(truncated);
- Sleep(100); // avoid 100% CPU
+ NumSymbols(truncated);
+ Sleep(100); // avoid 100% CPU
- AmountWspcRem = db_get_b(AContact, MODULENAME, RWSPACE_KEY, 0);
- RemoveInvis(truncated, AmountWspcRem);
- Sleep(100); // avoid 100% CPU
+ EraseSymbols(truncated);
+ Sleep(100); // avoid 100% CPU
- Removewhitespace(truncated);
+ AmountWspcRem = db_get_b(hContact, MODULENAME, RWSPACE_KEY, 0);
+ RemoveInvis(truncated, AmountWspcRem);
+ Sleep(100); // avoid 100% CPU
- SendToRichEdit(hwndDlg,
- truncated,
- TextClr,
- BackgoundClr);
-
- SetDlgItemText(hwndDlg, IDC_STATUSBAR, Translate("Loaded From Cache"));
-
- } ///
-}
+ Removewhitespace(truncated);
-/***************************/
+ SendToRichEdit(hwndDlg, truncated, TextClr, BackgoundClr);
+ SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Loaded From Cache"));
+ }
+}
diff --git a/plugins/WebView/src/webview_cleanup.cpp b/plugins/WebView/src/webview_cleanup.cpp
index 03fef944e5..b1fbc3912e 100644
--- a/plugins/WebView/src/webview_cleanup.cpp
+++ b/plugins/WebView/src/webview_cleanup.cpp
@@ -1,633 +1,798 @@
/*
- * 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.
- */
+* 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"
-/************************/
-void CodetoSymbol(char *truncated)
-{
- int counter = 0;
- int position = 0, recpos = 0, n;
- static char *stringfrompos;
-
- for (n = 0; n < AMOUNT3; n++)
- {
-
- while (1) // loop forever
-
- {
- Sleep(1); // avoid 100% CPU
-
- if (((strstr(truncated, CharacterCodes[n])) != 0))
-// does character code exist?
- {
-
- if (strstr(truncated, CharacterCodes[n]) != 0)
- {
- stringfrompos = strstr(truncated, CharacterCodes[n]);
- }
- position = stringfrompos - truncated;
- counter = 0;
- while (counter != (strlen(CharacterCodes[n])))
- {
- truncated[position + counter] = ' ';
- counter++;
- }
-
- truncated[(position + counter) - 1] = Characters[n];
-
-//
- strncpy(&truncated[position], &truncated[position + strlen(CharacterCodes[n])] - 1, strlen(&truncated[position]) - 1);
-//
-
- } // end does character code exist?
-
- if (recpos == position)
- break; // break out of loop if doesn't find new character code
+// ///////////////////////
+// characters and symbols//
+// ///////////////////////
- recpos = position;
- } // end loop forever
-
- } // for
+#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 (1) { // loop forever
+ Sleep(1); // avoid 100% CPU
+
+ if ( strstr(truncated, CharacterCodes[n]) != 0) { // does character code exist?
+ if (strstr(truncated, CharacterCodes[n]) != 0)
+ stringfrompos = strstr(truncated, CharacterCodes[n]);
+
+ position = stringfrompos - truncated;
+ counter = 0;
+ while (counter != strlen(CharacterCodes[n])) {
+ truncated[position + counter] = ' ';
+ counter++;
+ }
+
+ truncated[(position + counter) - 1] = Characters[n];
+ strncpy(&truncated[position], &truncated[position + strlen(CharacterCodes[n])] - 1, 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;
- char*tempraw;
- int BlockLength = 0;
-
-// //////
-
- tempraw = malloc(MAXSIZE1);
-
- if (truncated)
- strncpy(tempraw, truncated, MAXSIZE1);
-
-// ///////////////////////////
-
-// 1//
-
- while (1)
- {
- Sleep(1); // avoid 100% CPU
- // /get start and end of block
-
- if (strstr(tempraw, "<!--") != 0) // does tag exist?
-
- {
- stringfrompos = strstr(tempraw, "<!--");
- positionStart = stringfrompos - tempraw;
- }
- if (strstr(tempraw, "-->") != 0) // does tag exist?
-
- {
- stringfrompos = strstr(tempraw, "-->");
- positionEnd = stringfrompos - tempraw;
- }
- BlockLength = (positionEnd - positionStart) + 3;
-
- if ((strstr(tempraw, "<!--") == 0) || (strstr(tempraw, "-->") == 0))
- break;
-
-/////////////////////////////////////////
-
- // /////////
- if (strstr(tempraw, "<!--") != 0)
- {
- 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 (1)
- {
- Sleep(1); // avoid 100% CPU
- // /get start and end of block
-
- if (((strstr(tempraw, "<script")) != 0) || (strstr(tempraw, "<SCRIPT") != 0)) // does
- //
- // tag
- // exist?
-
- {
- if (strstr(tempraw, "<script") != 0)
- stringfrompos = strstr(tempraw, "<script");
- else
- stringfrompos = strstr(tempraw, "<SCRIPT");
-
- positionStart = stringfrompos - tempraw;
- }
- if (((strstr(tempraw, "</script")) != 0) || (strstr(tempraw, "</SCRIPT") != 0)) // does
- //
- // tag
- // exist?
-
- {
- if (strstr(tempraw, "<script") != 0)
- stringfrompos = strstr(tempraw, "</script");
- else
- stringfrompos = strstr(tempraw, "</SCRIPT");
-
- positionEnd = stringfrompos - tempraw;
- }
- BlockLength = (positionEnd - positionStart) + 9;
-
- if ((strstr(tempraw, "<script") != 0) && (strstr(tempraw, "</script") == 0))
- break;
-
- if ((strstr(tempraw, "<SCRIPT") != 0) && (strstr(tempraw, "</SCRIPT") == 0))
- break;
-
-///////////////////////////////////////
-
- // /////////
-
- if (((strstr(tempraw, "<script")) != 0) || ((strstr(tempraw, "<SCRIPT")) != 0))
- {
- 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 (1)
- {
- Sleep(1); // avoid 100% CPU
- // /get start and end of block
-
- if (((strstr(tempraw, "<style")) != 0) || (strstr(tempraw, "<STYLE") != 0)) // does
- //
- // tag
- // exist?
-
- {
- if (strstr(tempraw, "<style") != 0)
- stringfrompos = strstr(tempraw, "<style");
- else
- stringfrompos = strstr(tempraw, "<STYLE");
-
- positionStart = stringfrompos - tempraw;
- }
- if (((strstr(tempraw, "</style")) != 0) || (strstr(tempraw, "</STYLE") != 0)) // does
- //
- // tag
- // exist?
-
- {
- if (strstr(tempraw, "<style") != 0)
- stringfrompos = strstr(tempraw, "</style");
- else
- stringfrompos = strstr(tempraw, "</STYLE");
-
- positionEnd = stringfrompos - tempraw;
- }
- BlockLength = (positionEnd - positionStart) + 8;
-
- if ((strstr(tempraw, "<style") != 0) && (strstr(tempraw, "</style") == 0))
- break;
-
- if ((strstr(tempraw, "<STYLE") != 0) && (strstr(tempraw, "</STYLE") == 0))
- break;
-
-///////////////////////////////////////
-
- // /////////
-
- if (((strstr(tempraw, "<style")) != 0) || ((strstr(tempraw, "<STYLE")) != 0))
- {
- 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 (1)
- {
- Sleep(1); // avoid 100% CPU
- // /get start and end of block
-
- if (strstr(tempraw, "{") != 0) // does tag exist?
-
- {
- stringfrompos = strstr(tempraw, "{");
- positionStart = stringfrompos - tempraw;
- }
- if (strstr(tempraw, "}") != 0) // does tag exist?
-
- {
- stringfrompos = strstr(tempraw, "}");
- positionEnd = stringfrompos - tempraw;
- }
- BlockLength = (positionEnd - positionStart) + 1;
-
- if ((strstr(tempraw, "}") == 0) || (strstr(tempraw, "{") == 0))
- break;
-
-/////////////////////////////////////////
-
- // /////////
- if (strstr(tempraw, "{") != 0)
- {
- 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, strlen(truncated));
-
- free(tempraw);
+ 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 (1) {
+ Sleep(1); // avoid 100% CPU
+ // /get start and end of block
+
+ if (strstr(tempraw, "<!--") != 0) // does tag exist?
+ {
+ stringfrompos = strstr(tempraw, "<!--");
+ positionStart = stringfrompos - tempraw;
+ }
+
+ if (strstr(tempraw, "-->") != 0) // does tag exist?
+ {
+ stringfrompos = strstr(tempraw, "-->");
+ positionEnd = stringfrompos - tempraw;
+ }
+ BlockLength = (positionEnd - positionStart) + 3;
+
+ if ((strstr(tempraw, "<!--") == 0) || (strstr(tempraw, "-->") == 0))
+ break;
+
+ /////////////////////////////////////////
+
+ if (strstr(tempraw, "<!--") != 0)
+ 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 (1) {
+ Sleep(1); // avoid 100% CPU
+ // /get start and end of block
+
+ if (((strstr(tempraw, "<script")) != 0) || (strstr(tempraw, "<SCRIPT") != 0)) // does
+ {
+ if (strstr(tempraw, "<script") != 0)
+ stringfrompos = strstr(tempraw, "<script");
+ else
+ stringfrompos = strstr(tempraw, "<SCRIPT");
+
+ positionStart = stringfrompos - tempraw;
+ }
+
+ if (((strstr(tempraw, "</script")) != 0) || (strstr(tempraw, "</SCRIPT") != 0)) // does
+ {
+ if (strstr(tempraw, "<script") != 0)
+ stringfrompos = strstr(tempraw, "</script");
+ else
+ stringfrompos = strstr(tempraw, "</SCRIPT");
+
+ positionEnd = stringfrompos - tempraw;
+ }
+ BlockLength = (positionEnd - positionStart) + 9;
+
+ if ((strstr(tempraw, "<script") != 0) && (strstr(tempraw, "</script") == 0))
+ break;
+
+ if ((strstr(tempraw, "<SCRIPT") != 0) && (strstr(tempraw, "</SCRIPT") == 0))
+ break;
+
+ ///////////////////////////////////////
+
+ if (((strstr(tempraw, "<script")) != 0) || ((strstr(tempraw, "<SCRIPT")) != 0))
+ 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 (1)
+ {
+ Sleep(1); // avoid 100% CPU
+ // /get start and end of block
+
+ if (((strstr(tempraw, "<style")) != 0) || (strstr(tempraw, "<STYLE") != 0)) // does
+ {
+ if (strstr(tempraw, "<style") != 0)
+ stringfrompos = strstr(tempraw, "<style");
+ else
+ stringfrompos = strstr(tempraw, "<STYLE");
+
+ positionStart = stringfrompos - tempraw;
+ }
+
+ if (((strstr(tempraw, "</style")) != 0) || (strstr(tempraw, "</STYLE") != 0)) // does
+ {
+ if (strstr(tempraw, "<style") != 0)
+ stringfrompos = strstr(tempraw, "</style");
+ else
+ stringfrompos = strstr(tempraw, "</STYLE");
+
+ positionEnd = stringfrompos - tempraw;
+ }
+ BlockLength = (positionEnd - positionStart) + 8;
+
+ if ((strstr(tempraw, "<style") != 0) && (strstr(tempraw, "</style") == 0))
+ break;
+
+ if ((strstr(tempraw, "<STYLE") != 0) && (strstr(tempraw, "</STYLE") == 0))
+ break;
+
+ ///////////////////////////////////////
+ if (((strstr(tempraw, "<style")) != 0) || ((strstr(tempraw, "<STYLE")) != 0))
+ 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 (1) {
+ Sleep(1); // avoid 100% CPU
+ // /get start and end of block
+ if (strstr(tempraw, "{") != 0) // does tag exist?
+ {
+ stringfrompos = strstr(tempraw, "{");
+ positionStart = stringfrompos - tempraw;
+ }
+
+ if (strstr(tempraw, "}") != 0) // does tag exist?
+ {
+ stringfrompos = strstr(tempraw, "}");
+ positionEnd = stringfrompos - tempraw;
+ }
+ BlockLength = (positionEnd - positionStart) + 1;
+
+ if ((strstr(tempraw, "}") == 0) || (strstr(tempraw, "{") == 0))
+ break;
+
+ /////////////////////////////////////////
+ if (strstr(tempraw, "{") != 0)
+ 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, strlen(truncated));
+ free(tempraw);
}
-/************************/
-
-/************************/
+/*****************************************************************************/
void EraseSymbols(char *truncated)
{
- int counter = 0;
- int position = 0, recpos = 0;
- char*stringfrompos;
- char*tempraw;
-
- tempraw = malloc(MAXSIZE1);
-
- if (truncated)
- strncpy(tempraw, truncated, MAXSIZE1);
-
-// //////
-
- while (1)
- {
- Sleep(1); // avoid 100% CPU
-
- /**/
- counter = 0;
- if ((strstr(tempraw, "&#")) != 0)
- {
- stringfrompos = strstr(tempraw, "&#");
- position = stringfrompos - tempraw;
- //
- while (1)
- {
- 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, strlen(truncated));
-
- free(tempraw);
+ int counter = 0;
+ int position = 0, recpos = 0;
+ char *stringfrompos;
+
+ char *tempraw = (char*)malloc(MAXSIZE1);
+ if (truncated)
+ strncpy(tempraw, truncated, MAXSIZE1);
+
+ // //////
+ while (1) {
+ Sleep(1); // avoid 100% CPU
+
+ /**/
+ counter = 0;
+ if ((strstr(tempraw, "&#")) != 0) {
+ stringfrompos = strstr(tempraw, "&#");
+ position = stringfrompos - tempraw;
+
+ while (1) {
+ 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, 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;
-
- tempraw = malloc(MAXSIZE1);
-
- if (truncated)
- strncpy(tempraw, truncated, MAXSIZE1);
-
- while (1)
- {
- Sleep(1); // avoid 100% CPU
-
- /**/
- counter = 0;
-
- if ((strstr(tempraw, "&#")) != 0)
- {
- stringfrompos = strstr(tempraw, "&#");
- position = stringfrompos - tempraw;
-
- //
- while (1)
- {
- 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, strlen(truncated));
- free(tempraw);
+ 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 (1) {
+ Sleep(1); // avoid 100% CPU
+
+ counter = 0;
+
+ if ((strstr(tempraw, "&#")) != 0) {
+ stringfrompos = strstr(tempraw, "&#");
+ position = stringfrompos - tempraw;
+
+ while (1) {
+ 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, strlen(truncated));
+ free(tempraw);
}
-/************************/
-
-/************************/
+/*****************************************************************************/
void FastTagFilter(char *truncated)
{
- int counter = 0;
- char*tempraw;
-
-// //////
- tempraw = malloc(MAXSIZE1);
-
- if (truncated)
- strncpy(tempraw, truncated, MAXSIZE1);
-
- for (counter = 0; counter < lstrlen(tempraw); counter++)
- {
- if (tempraw[counter] == '<')
- {
- while (tempraw[counter] != '>')
- {
- if (counter >= lstrlen(tempraw))
- break;
- tempraw[counter] = ' ';
- counter++;
- }
- if (tempraw[counter] == '>')
- tempraw[counter] = ' ';
- }
- }
-
- strncpy(truncated, tempraw, strlen(truncated));
- free(tempraw);
+ char *tempraw = (char*)malloc(MAXSIZE1);
+ if (truncated)
+ strncpy(tempraw, truncated, MAXSIZE1);
+
+ for (int counter = 0; counter < lstrlenA(tempraw); counter++) {
+ if (tempraw[counter] == '<') {
+ while (tempraw[counter] != '>') {
+ if (counter >= lstrlenA(tempraw))
+ break;
+
+ tempraw[counter] = ' ';
+ counter++;
+ }
+ if (tempraw[counter] == '>')
+ tempraw[counter] = ' ';
+ }
+ }
+
+ strncpy(truncated, tempraw, strlen(truncated));
+ free(tempraw);
}
-/*************************/
-/********************/
+/*****************************************************************************/
void RemoveInvis(char *truncated, int AmountWspcRem)
{
- int counter = 0;
- int erase = 0;
- int RemovalLevel = 0;
- char*tempraw;
-
- tempraw = 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;
- default:
- break;
-
- }
-
-// //////
- for (counter = 0; counter < lstrlen(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, strlen(truncated));
- free(tempraw);
+ 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 < lstrlenA(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, strlen(truncated));
+ free(tempraw);
}
-/******************/
-
-/******************/
+/*****************************************************************************/
void RemoveTabs(char *truncated)
{
- int counter = 0;
- char*tempraw;
-
- tempraw = malloc(MAXSIZE1);
-
- if (truncated)
- strncpy(tempraw, truncated, MAXSIZE1);
-
- for (counter = 0; counter < lstrlen(tempraw); counter++)
- {
-
- if (tempraw[counter] == '\t')
- tempraw[counter] = ' ';
+ char *tempraw = (char*)malloc(MAXSIZE1);
+ if (truncated)
+ strncpy(tempraw, truncated, MAXSIZE1);
- } // end for
+ for (int counter = 0; counter < lstrlenA(tempraw); counter++)
+ if (tempraw[counter] == '\t')
+ tempraw[counter] = ' ';
- strncpy(truncated, tempraw, strlen(truncated));
-
- free(tempraw);
+ strncpy(truncated, tempraw, strlen(truncated));
+ free(tempraw);
}
-/******************/
-
-/********************/
+/*****************************************************************************/
void Removewhitespace(char *truncated)
{
- int counter = 0;
- int counter2 = 0;
- int pos1 = 0, pos2 = 0;
-
- for (counter = 0; counter < lstrlen(truncated); counter++)
- {
- if (truncated[counter] == ' ' && truncated[counter + 1] == ' ')
- {
- pos1 = counter + 1;
- counter2 = counter;
-
- while (truncated[counter2] == ' ')
- {
- counter2++;
- }
-
- pos2 = counter2;
- strncpy(&truncated[pos1], &truncated[pos2], strlen(&truncated[pos1]) - 1);
+ int counter2 = 0;
+ int pos1 = 0, pos2 = 0;
- } // end if
+ for (int counter = 0; counter < lstrlenA(truncated); counter++) {
+ if (truncated[counter] == ' ' && truncated[counter + 1] == ' ') {
+ pos1 = counter + 1;
+ counter2 = counter;
- } // end for
+ while (truncated[counter2] == ' ')
+ counter2++;
+ pos2 = counter2;
+ strncpy(&truncated[pos1], &truncated[pos2], strlen(&truncated[pos1]) - 1);
+ } // end if
+ } // end for
}
-/******************/
-
-/********************/
+/*****************************************************************************/
void Filter(char *truncated)
{
- int counter = 0;
- char tempraw[MAXSIZE1];
-
- strncpy(tempraw, truncated, sizeof(tempraw));
-
- for (counter = 0; counter < lstrlen(tempraw); counter++)
- {
+ char tempraw[MAXSIZE1];
+ strncpy(tempraw, truncated, sizeof(tempraw));
- if ((tempraw[counter] == '\n') || (tempraw[counter] == '\r') || (tempraw[counter] == '\t'))
- {
- strncpy(&tempraw[counter], &tempraw[counter + 1], strlen(&tempraw[counter]) - 1);
- }
- } // end for
-
- strncpy(truncated, tempraw, strlen(truncated));
+ for (int counter = 0; counter < lstrlenA(tempraw); counter++)
+ if ((tempraw[counter] == '\n') || (tempraw[counter] == '\r') || (tempraw[counter] == '\t'))
+ strncpy(&tempraw[counter], &tempraw[counter + 1], strlen(&tempraw[counter]) - 1);
+ strncpy(truncated, tempraw, strlen(truncated));
}
-
-/******************/
diff --git a/plugins/WebView/src/webview_common.h b/plugins/WebView/src/webview_common.h
deleted file mode 100644
index c0a85108a6..0000000000
--- a/plugins/WebView/src/webview_common.h
+++ /dev/null
@@ -1,174 +0,0 @@
-
-#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"
-
-
-/*
- * some globals for window settings
- */
-DWORD Xposition;
-DWORD Yposition;
-DWORD BackgoundClr;
-DWORD TextClr;
-DWORD WindowHeight;
-DWORD WindowWidth;
-
-UINT_PTR timerId;
-UINT_PTR Countdown;
-LOGFONT lf;
-HFONT h_font;
-HWND ContactHwnd;
-HINSTANCE hInst;
-HMENU hMenu;
-int bpStatus;
-HANDLE hMenuItem1;
-HANDLE hMenuItemCountdown;
-char optionsname[80];
-
-struct FORK_ARG
-{
- HANDLE hEvent;
- void (__cdecl * threadcode) (void *);
- unsigned (__stdcall * threadcodeex) (void *);
- void *arg;
-};
-
-//lets get rid of some warnings
-void timerfunc(void);
-void Countdownfunc(void);
-void SavewinSettings(void);
-void ValidatePosition(HWND hwndDlg);
-void CheckDbKeys(void);
-int ModulesLoaded(WPARAM wParam, LPARAM lParam);
-void ChangeMenuItem3();
-int ContactMenuItemUpdateData (WPARAM wParam, LPARAM lParam);
-
-int Doubleclick(WPARAM wParam, LPARAM lParam);
-int DBSettingChanged(WPARAM wParam, LPARAM lParam);
-
-int SendToRichEdit(HWND hWindow, TCHAR *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 ContactOptionsMenuCommand(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 ShowHideContactCommand(WPARAM wParam, LPARAM lParam);
-INT_PTR PingWebsiteMenuCommand(WPARAM wParam, LPARAM lParam);
-INT_PTR StpPrcssMenuCommand(WPARAM wParam, LPARAM lParam);
-
-int UpdateMenuCommand(WPARAM wParam, LPARAM lParam, HANDLE singlecontact);
-int OnTopMenuCommand(WPARAM wParam, LPARAM lParam, HANDLE 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(HANDLE AContact, char *truncated, char *tstr, char *contactname, int notpresent);
-
-BOOL CALLBACK DlgPopUpOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam);
-BOOL CALLBACK DlgProcFind(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
-int DataDialogResize(HWND hwndDlg, LPARAM lParam, UTILRESIZECONTROL * urc);
-
-void Filter(char *truncated);
-void TxtclrLoop();
-void BGclrLoop();
-void ContactLoop(void *dummy);
-void NumSymbols(char *truncated);
-
-INT_PTR AutoUpdateMCmd(WPARAM wParam, LPARAM lParam);
-BOOL CALLBACK DlgProcContactOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
-void AckFunc(void *dummy);
-int SiteDeleted(WPARAM wParam, LPARAM lParam);
-
-int WErrorPopup(char *namecontact, char *textdisplay);
-
-//////////////////////
-// wrappers
-HANDLE hHookDisplayDataAlert;
-
-#define ME_DISPLAYDATA_ALERT "Miranda/ALERT/DISPLAYDATA"
-
-HANDLE hHookAlertPopup;
-
-#define ME_POPUP_ALERT "Miranda/ALERT/POPUP"
-
-HANDLE hHookAlertWPopup;
-
-#define ME_WPOPUP_ALERT "Miranda/ALERT/WPOPUP"
-
-HANDLE hHookErrorPopup;
-
-#define ME_POPUP_ERROR "Miranda/ERROR/POPUP"
-
-HANDLE hHookAlertOSD;
-
-#define ME_OSD_ALERT "Miranda/ALERT/OSD"
diff --git a/plugins/WebView/src/webview_datawnd.cpp b/plugins/WebView/src/webview_datawnd.cpp
index 5999c9e3cd..78e8364711 100644
--- a/plugins/WebView/src/webview_datawnd.cpp
+++ b/plugins/WebView/src/webview_datawnd.cpp
@@ -1,999 +1,726 @@
/*
- * 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.
- */
+* 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"
-/*************/
-BOOL CALLBACK DlgProcFind(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+/*****************************************************************************/
+INT_PTR CALLBACK DlgProcFind(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- HWND ParentHwnd;
- static char Searchstr[128];
- static int loc;
- static int oldloc;
- static int startposition;
- static int OLDstartposition;
-
- ParentHwnd = GetParent(hwndDlg);
-
- switch (msg)
- {
- case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
- SetWindowLong(hwndDlg, GWL_USERDATA, lParam);
-
- SetWindowText(hwndDlg, Translate("Find"));
-
- SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM) LoadIcon(hInst, MAKEINTRESOURCE(IDI_FIND)));
-
- return TRUE;
- }
- break;
-
- case WM_COMMAND:
- switch (LOWORD(wParam))
- {
- case IDC_OK: // find Next
-
- {
- char NewSearchstr[128];
- char*tempbuffer;
- int len;
- int location = 0;
- int startsel = 0, endsel = 0;
- char buff[MAXSIZE1];
-
- ZeroMemory(&NewSearchstr, sizeof(NewSearchstr));
-
- len = GetWindowTextLength(GetDlgItem(ParentHwnd, IDC_DATA));
-
- tempbuffer = malloc(len + 2);
-
- GetWindowText(GetDlgItem(ParentHwnd, IDC_DATA), tempbuffer, len);
- strncpy(buff, tempbuffer, sizeof(buff));
- free(tempbuffer);
-
- Filter(buff);
- CharUpperBuff(buff, lstrlen(buff));
-
- GetDlgItemText(hwndDlg, IDC_FINDWHAT, NewSearchstr, sizeof(NewSearchstr));
- CharUpperBuff(NewSearchstr, lstrlen(NewSearchstr));
-
- OLDstartposition = startposition;
-
- if ((strstr(Searchstr, NewSearchstr)) != 0)
- {
- startposition = loc + strlen(Searchstr);
- } else
- {
- oldloc = 0;
- startposition = 0;
- }
-
- strcpy(Searchstr, NewSearchstr);
- //
-
- /**/
- if (!(startposition > 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 + strlen(NewSearchstr);
- oldloc = 0;
- startposition = 0;
- } else
- {
- ShowWindow(GetDlgItem(hwndDlg, IDC_SEARCH_COMPLETE), SW_HIDE);
- startsel = loc;
- endsel = loc + strlen(NewSearchstr);
- }
-
- CHARRANGE sel2 = {startsel, endsel};
-
- //
- SendMessage(GetDlgItem(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;
-
- }
- break;
- }
- return FALSE;
+ 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);
+ SetWindowLong(hwndDlg, GWLP_USERDATA, lParam);
+ SetWindowText(hwndDlg, TranslateT("Find"));
+ SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM) LoadIcon(hInst, 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];
+
+ ZeroMemory(&NewSearchstr, sizeof(NewSearchstr));
+
+ int len = GetWindowTextLength(GetDlgItem(ParentHwnd, IDC_DATA));
+
+ char *tempbuffer = (char*)malloc(len + 2);
+
+ GetWindowTextA(GetDlgItem(ParentHwnd, IDC_DATA), tempbuffer, len);
+ strncpy(buff, tempbuffer, sizeof(buff));
+ free(tempbuffer);
+
+ Filter(buff);
+ CharUpperBuffA(buff, lstrlenA(buff));
+
+ GetDlgItemTextA(hwndDlg, IDC_FINDWHAT, NewSearchstr, sizeof(NewSearchstr));
+ CharUpperBuffA(NewSearchstr, lstrlenA(NewSearchstr));
+
+ OLDstartposition = startposition;
+
+ if ((strstr(Searchstr, NewSearchstr)) != 0)
+ startposition = loc + (int)strlen(Searchstr);
+ else {
+ oldloc = 0;
+ startposition = 0;
+ }
+
+ strcpy(Searchstr, NewSearchstr);
+
+ if (!(startposition > 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)strlen(NewSearchstr);
+ oldloc = 0;
+ startposition = 0;
+ }
+ else {
+ ShowWindow(GetDlgItem(hwndDlg, IDC_SEARCH_COMPLETE), SW_HIDE);
+ startsel = loc;
+ endsel = loc + (int)strlen(NewSearchstr);
+ }
+
+ CHARRANGE sel2 = {startsel, endsel};
+ SendMessage(GetDlgItem(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;
}
-/**************/
-
-/*******************************/
-BOOL CALLBACK DlgProcDisplayData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+/*****************************************************************************/
+INT_PTR CALLBACK DlgProcDisplayData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- DBVARIANT dbv;
- DBVARIANT dbv2;
- DBVARIANT dbv3;
- RECT rc;
- char url[300];
-
- switch (msg)
- {
- case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
-
- //
-
- HANDLE hContact2 = (HANDLE) lParam;
-
- SetWindowLong(hwndDlg, GWL_USERDATA, (LONG) hContact2);
- WindowList_Add(hWindowList, hwndDlg, hContact2);
- // //
- url[0] = '\0';
- DBGetContactSetting(hContact2, MODULENAME, URL_KEY, &dbv);
- _snprintf(url, sizeof(url), "%s", dbv.pszVal);
- DBFreeVariant(&dbv);
- // //
- char buttontext[256];
- char stringbefore[256];
- char*stringafter;
- char newbuttontext[256];
- int pos = 0;
- int posafter = 0;
- int posbefore = 0;
-
- ZeroMemory(&buttontext, sizeof(buttontext));
- ZeroMemory(&newbuttontext, sizeof(newbuttontext));
- _snprintf(buttontext, sizeof(buttontext), "%s", url);
- _snprintf(newbuttontext, sizeof(newbuttontext), "%s", url);
-
- if ((strstr(newbuttontext, "&")) != 0)
- {
- while (1)
- {
-
- ZeroMemory(&stringbefore, sizeof(stringbefore));
-
- if ((strstr(newbuttontext, "&")) == 0)
- break;
-
- _snprintf(buttontext, sizeof(buttontext), "%s", newbuttontext);
- stringafter = strstr(buttontext, "&");
- pos = (stringafter - buttontext);
- posbefore = (stringafter - buttontext) - 1;
- posafter = (stringafter - buttontext) + 1;
- strncpy(&stringafter[0], &stringafter[1], strlen(stringafter));
- _snprintf(stringbefore, pos, "%s", buttontext);
- _snprintf(newbuttontext, sizeof(buttontext), "%s%s%s", stringbefore, "!!", stringafter);
-
- posafter = 0;
- posbefore = 0;
- }
-
- while (1)
- {
- if ((strstr(newbuttontext, "!")) != 0)
- {
- stringafter = strstr(newbuttontext, "!");
- pos = (stringafter - newbuttontext);
- newbuttontext[pos] = '&';
- }
- if ((strstr(newbuttontext, "!")) == 0)
- break;
-
- }
- }
- SetDlgItemText(hwndDlg, IDC_OPEN_URL, newbuttontext);
- //SetDlgItemText(hwndDlg, IDC_HIDDEN_URL, url);
- // //
- //
- char preservename[100];
-
- ZeroMemory(&preservename, sizeof(preservename));
-
- DBGetContactSetting(hContact2, MODULENAME, PRESERVE_NAME_KEY, &dbv);
- _snprintf(preservename, sizeof(preservename), "%s", dbv.pszVal);
- DBFreeVariant(&dbv);
-
- SetWindowText(hwndDlg, preservename);
- //
- SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM) LoadIcon(hInst, MAKEINTRESOURCE(IDI_SITE)));
-
- // //////
- COLORREF colour;
- COLORREF txtcolor;
-
- colour = BackgoundClr;
- SendDlgItemMessage(hwndDlg, IDC_DATA, EM_SETBKGNDCOLOR, 0, colour);
- // /////
-
- // //
- SendDlgItemMessage(hwndDlg, IDC_UPDATE_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_UPDATE), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)));
- SendMessage(GetDlgItem(hwndDlg, IDC_UPDATE_BUTTON), BUTTONADDTOOLTIP, (WPARAM) Translate("Update Data"), 0);
-
- SendDlgItemMessage(hwndDlg, IDC_FIND_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_FIND), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)));
- SendMessage(GetDlgItem(hwndDlg, IDC_FIND_BUTTON), BUTTONADDTOOLTIP, (WPARAM) Translate("Find"), 0);
-
- SendDlgItemMessage(hwndDlg, IDC_OPTIONS_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_OPTIONS), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)));
- SendMessage(GetDlgItem(hwndDlg, IDC_OPTIONS_BUTTON), BUTTONADDTOOLTIP, (WPARAM) Translate("Contact Options"), 0);
-
- SendDlgItemMessage(hwndDlg, IDC_ALERT_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_ALERT), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)));
- SendMessage(GetDlgItem(hwndDlg, IDC_ALERT_BUTTON), BUTTONADDTOOLTIP, (WPARAM) Translate("Alert Options"), 0);
-
- SendDlgItemMessage(hwndDlg, IDC_STOP, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_STOP), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)));
- SendMessage(GetDlgItem(hwndDlg, IDC_STOP), BUTTONADDTOOLTIP, (WPARAM) Translate("Stop Processing"), 0);
- // ///
- SendMessage(GetDlgItem(hwndDlg, IDC_OPEN_URL), BUTTONADDTOOLTIP, (WPARAM) Translate("Click here to open this URL in a browser window."), 0);
- // ///
-
- if (!(db_get_b(hContact2, MODULENAME, ON_TOP_KEY, 0)))
- {//
- SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_UNSTICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)));
- SendMessage(GetDlgItem(hwndDlg, IDC_STICK_BUTTON), BUTTONADDTOOLTIP, (WPARAM) Translate("Stick to the front"), 0);
- }
- if (db_get_b(hContact2, MODULENAME, ON_TOP_KEY, 0))
- {
- SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_STICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)));
- SendMessage(GetDlgItem(hwndDlg, IDC_STICK_BUTTON), BUTTONADDTOOLTIP, (WPARAM) Translate("Disable Stick to the Front"), 0);
- }
- // //
-
- SendMessage(GetDlgItem(hwndDlg, IDC_DATA), WM_SETFONT, (WPARAM) h_font, 1);
-
- txtcolor = TextClr;
-
- SetDlgItemText(hwndDlg, IDC_DATA, "");
-
- InvalidateRect(hwndDlg, NULL, 1);
-
- //
-
- // /
- SendMessage(GetDlgItem(hwndDlg, IDC_DATA), EM_AUTOURLDETECT, 1, 0);
- int mask = (int) SendMessage(GetDlgItem(hwndDlg, IDC_DATA), EM_GETEVENTMASK, 0, 0);
-
- SendMessage(GetDlgItem(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);
- //
-
- {
- int partWidth[2];
- SIZE textSize;
- HDC hdc;
-
- hdc = GetDC(GetDlgItem(hwndDlg, IDC_STATUSBAR));
- SelectObject(hdc, (HFONT) SendDlgItemMessage(hwndDlg, IDC_STATUSBAR, WM_GETFONT, 0, 0));
- GetTextExtentPoint32(hdc, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", lstrlen("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"), &textSize);
- partWidth[0] = textSize.cx;
- ReleaseDC(GetDlgItem(hwndDlg, IDC_STATUSBAR), hdc);
- partWidth[1] = -1;
- SendDlgItemMessage(hwndDlg, IDC_STATUSBAR, SB_SETPARTS, sizeof(partWidth) / sizeof(partWidth[0]), (LPARAM) partWidth);
- SendDlgItemMessage(hwndDlg, IDC_STATUSBAR, SB_SETTEXT, 1 | SBT_OWNERDRAW, 0);
-
- }
- //
-
- if ((db_get_b(NULL, MODULENAME, 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:
- {
- HMENU hSubMenu;
- POINT pt;
- CHARRANGE sel, all = {0, -1};
-
- hSubMenu = GetSubMenu(hMenu, 0);
- CallService(MS_LANGPACK_TRANSLATEMENU, (WPARAM) hSubMenu, 0);
- 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, NULL))
- {
- 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:
- {
- SetDlgItemText(hwndDlg, IDC_DATA, "");
- SetFocus(GetDlgItem(hwndDlg, IDC_DATA));
- }
- break;
- }
- }
- }
- break;
-
- //
- case EN_LINK:
-
- switch (((ENLINK *) lParam)->msg)
- {
- case WM_RBUTTONDOWN:
- case WM_LBUTTONUP:
- {
- TEXTRANGE tr;
- CHARRANGE sel;
-
- SendDlgItemMessage(hwndDlg, IDC_DATA, EM_EXGETSEL, 0, (LPARAM) & sel);
- if (sel.cpMin != sel.cpMax)
- break;
- tr.chrg = ((ENLINK *) lParam)->chrg;
-
- tr.lpstrText = malloc(tr.chrg.cpMax - tr.chrg.cpMin + 8);
-
- SendDlgItemMessage(hwndDlg, IDC_DATA, EM_GETTEXTRANGE, 0, (LPARAM) & tr);
-
-/*
-#ifdef UNICODE_VERISON
- if (wcschr(tr.lpstrText, '@') != NULL && wcschr(tr.lpstrText, ':') == NULL && wcschr(tr.lpstrText, '/') == NULL)
- {
- MoveMemory(tr.lpstrText + 7, tr.lpstrText, tr.chrg.cpMax - tr.chrg.cpMin + 1);
- CopyMemory(tr.lpstrText, "mailto:", 7);
- }
-#endif
-*/
-
-//#ifndef UNICODE_VERISON
- if (strchr(tr.lpstrText, '@') != NULL && strchr(tr.lpstrText, ':') == NULL && strchr(tr.lpstrText, '/') == NULL)
- {
- MoveMemory(tr.lpstrText + 7, tr.lpstrText, tr.chrg.cpMax - tr.chrg.cpMin + 1);
- CopyMemory(tr.lpstrText, "mailto:", 7);
- }
-//#endif
-
- CallService(MS_UTILS_OPENURL, 1, (LPARAM) tr.lpstrText);
- SetFocus(GetDlgItem(hwndDlg, IDC_DATA));
-
- free(tr.lpstrText);
- break;
- }
- }
- break;
-
- }
- break; // notify
-
- // ///////////
-
- case WM_COMMAND:
- switch (LOWORD(wParam))
- {
- case IDC_OPEN_URL:
- {
-
-
- ZeroMemory(&url, sizeof(url));
- GetDlgItemText(hwndDlg, IDC_OPEN_URL, url, sizeof(url));
- CallService(MS_UTILS_OPENURL, 1, (LPARAM) url);
- db_set_w((HANDLE) wParam, MODULENAME, "Status", ID_STATUS_ONLINE);
-
- }
- break;
-
- case IDC_UPDATE_BUTTON:
- {
- HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
- char*szProto;
- char urltext[300];
- char titlebartxt[300];
- int contactcount = 0;
-
- ZeroMemory(&urltext, sizeof(urltext));
- ZeroMemory(&titlebartxt, sizeof(titlebartxt));
-
- //GetDlgItemText(hwndDlg, IDC_HIDDEN_URL, urltext, sizeof(urltext));
- GetDlgItemText(hwndDlg, IDC_OPEN_URL, urltext, sizeof(urltext));
- GetWindowText(hwndDlg, titlebartxt, sizeof(titlebartxt));
-
- while (hContact != NULL)
- {
- szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0);
- if (szProto != NULL && !lstrcmp(MODULENAME, szProto))
- {
- DBGetContactSetting(hContact, MODULENAME, URL_KEY, &dbv);
- DBGetContactSetting(hContact, MODULENAME, PRESERVE_NAME_KEY, &dbv2);
-
- if ((!lstrcmp(urltext, dbv.pszVal)) && (!lstrcmp(titlebartxt, dbv2.pszVal)))
- {
- contactcount++;
- if (contactcount > 1)
- {
- MessageBox(NULL, Translate("ERROR: You have two or more Webview contacts with the same URL and contact name."), MODULENAME, MB_OK);
- break;
- }
- EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE_BUTTON), 0);
- UpdateMenuCommand(wParam, lParam, hContact);
- }
- DBFreeVariant(&dbv);
- DBFreeVariant(&dbv2);
- }
- hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0);
- }
- }
- break;
-
-
-
- case IDC_STOP:
- {
- HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
- char*szProto;
- char urltext[300];
- char titlebartxt[300];
- int contactcount = 0;
-
- ZeroMemory(&urltext, sizeof(urltext));
- ZeroMemory(&titlebartxt, sizeof(titlebartxt));
-
- //GetDlgItemText(hwndDlg, IDC_HIDDEN_URL, urltext, sizeof(urltext));
- GetDlgItemText(hwndDlg, IDC_OPEN_URL, urltext, sizeof(urltext));
- GetWindowText(hwndDlg, titlebartxt, sizeof(titlebartxt));
-
- while (hContact != NULL)
- {
- szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0);
- if (szProto != NULL && !lstrcmp(MODULENAME, szProto))
- {
- DBGetContactSetting(hContact, MODULENAME, URL_KEY, &dbv);
- DBGetContactSetting(hContact, MODULENAME, PRESERVE_NAME_KEY, &dbv2);
-
- if ((!lstrcmp(urltext, dbv.pszVal)) && (!lstrcmp(titlebartxt, dbv2.pszVal)))
- {
- contactcount++;
- if (contactcount > 1)
- {
- MessageBox(NULL, Translate("ERROR: You have two or more Webview contacts with the same URL and contact name."), MODULENAME, MB_OK);
- break;
- }
- db_set_b(hContact, MODULENAME, STOP_KEY, 1);
- }
- DBFreeVariant(&dbv);
- DBFreeVariant(&dbv2);
- }
- hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0);
- }
- }
- break;
-
-
-
- case IDC_STICK_BUTTON:
- {
-
-// /////////
-
- HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
- char*szProto;
- char urltext2[300];
- char titlebartxt[300];
- int contactcount = 0;
-
- ZeroMemory(&urltext2, sizeof(urltext2));
- ZeroMemory(&titlebartxt, sizeof(titlebartxt));
-
- //GetDlgItemText(hwndDlg, IDC_HIDDEN_URL, urltext2, sizeof(urltext2));
- GetDlgItemText(hwndDlg, IDC_OPEN_URL, urltext2, sizeof(urltext2));
- GetWindowText(hwndDlg, titlebartxt, sizeof(titlebartxt));
-
- while (hContact != NULL)
- {
- szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0);
- if (szProto != NULL && !lstrcmp(MODULENAME, szProto))
- {
- DBGetContactSetting(hContact, MODULENAME, URL_KEY, &dbv);
- DBGetContactSetting(hContact, MODULENAME, PRESERVE_NAME_KEY, &dbv2);
-
- if ((!lstrcmp(urltext2, dbv.pszVal)) && (!lstrcmp(titlebartxt, dbv2.pszVal)))
- {
- contactcount++;
- if (contactcount > 1)
- {
- MessageBox(NULL, Translate("ERROR: You have two or more Webview contacts with the same URL and contact name."), MODULENAME, MB_OK);
- break;
- }
- OnTopMenuCommand(wParam, lParam, hContact);
- DBFreeVariant(&dbv);
- break;
- }
- DBFreeVariant(&dbv);
- DBFreeVariant(&dbv2);
- }
- hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0);
- }
- //
-
-// ////////
-
- if (!(db_get_b(hContact, MODULENAME, ON_TOP_KEY, 0)))
- {//
- SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_UNSTICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)));
- SendMessage(GetDlgItem(hwndDlg, IDC_STICK_BUTTON), BUTTONADDTOOLTIP, (WPARAM) Translate("Stick to the front"), 0);
- if ((db_get_b(NULL, MODULENAME, SAVE_INDIVID_POS_KEY, 0)))
- {
-
- SetWindowPos(
- hwndDlg,
- HWND_NOTOPMOST,
- 0, // Xposition,
- 0, // Yposition,
- 0, // WindowWidth,
- 0, // WindowHeight,
- SWP_NOSIZE | SWP_NOMOVE);
- } else
- {
-
- SetWindowPos(
- hwndDlg,
- HWND_NOTOPMOST,
- 0,
- 0,
- 0,
- 0,
- SWP_NOSIZE | SWP_NOMOVE);
- }
-
- }
- if (db_get_b(hContact, MODULENAME, ON_TOP_KEY, 0))
- {
- SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_STICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)));
- SendMessage(GetDlgItem(hwndDlg, IDC_STICK_BUTTON), BUTTONADDTOOLTIP, (WPARAM) Translate("Disable Stick to the front"), 0);
-
- if ((db_get_b(NULL, MODULENAME, SAVE_INDIVID_POS_KEY, 0)))
- {
- SetWindowPos(
- hwndDlg,
- HWND_TOPMOST,
- 0, // Xposition,
- 0, // Yposition,
- 0, // WindowWidth,
- 0, // WindowHeight,
- SWP_NOSIZE | SWP_NOMOVE);
- } else
- {
- SetWindowPos(
- hwndDlg,
- HWND_TOPMOST,
- 0,
- 0,
- 0,
- 0,
- SWP_NOSIZE | SWP_NOMOVE);
-
- }
-
- }
- DBFreeVariant(&dbv);
- }
- break;
-
- // //
- case IDC_FIND_BUTTON:
- {
- HWND hwndFind;
-
- hwndFind = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_FIND), hwndDlg, DlgProcFind, (LPARAM) (HANDLE) wParam);
- ShowWindow(hwndFind, SW_SHOW);
- EnableWindow(GetDlgItem(hwndDlg, IDC_FIND_BUTTON), 0);
- }
- break;
-
- case IDC_OPTIONS_BUTTON:
- {
- HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
- char*szProto;
- char urltext[300];
- char titlebartxt[300];
- int contactcount = 0;
-
- //
- ZeroMemory(&urltext, sizeof(urltext));
- ZeroMemory(&titlebartxt, sizeof(titlebartxt));
-
- //GetDlgItemText(hwndDlg, IDC_HIDDEN_URL, urltext, sizeof(urltext));
- GetDlgItemText(hwndDlg, IDC_OPEN_URL, urltext, sizeof(urltext));
- GetWindowText(hwndDlg, titlebartxt, sizeof(titlebartxt));
-
- while (hContact != NULL)
- {
- szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0);
- if (szProto != NULL && !lstrcmp(MODULENAME, szProto))
- {
- DBGetContactSetting(hContact, MODULENAME, URL_KEY, &dbv);
- DBGetContactSetting(hContact, MODULENAME, PRESERVE_NAME_KEY, &dbv2);
-
- if ((!lstrcmp(urltext, dbv.pszVal)) && (!lstrcmp(titlebartxt, dbv2.pszVal)))
- {
- contactcount++;
- if (contactcount > 1)
- {
- MessageBox(NULL, Translate("ERROR: You have two or more Webview contacts with the same URL and contact name."), MODULENAME, MB_OK);
- break;
- }
- ContactHwnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_CONTACT_OPT), hwndDlg, DlgProcContactOpt, (LPARAM) (HANDLE) hContact);
- ShowWindow(ContactHwnd, SW_SHOW);
- SetActiveWindow(ContactHwnd);
- EnableWindow(GetDlgItem(hwndDlg, IDC_OPTIONS_BUTTON), 0);
- EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_BUTTON), 0);
-
- }
- DBFreeVariant(&dbv);
- DBFreeVariant(&dbv2);
-
- }
- hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0);
- }
-
- //
- }
- break;
-
- // ///
- case IDC_ALERT_BUTTON:
- {
- HWND hwndAlertOpt;
- HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
- char*szProto;
- char urltext[300];
- char titlebartxt[300];
- int contactcount = 0;
-
- //
- ZeroMemory(&urltext, sizeof(urltext));
- ZeroMemory(&titlebartxt, sizeof(titlebartxt));
-
- //GetDlgItemText(hwndDlg, IDC_HIDDEN_URL, urltext, sizeof(urltext));
- GetDlgItemText(hwndDlg, IDC_OPEN_URL, urltext, sizeof(urltext));
- GetWindowText(hwndDlg, titlebartxt, sizeof(titlebartxt));
-
- while (hContact != NULL)
- {
- szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0);
- if (szProto != NULL && !lstrcmp(MODULENAME, szProto))
- {
- DBGetContactSetting(hContact, MODULENAME, URL_KEY, &dbv);
- DBGetContactSetting(hContact, MODULENAME, PRESERVE_NAME_KEY, &dbv2);
-
- if ((!lstrcmp(urltext, dbv.pszVal)) && (!lstrcmp(titlebartxt, dbv2.pszVal)))
- {
- contactcount++;
- if (contactcount > 1)
- {
- MessageBox(NULL, Translate("ERROR: You have two or more Webview contacts with the same URL and contact name."), MODULENAME, MB_OK);
- break;
- }
- hwndAlertOpt = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ALRT_OPT), hwndDlg, DlgProcAlertOpt, (LPARAM) (HANDLE) hContact);
- ShowWindow(hwndAlertOpt, SW_SHOW);
- SetActiveWindow(hwndAlertOpt);
- EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_BUTTON), 0);
- EnableWindow(GetDlgItem(hwndDlg, IDC_OPTIONS_BUTTON), 0);
-
- }
- DBFreeVariant(&dbv);
- DBFreeVariant(&dbv2);
- }
- hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0);
- }
-
- }
- break;
-
- case IDOK:
- case IDCANCEL:
- if (hwndDlg != NULL)
- DestroyWindow(hwndDlg);
- return TRUE;
- }
- break;
-
- break;
-
- case WM_CLOSE:
- {
- //
- HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
- char*szProto;
- char urltext[300];
- char titlebartxt[300];
- int contactcount = 0;
-
- if (Yposition == -32000)
- Yposition = 100;
-
- if (Xposition == -32000)
- Xposition = 100;
-
- SavewinSettings();
-
- /**/
- //
- ZeroMemory(&urltext, sizeof(urltext));
- ZeroMemory(&titlebartxt, sizeof(titlebartxt));
-
- //GetDlgItemText(hwndDlg, IDC_HIDDEN_URL, urltext, sizeof(urltext));
- GetDlgItemText(hwndDlg, IDC_OPEN_URL, urltext, sizeof(urltext));
- GetWindowText(hwndDlg, titlebartxt, sizeof(titlebartxt));
-
- while (hContact != NULL)
- {
- szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0);
- if (szProto != NULL && !lstrcmp(MODULENAME, szProto))
- {
- DBGetContactSetting(hContact, MODULENAME, URL_KEY, &dbv);
- DBGetContactSetting(hContact, MODULENAME, PRESERVE_NAME_KEY, &dbv2);
-
- if ((!lstrcmp(urltext, dbv.pszVal)) && (!lstrcmp(titlebartxt, dbv2.pszVal)))
- {
- contactcount++;
- if (contactcount > 1)
- break;
-
- //
- Utils_SaveWindowPosition(hwndDlg, hContact, MODULENAME, "WV");
-
- //
-
- }
- DBFreeVariant(&dbv);
- DBFreeVariant(&dbv2);
-
- }
- hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0);
- }
-
- /**/
-
- if (hwndDlg != NULL)
- DestroyWindow(hwndDlg);
- return 0;
- break;
- }
-
- case WM_DESTROY:
- {
- WindowList_Remove(hWindowList, hwndDlg);
- return 0;
- break;
- }
-
- case WM_SIZE:
- {
- UTILRESIZEDIALOG urd = {0};
-
- urd.cbSize = sizeof(urd);
- urd.hInstance = hInst;
- urd.hwndDlg = hwndDlg;
- urd.lParam = 0;
- urd.lpTemplate = MAKEINTRESOURCE(IDD_DISPLAY_DATA);
- urd.pfnResizer = DataDialogResize;
- CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM) & urd);
- InvalidateRect(hwndDlg, NULL, TRUE);
-
- GetWindowRect(hwndDlg, &rc);
-
- // global
- 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;
- return 0;
- }
- ValidatePosition(hwndDlg);
-
- }
- }
- return FALSE;
+ DBVARIANT dbv, dbv2;
+ RECT rc;
+ char url[300];
+
+ switch (msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+ {
+ HANDLE hContact2 = (HANDLE) lParam;
+
+ SetWindowLong(hwndDlg, GWLP_USERDATA, (LONG) hContact2);
+ WindowList_Add(hWindowList, hwndDlg, hContact2);
+
+ url[0] = '\0';
+ db_get_s(hContact2, MODULENAME, URL_KEY, &dbv);
+ _snprintf(url, sizeof(url), "%s", dbv.pszVal);
+ db_free(&dbv);
+
+ char buttontext[256];
+ char stringbefore[256];
+ char*stringafter;
+ char newbuttontext[256];
+ int pos = 0;
+ int posafter = 0;
+ int posbefore = 0;
+
+ ZeroMemory(&buttontext, sizeof(buttontext));
+ ZeroMemory(&newbuttontext, sizeof(newbuttontext));
+ _snprintf(buttontext, sizeof(buttontext), "%s", url);
+ _snprintf(newbuttontext, sizeof(newbuttontext), "%s", url);
+
+ if ((strstr(newbuttontext, "&")) != 0) {
+ while (1) {
+ ZeroMemory(&stringbefore, sizeof(stringbefore));
+
+ if ((strstr(newbuttontext, "&")) == 0)
+ break;
+
+ _snprintf(buttontext, sizeof(buttontext), "%s", newbuttontext);
+ stringafter = strstr(buttontext, "&");
+ pos = (stringafter - buttontext);
+ posbefore = (stringafter - buttontext) - 1;
+ posafter = (stringafter - buttontext) + 1;
+ strncpy(&stringafter[0], &stringafter[1], strlen(stringafter));
+ _snprintf(stringbefore, pos, "%s", buttontext);
+ _snprintf(newbuttontext, sizeof(buttontext), "%s%s%s", stringbefore, "!!", stringafter);
+
+ posafter = 0;
+ posbefore = 0;
+ }
+
+ while (1) {
+ if ((strstr(newbuttontext, "!")) != 0) {
+ stringafter = strstr(newbuttontext, "!");
+ pos = (stringafter - newbuttontext);
+ newbuttontext[pos] = '&';
+ }
+ if ((strstr(newbuttontext, "!")) == 0)
+ break;
+ }
+ }
+
+ SetDlgItemTextA(hwndDlg, IDC_OPEN_URL, newbuttontext);
+
+ char preservename[100];
+ db_get_s(hContact2, MODULENAME, PRESERVE_NAME_KEY, &dbv);
+ mir_snprintf(preservename, sizeof(preservename), "%s", dbv.pszVal);
+ db_free(&dbv);
+ SetWindowTextA(hwndDlg, preservename);
+
+ SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM) LoadIcon(hInst, 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) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_UPDATE), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)));
+ SendMessage(GetDlgItem(hwndDlg, IDC_UPDATE_BUTTON), BUTTONADDTOOLTIP, (WPARAM) Translate("Update Data"), 0);
+
+ SendDlgItemMessage(hwndDlg, IDC_FIND_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_FIND), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)));
+ SendMessage(GetDlgItem(hwndDlg, IDC_FIND_BUTTON), BUTTONADDTOOLTIP, (WPARAM) Translate("Find"), 0);
+
+ SendDlgItemMessage(hwndDlg, IDC_OPTIONS_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_OPTIONS), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)));
+ SendMessage(GetDlgItem(hwndDlg, IDC_OPTIONS_BUTTON), BUTTONADDTOOLTIP, (WPARAM) Translate("Contact Options"), 0);
+
+ SendDlgItemMessage(hwndDlg, IDC_ALERT_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_ALERT), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)));
+ SendMessage(GetDlgItem(hwndDlg, IDC_ALERT_BUTTON), BUTTONADDTOOLTIP, (WPARAM) Translate("Alert Options"), 0);
+
+ SendDlgItemMessage(hwndDlg, IDC_STOP, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_STOP), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)));
+ SendMessage(GetDlgItem(hwndDlg, IDC_STOP), BUTTONADDTOOLTIP, (WPARAM) Translate("Stop Processing"), 0);
+
+ SendMessage(GetDlgItem(hwndDlg, IDC_OPEN_URL), BUTTONADDTOOLTIP, (WPARAM) Translate("Click here to open this URL in a browser window."), 0);
+
+ if ( !db_get_b(hContact2, MODULENAME, ON_TOP_KEY, 0)) {
+ SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_UNSTICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)));
+ SendMessage(GetDlgItem(hwndDlg, IDC_STICK_BUTTON), BUTTONADDTOOLTIP, (WPARAM) Translate("Stick to the front"), 0);
+ }
+ if ( db_get_b(hContact2, MODULENAME, ON_TOP_KEY, 0)) {
+ SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_STICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)));
+ SendMessage(GetDlgItem(hwndDlg, IDC_STICK_BUTTON), BUTTONADDTOOLTIP, (WPARAM) Translate("Disable Stick to the Front"), 0);
+ }
+
+ SendMessage(GetDlgItem(hwndDlg, IDC_DATA), WM_SETFONT, (WPARAM) h_font, 1);
+
+ txtcolor = TextClr;
+
+ SetDlgItemTextA(hwndDlg, IDC_DATA, "");
+
+ InvalidateRect(hwndDlg, NULL, 1);
+
+ SendMessage(GetDlgItem(hwndDlg, IDC_DATA), EM_AUTOURLDETECT, 1, 0);
+ int mask = (int) SendMessage(GetDlgItem(hwndDlg, IDC_DATA), EM_GETEVENTMASK, 0, 0);
+
+ SendMessage(GetDlgItem(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);
+ {
+ int partWidth[2];
+ SIZE textSize;
+ HDC hdc;
+
+ hdc = GetDC(GetDlgItem(hwndDlg, IDC_STATUSBAR));
+ SelectObject(hdc, (HFONT) SendDlgItemMessage(hwndDlg, IDC_STATUSBAR, WM_GETFONT, 0, 0));
+ GetTextExtentPoint32A(hdc, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", lstrlenA("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"), &textSize);
+ partWidth[0] = textSize.cx;
+ ReleaseDC(GetDlgItem(hwndDlg, IDC_STATUSBAR), hdc);
+ partWidth[1] = -1;
+ SendDlgItemMessage(hwndDlg, IDC_STATUSBAR, SB_SETPARTS, sizeof(partWidth) / sizeof(partWidth[0]), (LPARAM) partWidth);
+ SendDlgItemMessage(hwndDlg, IDC_STATUSBAR, SB_SETTEXT, 1 | SBT_OWNERDRAW, 0);
+
+ }
+
+ if ( db_get_b(NULL, MODULENAME, 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);
+ CallService(MS_LANGPACK_TRANSLATEMENU, (WPARAM) hSubMenu, 0);
+ 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, NULL)) {
+ 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, '@') != NULL && strchr(tr.lpstrText, ':') == NULL && strchr(tr.lpstrText, '/') == NULL) {
+ MoveMemory(tr.lpstrText + 7, tr.lpstrText, tr.chrg.cpMax - tr.chrg.cpMin + 1);
+ CopyMemory(tr.lpstrText, "mailto:", 7);
+ }
+
+ CallService(MS_UTILS_OPENURL, 1, (LPARAM) tr.lpstrText);
+ SetFocus(GetDlgItem(hwndDlg, IDC_DATA));
+
+ free(tr.lpstrText);
+ break;
+ }
+ }
+ break; // notify
+
+ case WM_COMMAND:
+ switch (LOWORD(wParam)) {
+ case IDC_OPEN_URL:
+ ZeroMemory(&url, sizeof(url));
+ GetDlgItemTextA(hwndDlg, IDC_OPEN_URL, url, sizeof(url));
+ CallService(MS_UTILS_OPENURL, 1, (LPARAM) url);
+ db_set_w((HANDLE)wParam, MODULENAME, "Status", ID_STATUS_ONLINE);
+ break;
+
+ case IDC_UPDATE_BUTTON:
+ {
+ char urltext[300];
+ char titlebartxt[300];
+ int contactcount = 0;
+
+ ZeroMemory(&urltext, sizeof(urltext));
+ ZeroMemory(&titlebartxt, sizeof(titlebartxt));
+
+ //GetDlgItemText(hwndDlg, IDC_HIDDEN_URL, urltext, sizeof(urltext));
+ GetDlgItemTextA(hwndDlg, IDC_OPEN_URL, urltext, sizeof(urltext));
+ GetWindowTextA(hwndDlg, titlebartxt, sizeof(titlebartxt));
+
+ for (HANDLE hContact = db_find_first(MODULENAME); hContact != NULL; hContact = db_find_next(hContact, MODULENAME)) {
+ db_get_s(hContact, MODULENAME, URL_KEY, &dbv);
+ db_get_s(hContact, MODULENAME, PRESERVE_NAME_KEY, &dbv2);
+
+ if ( !lstrcmpA(urltext, dbv.pszVal) && !lstrcmpA(titlebartxt, dbv2.pszVal)) {
+ contactcount++;
+ if (contactcount > 1) {
+ MessageBox(NULL, TranslateT("ERROR: You have two or more Webview contacts with the same URL and contact name."), _T(MODULENAME), MB_OK);
+ break;
+ }
+ EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE_BUTTON), 0);
+ UpdateMenuCommand(wParam, lParam, hContact);
+ }
+ db_free(&dbv);
+ db_free(&dbv2);
+ }
+ }
+ break;
+
+ case IDC_STOP:
+ {
+ char urltext[300];
+ char titlebartxt[300];
+ int contactcount = 0;
+
+ ZeroMemory(&urltext, sizeof(urltext));
+ ZeroMemory(&titlebartxt, sizeof(titlebartxt));
+
+ //GetDlgItemText(hwndDlg, IDC_HIDDEN_URL, urltext, sizeof(urltext));
+ GetDlgItemTextA(hwndDlg, IDC_OPEN_URL, urltext, sizeof(urltext));
+ GetWindowTextA(hwndDlg, titlebartxt, sizeof(titlebartxt));
+
+ for (HANDLE hContact = db_find_first(MODULENAME); hContact != NULL; hContact = db_find_next(hContact, MODULENAME)) {
+ db_get_s(hContact, MODULENAME, URL_KEY, &dbv);
+ db_get_s(hContact, MODULENAME, PRESERVE_NAME_KEY, &dbv2);
+
+ if ( !lstrcmpA(urltext, dbv.pszVal) && !lstrcmpA(titlebartxt, dbv2.pszVal)) {
+ contactcount++;
+ if (contactcount > 1) {
+ MessageBox(NULL, TranslateT("ERROR: You have two or more Webview contacts with the same URL and contact name."), _T(MODULENAME), MB_OK);
+ break;
+ }
+ db_set_b(hContact, MODULENAME, STOP_KEY, 1);
+ }
+ db_free(&dbv);
+ db_free(&dbv2);
+ }
+ }
+ break;
+
+ case IDC_STICK_BUTTON:
+ {
+ char urltext2[300];
+ char titlebartxt[300];
+ int contactcount = 0;
+
+ ZeroMemory(&urltext2, sizeof(urltext2));
+ ZeroMemory(&titlebartxt, sizeof(titlebartxt));
+
+ GetDlgItemTextA(hwndDlg, IDC_OPEN_URL, urltext2, sizeof(urltext2));
+ GetWindowTextA(hwndDlg, titlebartxt, sizeof(titlebartxt));
+
+ HANDLE hContact;
+ for (hContact = db_find_first(MODULENAME); hContact != NULL; hContact = db_find_next(hContact, MODULENAME)) {
+ db_get_s(hContact, MODULENAME, URL_KEY, &dbv);
+ db_get_s(hContact, MODULENAME, PRESERVE_NAME_KEY, &dbv2);
+
+ if ( !lstrcmpA(urltext2, dbv.pszVal) && !lstrcmpA(titlebartxt, dbv2.pszVal)) {
+ contactcount++;
+ if (contactcount > 1) {
+ MessageBox(NULL, TranslateT("ERROR: You have two or more Webview contacts with the same URL and contact name."), _T(MODULENAME), MB_OK);
+ break;
+ }
+ OnTopMenuCommand(wParam, lParam, hContact);
+ db_free(&dbv);
+ break;
+ }
+ db_free(&dbv);
+ db_free(&dbv2);
+ }
+
+ // ////////
+
+ TCHAR *ptszToolTip;
+ HWND hTopmost;
+ if ( !db_get_b(hContact, MODULENAME, 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) ((HICON) LoadImage(hInst, MAKEINTRESOURCE(IDI_UNSTICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)));
+ SendMessage(GetDlgItem(hwndDlg, IDC_STICK_BUTTON), BUTTONADDTOOLTIP, (WPARAM)ptszToolTip, BATF_TCHAR);
+ SetWindowPos(hwndDlg, hTopmost, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
+ db_free(&dbv);
+ }
+ break;
+
+ case IDC_FIND_BUTTON:
+ {
+ HWND hwndFind = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_FIND), hwndDlg, DlgProcFind, (LPARAM) (HANDLE) wParam);
+ ShowWindow(hwndFind, SW_SHOW);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_FIND_BUTTON), 0);
+ }
+ break;
+
+ case IDC_OPTIONS_BUTTON:
+ {
+ char urltext[300];
+ char titlebartxt[300];
+ int contactcount = 0;
+
+ //
+ ZeroMemory(&urltext, sizeof(urltext));
+ ZeroMemory(&titlebartxt, sizeof(titlebartxt));
+
+ //GetDlgItemText(hwndDlg, IDC_HIDDEN_URL, urltext, sizeof(urltext));
+ GetDlgItemTextA(hwndDlg, IDC_OPEN_URL, urltext, sizeof(urltext));
+ GetWindowTextA(hwndDlg, titlebartxt, sizeof(titlebartxt));
+
+ for (HANDLE hContact = db_find_first(MODULENAME); hContact != NULL; hContact = db_find_next(hContact, MODULENAME)) {
+ db_get_s(hContact, MODULENAME, URL_KEY, &dbv);
+ db_get_s(hContact, MODULENAME, PRESERVE_NAME_KEY, &dbv2);
+
+ if ( !lstrcmpA(urltext, dbv.pszVal) && !lstrcmpA(titlebartxt, dbv2.pszVal)) {
+ contactcount++;
+ if (contactcount > 1) {
+ MessageBox(NULL, TranslateT("ERROR: You have two or more Webview contacts with the same URL and contact name."), _T(MODULENAME), MB_OK);
+ break;
+ }
+ ContactHwnd = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_CONTACT_OPT), hwndDlg, DlgProcContactOpt, (LPARAM) (HANDLE) hContact);
+ ShowWindow(ContactHwnd, SW_SHOW);
+ SetActiveWindow(ContactHwnd);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_OPTIONS_BUTTON), 0);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_BUTTON), 0);
+
+ }
+ db_free(&dbv);
+ db_free(&dbv2);
+ }
+ }
+ break;
+
+ case IDC_ALERT_BUTTON:
+ {
+ HWND hwndAlertOpt;
+ char urltext[300];
+ char titlebartxt[300];
+ int contactcount = 0;
+
+ ZeroMemory(&urltext, sizeof(urltext));
+ ZeroMemory(&titlebartxt, sizeof(titlebartxt));
+
+ //GetDlgItemText(hwndDlg, IDC_HIDDEN_URL, urltext, sizeof(urltext));
+ GetDlgItemTextA(hwndDlg, IDC_OPEN_URL, urltext, sizeof(urltext));
+ GetWindowTextA(hwndDlg, titlebartxt, sizeof(titlebartxt));
+
+ for (HANDLE hContact = db_find_first(MODULENAME); hContact != NULL; hContact = db_find_next(hContact, MODULENAME)) {
+ db_get_s(hContact, MODULENAME, URL_KEY, &dbv);
+ db_get_s(hContact, MODULENAME, PRESERVE_NAME_KEY, &dbv2);
+
+ if ( !lstrcmpA(urltext, dbv.pszVal) && !lstrcmpA(titlebartxt, dbv2.pszVal)) {
+ contactcount++;
+ if (contactcount > 1) {
+ MessageBox(NULL, TranslateT("ERROR: You have two or more Webview contacts with the same URL and contact name."), _T(MODULENAME), MB_OK);
+ break;
+ }
+ hwndAlertOpt = CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_ALRT_OPT), hwndDlg, DlgProcAlertOpt, (LPARAM) (HANDLE) hContact);
+ ShowWindow(hwndAlertOpt, SW_SHOW);
+ SetActiveWindow(hwndAlertOpt);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_BUTTON), 0);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_OPTIONS_BUTTON), 0);
+
+ }
+ db_free(&dbv);
+ db_free(&dbv2);
+ }
+ }
+ break;
+
+ case IDOK:
+ case IDCANCEL:
+ if (hwndDlg != NULL)
+ DestroyWindow(hwndDlg);
+ return TRUE;
+ }
+ break;
+
+ case WM_CLOSE:
+ {
+ char urltext[300];
+ char titlebartxt[300];
+ int contactcount = 0;
+
+ if (Yposition == -32000)
+ Yposition = 100;
+
+ if (Xposition == -32000)
+ Xposition = 100;
+
+ SavewinSettings();
+
+ /**/
+ //
+ ZeroMemory(&urltext, sizeof(urltext));
+ ZeroMemory(&titlebartxt, sizeof(titlebartxt));
+
+ //GetDlgItemText(hwndDlg, IDC_HIDDEN_URL, urltext, sizeof(urltext));
+ GetDlgItemTextA(hwndDlg, IDC_OPEN_URL, urltext, sizeof(urltext));
+ GetWindowTextA(hwndDlg, titlebartxt, sizeof(titlebartxt));
+
+ for (HANDLE hContact = db_find_first(MODULENAME); hContact != NULL; hContact = db_find_next(hContact, MODULENAME)) {
+ db_get_s(hContact, MODULENAME, URL_KEY, &dbv);
+ db_get_s(hContact, MODULENAME, PRESERVE_NAME_KEY, &dbv2);
+
+ if ( !lstrcmpA(urltext, dbv.pszVal) && !lstrcmpA(titlebartxt, dbv2.pszVal)) {
+ contactcount++;
+ if (contactcount > 1)
+ break;
+
+ Utils_SaveWindowPosition(hwndDlg, hContact, MODULENAME, "WV");
+ }
+ db_free(&dbv);
+ db_free(&dbv2);
+ }
+
+ if (hwndDlg != NULL)
+ DestroyWindow(hwndDlg);
+ }
+ return 0;
+
+ case WM_DESTROY:
+ WindowList_Remove(hWindowList, hwndDlg);
+ return 0;
+
+ case WM_SIZE:
+ {
+ UTILRESIZEDIALOG urd = {0};
+
+ urd.cbSize = sizeof(urd);
+ urd.hInstance = hInst;
+ urd.hwndDlg = hwndDlg;
+ urd.lParam = 0;
+ urd.lpTemplate = MAKEINTRESOURCEA(IDD_DISPLAY_DATA);
+ urd.pfnResizer = DataDialogResize;
+ CallService(MS_UTILS_RESIZEDIALOG, 0, (LPARAM) & urd);
+ InvalidateRect(hwndDlg, NULL, TRUE);
+
+ GetWindowRect(hwndDlg, &rc);
+
+ // global
+ 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 hwndDlg, LPARAM 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;
+ 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 (Yposition == -32000)
- Yposition = 100;
-
- if (Xposition == -32000)
- Xposition = 100;
+ if (Xposition == -32000)
+ Xposition = 100;
- db_set_dw(NULL, MODULENAME, Xpos_WIN_KEY, Xposition);
- db_set_dw(NULL, MODULENAME, Ypos_WIN_KEY, Yposition);
+ db_set_dw(NULL, MODULENAME, Xpos_WIN_KEY, Xposition);
+ db_set_dw(NULL, MODULENAME, Ypos_WIN_KEY, Yposition);
- db_set_dw(NULL, MODULENAME, BG_COLOR_KEY, BackgoundClr);
- db_set_dw(NULL, MODULENAME, TXT_COLOR_KEY, TextClr);
- db_set_dw(NULL, MODULENAME, WIN_HEIGHT_KEY, WindowHeight);
- db_set_dw(NULL, MODULENAME, WIN_WIDTH_KEY, WindowWidth);
+ db_set_dw(NULL, MODULENAME, BG_COLOR_KEY, BackgoundClr);
+ db_set_dw(NULL, MODULENAME, TXT_COLOR_KEY, TextClr);
+ db_set_dw(NULL, MODULENAME, WIN_HEIGHT_KEY, WindowHeight);
+ db_set_dw(NULL, MODULENAME, WIN_WIDTH_KEY, WindowWidth);
}
-/************/
-/************************/
+/*****************************************************************************/
void ValidatePosition(HWND hwndDlg)
{
- RECT r;
- POINT pt;
+ typedef HMONITOR WINAPI MyMonitorFromPoint(POINT, DWORD);
+ typedef BOOL WINAPI MyGetMonitorInfo(HMONITOR, LPMONITORINFO);
- typedef HMONITOR WINAPI MyMonitorFromPoint(POINT, DWORD);
- typedef BOOL WINAPI MyGetMonitorInfo(HMONITOR, LPMONITORINFO);
+ HMODULE hUserInstance = GetModuleHandleA("user32");
- HMODULE hUserInstance = GetModuleHandle("user32");
+ RECT r;
+ SystemParametersInfo(SPI_GETWORKAREA, 0, &r, 0);
- SystemParametersInfo(SPI_GETWORKAREA, 0, &r, 0);
+ MyGetMonitorInfo *LPMyGetMonitorInfo = (MyGetMonitorInfo*)GetProcAddress(hUserInstance, "GetMonitorInfoA");
+ MyMonitorFromPoint *LPMyMonitorFromPoint = (MyMonitorFromPoint*)GetProcAddress(hUserInstance, "MonitorFromPoint");
+ if (LPMyMonitorFromPoint == NULL || LPMyGetMonitorInfo == NULL)
+ return;
- MyMonitorFromPoint *LPMyMonitorFromPoint = (MyMonitorFromPoint *) GetProcAddress(hUserInstance, "MonitorFromPoint");
+ POINT pt = { 0, 0 };
+ HMONITOR hMonitor = LPMyMonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST); // always
- if (LPMyMonitorFromPoint)
- {
- MONITORINFO monitorInfo;
- HMONITOR hMonitor = LPMyMonitorFromPoint(pt, MONITOR_DEFAULTTONEAREST); // always
+ MONITORINFO monitorInfo;
+ monitorInfo.cbSize = sizeof(MONITORINFO);
+ if ( LPMyGetMonitorInfo(hMonitor, &monitorInfo))
+ CopyMemory(&r, &monitorInfo.rcMonitor, sizeof(RECT));
- //
+ // /window going off right of screen*
+ if ((Xposition + WindowWidth) >= r.right)
+ Xposition = r.right - WindowWidth;
- // returns
- // a
- // valid
- // value
+ // window going off bottom of screen
+ if ((Yposition + (WindowHeight)) >= r.bottom)
+ Yposition = r.bottom - WindowHeight;
- monitorInfo.cbSize = sizeof(MONITORINFO);
-
- if ((MyGetMonitorInfo *) GetProcAddress(hUserInstance, "GetMonitorInfoA") (hMonitor, &monitorInfo))
- {
- CopyMemory(&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;
-
- }
+ // window going off left of screen
+ if (Xposition >= r.right)
+ Xposition = 0;
}
-
-/***********************/
diff --git a/plugins/WebView/src/webview_getdata.cpp b/plugins/WebView/src/webview_getdata.cpp
index dae383ab86..068065d04a 100644
--- a/plugins/WebView/src/webview_getdata.cpp
+++ b/plugins/WebView/src/webview_getdata.cpp
@@ -1,957 +1,542 @@
/*
- * 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.
- */
+* 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 HANDLE hNetlibUser = NULL;
int Startingup = 1;
int AlreadyDownloading = 0;
/*******************/
-static void GetData(void *AContact)
+void GetData(HANDLE hContact)
{
- int statpos = 0, dispos = 0, statposend = 0;
- char*pos;
- DBVARIANT dbv;
- NETLIBHTTPREQUEST nlhr = {0}
- , *nlhrReply;
- NETLIBHTTPHEADER headers[2];
- char tempstring[300], tempstring2[300];
- int MallocSize = 0;
- int DownloadSuccess = 0;
- char*raw;
- char*szInfo;
- char truncated[MAXSIZE1];
- char truncated2[MAXSIZE2];
- int trunccount = 0;
- char url[300];
- unsigned long downloadsize = 0;
- int AmountWspcRem = 0;
- static char contactname[100];
- char statustext[200];
- 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, AContact));
-
- Startingup = 0;
-
- ZeroMemory(&url, sizeof(url));
- ZeroMemory(&contactname, sizeof(contactname));
- ZeroMemory(&tempstring, sizeof(tempstring));
- ZeroMemory(&tempstring2, sizeof(tempstring2));
- ZeroMemory(&szInfo, sizeof(szInfo));
- ZeroMemory(&dbv, sizeof(dbv));
- ZeroMemory(&tstr, sizeof(tstr));
- ZeroMemory(&timestring, sizeof(timestring));
-
-
- db_set_b(AContact, MODULENAME, STOP_KEY, 0);
-
-//
- if (DBGetContactSetting(AContact, MODULENAME, PRESERVE_NAME_KEY, &dbv))
- {
- DBFreeVariant(&dbv);
- DBGetContactSetting(AContact, "CList", "MyHandle", &dbv);
- db_set_s(AContact, MODULENAME, PRESERVE_NAME_KEY, dbv.pszVal);
- DBFreeVariant(&dbv);
- }
- DBGetContactSetting(AContact, MODULENAME, PRESERVE_NAME_KEY, &dbv);
- _snprintf(contactname, sizeof(contactname), "%s", dbv.pszVal);
- DBFreeVariant(&dbv);
- //MessageBox(NULL, contactname, "pro-contname0", MB_OK);
-//
-
- url[0] = '\0';
-
- if (!Startingup)
- db_set_b(NULL, MODULENAME, HAS_CRASHED_KEY, 1);
-
- //
- DBGetContactSetting(AContact, MODULENAME, START_STRING_KEY, &dbv);
- _snprintf(tempstring, sizeof(tempstring), "%s", dbv.pszVal);
- DBFreeVariant(&dbv);
- //
- DBGetContactSetting(AContact, MODULENAME, END_STRING_KEY, &dbv);
- _snprintf(tempstring2, sizeof(tempstring2), "%s", dbv.pszVal);
- DBFreeVariant(&dbv);
- //
- DBGetContactSetting(AContact, MODULENAME, URL_KEY, &dbv);
- _snprintf(url, sizeof(url), "%s", dbv.pszVal);
- DBFreeVariant(&dbv);
-
- if (strlen(url) < 3)
- {
- WErrorPopup(contactname, Translate("URL not supplied"));
- }
- nlhr.cbSize = sizeof(nlhr);
- nlhr.requestType = REQUEST_GET;
- nlhr.flags = NLHRF_DUMPASTEXT;
- nlhr.szUrl = url;
- nlhr.headersCount = 2;
-
- headers[0].szName = "User-Agent";
- headers[0].szValue = "Mozilla/4.0 (compatible; MSIE 6.0; Win32)";
-
- headers[1].szName = "Content-Length";
- headers[1].szValue = NULL;
-
- nlhr.headers = headers;
-
-// //////
- if ((db_get_b(NULL, MODULENAME, NO_PROTECT_KEY, 0))) // disable
- // download
- // protection
-
- 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);
-
- ZeroMemory(&statustext, sizeof(statustext));
- _snprintf(statustext, sizeof(statustext), " %s", Translate("Download in progress, please wait..."));
- SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext);
-
- ZeroMemory(&statustext, sizeof(statustext));
- _snprintf(statustext, sizeof(statustext), "%s", Translate("Updating..."));
- db_set_s(AContact, "CList", "StatusMsg", statustext);
-// /
-
- db_set_w(AContact, MODULENAME, "Status", ID_STATUS_DND); // download
- // and
- // processing
- // in
- // progress
-
- nlhrReply = (NETLIBHTTPREQUEST *) CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM) hNetlibUser, (LPARAM) & nlhr);
-
- if (nlhrReply)
- {
-
- if (nlhrReply->resultCode < 200 || nlhrReply->resultCode >= 300)
- {
- db_set_w(AContact, MODULENAME, "Status", ID_STATUS_AWAY);
- HWND hwndDlg = (WindowList_Find(hWindowList, AContact));
-
- ZeroMemory(&statustext, sizeof(statustext));
- _snprintf(statustext, sizeof(statustext), " %s (%d)", Translate("The server replied with a failure code"), nlhrReply->resultCode);
- SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext);
- WErrorPopup(contactname, statustext);
-
- ZeroMemory(&statustext, sizeof(statustext));
- _snprintf(statustext, sizeof(statustext), " %s (%d)", "HTTP ERROR: ", nlhrReply->resultCode);
- db_set_s(AContact, "CList", "StatusMsg", statustext);
- }
- if (nlhrReply->dataLength)
- {
- szInfo = malloc(lstrlen(nlhrReply->pData) + 2);
- lstrcpyn(szInfo, nlhrReply->pData, lstrlen(nlhrReply->pData));
- downloadsize = lstrlen(nlhrReply->pData);
-
- trunccount = 0;
- lstrcpyn(truncated2, szInfo, MAXSIZE2);
- free(szInfo);
-
-//////////////////////////////////////////
-
-/*
-#ifdef UNICODE_VERISON
-
-//semi works
-
- wchar_t tmp2[sizeof(nlhrReply->pData)];
-
-
-
-
-MultiByteToWideChar(CP_UTF8, 0, (CHAR *)nlhrReply->pData, -1, tmp2, strlen(nlhrReply->pData));
-
-SetDlgItemTextW(hwndDlg, IDC_DATA, (wchar_t *)&tmp2);
-//MessageBoxW(NULL, tmp2, L"Umm", MB_OK);
- #endif
-*/
-
-
-////////////////////////////////////////////
- sprintf(truncated2, "%s", nlhrReply->pData);
- AlreadyDownloading = 1;
- } // END DATELENGTH
-
- } // END REPLY
-
- if (!(nlhrReply))
- {
- db_set_w(AContact, MODULENAME, "Status", ID_STATUS_NA);
- HWND hwndDlg = (WindowList_Find(hWindowList, AContact));
-
- ZeroMemory(&statustext, sizeof(statustext));
- _snprintf(statustext, sizeof(statustext), " %s", Translate("The server is down or lagging."));
- SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext);
- WErrorPopup(contactname, statustext);
-
- ZeroMemory(&statustext, sizeof(statustext));
- _snprintf(statustext, sizeof(statustext), "%s", Translate("The server is down."));
- db_set_s(AContact, "CList", "StatusMsg", statustext);
-
-
-
- }
- if (!(nlhrReply))
- DownloadSuccess = 0;
-
- if ((nlhrReply) && (nlhrReply->resultCode < 200 || nlhrReply->resultCode >= 300))
- {
- DownloadSuccess = 0;
- } else if (nlhrReply)
- DownloadSuccess = 1;
-
- //
-
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM) nlhrReply);
-
- if (DownloadSuccess)
- {
- HWND hwndDlg = (WindowList_Find(hWindowList, AContact));
-
- ZeroMemory(&statustext, sizeof(statustext));
- _snprintf(statustext, sizeof(statustext), " %s", Translate("Download successful; about to process data..."));
- SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext);
- // MessageBox(NULL, "Crash", "1", MB_OK);
- }
-///get data in desired range
-
- // download successful
- if (DownloadSuccess)
- {
-
-// all the site
- if (db_get_b(AContact, MODULENAME, U_ALLSITE_KEY, 0) == 1)
- {
- lstrcpyn(truncated, truncated2, MAXSIZE1);
- } else // use start and end string
-
- {
- // putting data into string
- if (((strstr(truncated2, tempstring)) != 0) && ((strstr(truncated2, tempstring2)) != 0))
- {
-
-// start string
- pos = strstr(truncated2, tempstring);
- statpos = pos - truncated2;
-//
- ZeroMemory(&pos, sizeof(pos));
-// end string
- pos = strstr(truncated2, tempstring2);
- statposend = pos - truncated2 + strlen(tempstring2);
-//
- if (statpos > statposend)
- {
- memset(&truncated2, ' ', statpos);
- ZeroMemory(&pos, sizeof(pos));
- pos = strstr(truncated2, tempstring2);
- statposend = pos - truncated2 + strlen(tempstring2);
- }
- if (statpos < statposend)
- {
- ZeroMemory(&raw, sizeof(raw));
-
-// get size for malloc
- //MessageBox(NULL, "Crash", "2", MB_OK);
-
- 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 + strlen(tempstring2);
-//
- //MessageBox(NULL, "Crash", "3", MB_OK);
-
- if (statpos > statposend)
- {
- memset(&truncated2, ' ', statpos);
- ZeroMemory(&pos, sizeof(pos));
- pos = strstr(truncated2, tempstring2);
- statposend = pos - truncated2 + strlen(tempstring2);
- }
- dispos = 0;
-
-// write selected data to string
- //MessageBox(NULL, "Crash", "4", MB_OK);
-
- strncpy(raw, &truncated2[statpos], MallocSize);
- raw[MallocSize] = '\0';
-
- trunccount = 0;
-
- lstrcpyn(truncated, raw, MAXSIZE1);
-
- //MessageBox(NULL, "Crash", "5", MB_OK);
- /*
-#ifdef UNICODE_VERISON
-
-
- wchar_t tmp2[50];
-
- MessageBox(NULL, raw, "raw", MB_OK);
-
- int c = lstrlenA(raw);
-MultiByteToWideChar(CP_ACP, 0, raw, c, tmp2, c);
-
-//MessageBoxW(NULL, tmp2, MODULENAME, MB_OK);
- #endif
-*/
- free(raw);
-
- //MessageBox(NULL, "Crash", "6", MB_OK);
-
- DownloadSuccess = 1;
-
- } else if (db_get_b(AContact, MODULENAME, U_ALLSITE_KEY, 0) == 0)
- {
- ZeroMemory(&statustext, sizeof(statustext));
- _snprintf(statustext, sizeof(statustext), " %s", Translate("Invalid search parameters."));
- WErrorPopup(contactname, statustext);
- HWND hwndDlg = (WindowList_Find(hWindowList, AContact));
-
- DownloadSuccess = 0;
- SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext);
- db_set_w(AContact, MODULENAME, "Status", ID_STATUS_AWAY);
- }
- } // end putting data into string
-
- } // end use start and end strings
-
- } // end download success
-
- //MessageBox(NULL, "Crash", "7", MB_OK);
-
- if (DownloadSuccess) // download success
-
- {
- if (statpos == 0 && statposend == 0)
- {
- if (db_get_b(AContact, MODULENAME, U_ALLSITE_KEY, 0) == 0)
- {
- ZeroMemory(&statustext, sizeof(statustext));
- _snprintf(statustext, sizeof(statustext), " %s", Translate("Both search strings not found or strings not set."));
- WErrorPopup(contactname, statustext);
- db_set_s(AContact, "CList", "StatusMsg", statustext);
- HWND hwndDlg = (WindowList_Find(hWindowList, AContact));
-
- DownloadSuccess = 0;
- SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext);
- TherewasAlert = ProcessAlerts(AContact, statustext, contactname, contactname, 1);
- db_set_w(AContact, MODULENAME, "Status", ID_STATUS_AWAY);
- }
- }
- } // end download success
- // //////
- //MessageBox(NULL, "Crash", "8", MB_OK);
-
- 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;
-
- setlocale(LC_ALL, "");
-
- if (!DBGetContactSetting(AContact, MODULENAME, PRESERVE_NAME_KEY, &dbv))
- {
- ZeroMemory(&temptime, sizeof(temptime));
- ZeroMemory(&tstr, sizeof(tstr));
- ftime = time(NULL);
- nTime = localtime(&ftime);
- // 12 hour
- if (db_get_b(AContact, MODULENAME, USE_24_HOUR_KEY, 0) == 0)
- strftime(temptime, 128, "(%b %d,%I:%M %p)", nTime);
- // 24 hour
- if (db_get_b(AContact, MODULENAME, USE_24_HOUR_KEY, 0) == 1)
- strftime(temptime, 128, "(%b %d,%H:%M:%S)", nTime);
-
- if (db_get_b(AContact, MODULENAME, CONTACT_PREFIX_KEY, 1) == 1)
- _snprintf(tstr, sizeof(tstr), "%s %s", temptime, dbv.pszVal);
- if (db_get_b(AContact, MODULENAME, CONTACT_PREFIX_KEY, 1) == 0)
- _snprintf(tstr, sizeof(tstr), "%s %s", dbv.pszVal, temptime);
- DBFreeVariant(&dbv);
- } else if (DBGetContactSetting(AContact, MODULENAME, PRESERVE_NAME_KEY, &dbv))
- {
- DBFreeVariant(&dbv);
- DBGetContactSetting(AContact, "CList", "MyHandle", &dbv);
- ZeroMemory(&temptime, sizeof(temptime));
- ZeroMemory(&tstr, sizeof(tstr));
- ftime = time(NULL);
- nTime = localtime(&ftime);
- // 12 hour
- if (db_get_b(AContact, MODULENAME, USE_24_HOUR_KEY, 0) == 0)
- strftime(temptime, 128, "(%b %d,%I:%M %p)", nTime);
- // 24 hour
- if (db_get_b(AContact, MODULENAME, USE_24_HOUR_KEY, 0) == 1)
- strftime(temptime, 128, "(%b %d,%H:%M:%S)", nTime);
-
- db_set_s(AContact, MODULENAME, PRESERVE_NAME_KEY, dbv.pszVal);
- if (db_get_b(AContact, MODULENAME, CONTACT_PREFIX_KEY, 1) == 1)
- _snprintf(tstr, sizeof(tstr), "%s %s", temptime, dbv.pszVal);
- if (db_get_b(AContact, MODULENAME, CONTACT_PREFIX_KEY, 1) == 0)
- _snprintf(tstr, sizeof(tstr), "%s %s", dbv.pszVal, temptime);
- DBFreeVariant(&dbv);
- }
- ZeroMemory(&timeprefix, sizeof(timeprefix));
- ZeroMemory(&temptime1, sizeof(temptime1));
- ZeroMemory(&timeat, sizeof(timeat));
- ZeroMemory(&temptime2, sizeof(temptime2));
- ZeroMemory(&timestring, sizeof(timestring));
-
- ftime = time(NULL);
- nTime = localtime(&ftime);
-
- _snprintf(timeprefix, sizeof(timeprefix), " %s ", (Translate("Last updated on")));
- strftime(temptime1, 32, " %a, %b %d, %Y ", nTime);
- _snprintf(timeat, sizeof(timeat), "%s", (Translate("at the time")));
- strftime(temptime2, 32, " %I:%M %p.", nTime);
- _snprintf(timestring, sizeof(timestring), "%s%s%s%s", timeprefix, temptime1, timeat, temptime2);
-
- } // end download success
-
- //MessageBox(NULL, "Crash", "9", MB_OK);
-////////
-
- if (DownloadSuccess)
- {
- // alertfunc
- //MessageBox(NULL, contactname, "pro-contname1", MB_OK);
- TherewasAlert = ProcessAlerts(AContact, 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 = db_get_b(AContact, MODULENAME, EVNT_INDEX_KEY, 0);
-
- if (eventIndex == 2)
- {
-
- strncpy(buff, truncated, sizeof(buff));
-
- Filter(buff);
- //
-
- //
- DBGetContactSetting(AContact, MODULENAME, ALRT_S_STRING_KEY, &dbv);
- _snprintf(Alerttempstring, sizeof(Alerttempstring), "%s", dbv.pszVal);
- DBFreeVariant(&dbv);
- //
- DBGetContactSetting(AContact, MODULENAME, ALRT_E_STRING_KEY, &dbv);
- _snprintf(Alerttempstring2, sizeof(Alerttempstring2), "%s", dbv.pszVal);
- DBFreeVariant(&dbv);
- //
-
- // putting data into string
- if (((strstr(buff, Alerttempstring)) != 0) && ((strstr(buff, Alerttempstring2)) != 0))
- {
-
- //
- location = (strstr(buff, Alerttempstring)) - buff;
- location2 = (strstr(buff, Alerttempstring2)) - buff;
- //
-
- }
- }
- // ///////////////////////////
- }
- // ///////
- // MessageBox(NULL, "Crash", "10", MB_OK);
-
- if ((((strstr(truncated2, tempstring)) != 0) && ((strstr(truncated2, tempstring2)) != 0) && (db_get_b(AContact, MODULENAME, U_ALLSITE_KEY, 0) == 0)) || (db_get_b(AContact, MODULENAME, U_ALLSITE_KEY, 0) == 1))
- {
- // MessageBox(NULL, "Crash", "10a", MB_OK);
- RemoveTabs(truncated);
- //MessageBox(NULL, "Crash", "10b", MB_OK);
-
- if ((db_get_b(AContact, MODULENAME, CLEAR_DISPLAY_KEY, 0)))
- {
- HWND hwndDlg = (WindowList_Find(hWindowList, AContact));
- // MessageBox(NULL, "Crash", "10c", MB_OK);
-
- //
- ZeroMemory(&statustext, sizeof(statustext));
- // MessageBox(NULL, "Crash", "10d", MB_OK);
- _snprintf(statustext, sizeof(statustext), " %s", Translate("Processing data (Stage 1)"));
- //MessageBox(NULL, "Crash", "10e", MB_OK);
- //SetDlgItemText(hwndDlg, IDC_DATA, truncated);
- /**/
- SendToRichEdit(hwndDlg,
- truncated,
- TextClr,
- BackgoundClr
- );
- /**/
- //MessageBox(NULL, "Crash", "10f", MB_OK);
- SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext);
- if (db_get_b(AContact, MODULENAME, STOP_KEY, 1) == 1)
- {
-
- ZeroMemory(&statustext, sizeof(statustext));
- _snprintf(statustext, sizeof(statustext), " %s", Translate("Processing data stopped by user."));
- SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext);
- db_set_b(AContact, MODULENAME, STOP_KEY, 0);
- db_set_w(AContact, MODULENAME, "Status", ID_STATUS_ONLINE);
- db_set_s(AContact, "CList", "StatusMsg", statustext);
- AlreadyDownloading = 0;
- return;
- }
- CodetoSymbol(truncated);
- Sleep(100); // avoid 100% CPU
-
- ZeroMemory(&statustext, sizeof(statustext));
- _snprintf(statustext, sizeof(statustext), " %s", Translate("Processing data (Stage 2)"));
- //SetDlgItemText(hwndDlg, IDC_DATA, truncated);
- /**/
- SendToRichEdit(hwndDlg,
- truncated,
- TextClr,
- BackgoundClr
- );
- /**/
- SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext);
- if (db_get_b(AContact, MODULENAME, STOP_KEY, 1) == 1)
- {
-
- ZeroMemory(&statustext, sizeof(statustext));
- _snprintf(statustext, sizeof(statustext), " %s", Translate("Processing data stopped by user."));
- SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext);
- db_set_b(AContact, MODULENAME, STOP_KEY, 0);
- db_set_w(AContact, MODULENAME, "Status", ID_STATUS_ONLINE);
- db_set_s(AContact, "CList", "StatusMsg", statustext);
- AlreadyDownloading = 0;
- return;
- }
-
- EraseBlock(truncated);
- Sleep(100); // avoid 100% CPU
-
- ZeroMemory(&statustext, sizeof(statustext));
- _snprintf(statustext, sizeof(statustext), " %s", Translate("Processing data (Stage 3)"));
- //SetDlgItemText(hwndDlg, IDC_DATA, truncated);
- /**/ SendToRichEdit(hwndDlg,
- truncated,
- TextClr,
- BackgoundClr
- );
- /**/
- SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext);
- if (db_get_b(AContact, MODULENAME, STOP_KEY, 1) == 1)
- {
-
- ZeroMemory(&statustext, sizeof(statustext));
- _snprintf(statustext, sizeof(statustext), " %s", Translate("Processing data stopped by user."));
- SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext);
- db_set_b(AContact, MODULENAME, STOP_KEY, 0);
- db_set_w(AContact, MODULENAME, "Status", ID_STATUS_ONLINE);
- db_set_s(AContact, "CList", "StatusMsg", statustext);
- AlreadyDownloading = 0;
- return;
- }
- FastTagFilter(truncated);
- Sleep(100); // avoid 100% CPU
-
- ZeroMemory(&statustext, sizeof(statustext));
- _snprintf(statustext, sizeof(statustext), " %s", Translate("Processing data (Stage 4)"));
- //SetDlgItemText(hwndDlg, IDC_DATA, truncated);
- /**/ SendToRichEdit(hwndDlg,
- truncated,
- TextClr,
- BackgoundClr
- );/**/
- SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext);
- if (db_get_b(AContact, MODULENAME, STOP_KEY, 1) == 1)
- {
-
- ZeroMemory(&statustext, sizeof(statustext));
- _snprintf(statustext, sizeof(statustext), " %s", Translate("Processing data stopped by user."));
- SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext);
- db_set_b(AContact, MODULENAME, STOP_KEY, 0);
- db_set_w(AContact, MODULENAME, "Status", ID_STATUS_ONLINE);
- db_set_s(AContact, "CList", "StatusMsg", statustext);
- AlreadyDownloading = 0;
- return;
- }
-
- NumSymbols(truncated);
- Sleep(100); // avoid 100% CPU
-
- ZeroMemory(&statustext, sizeof(statustext));
- _snprintf(statustext, sizeof(statustext), " %s", Translate("Processing data (Stage 5)"));
- //SetDlgItemText(hwndDlg, IDC_DATA, truncated);
- /**/SendToRichEdit(hwndDlg,
- truncated,
- TextClr,
- BackgoundClr
- );/**/
- SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext);
- if (db_get_b(AContact, MODULENAME, STOP_KEY, 1) == 1)
- {
-
- ZeroMemory(&statustext, sizeof(statustext));
- _snprintf(statustext, sizeof(statustext), " %s", Translate("Processing data stopped by user."));
- SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext);
- db_set_b(AContact, MODULENAME, STOP_KEY, 0);
- db_set_w(AContact, MODULENAME, "Status", ID_STATUS_ONLINE);
- db_set_s(AContact, "CList", "StatusMsg", statustext);
- AlreadyDownloading = 0;
- return;
- }
- EraseSymbols(truncated);
- Sleep(100); // avoid 100% CPU
-
- ZeroMemory(&statustext, sizeof(statustext));
- _snprintf(statustext, sizeof(statustext), " %s", Translate("Processing data (Stage 6)"));
- //SetDlgItemText(hwndDlg, IDC_DATA, truncated);
- /**/SendToRichEdit(hwndDlg,
- truncated,
- TextClr,
- BackgoundClr
- );/**/
- SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext);
- AmountWspcRem = db_get_b(AContact, MODULENAME, RWSPACE_KEY, 0);
- if (db_get_b(AContact, MODULENAME, STOP_KEY, 1) == 1)
- {
-
- ZeroMemory(&statustext, sizeof(statustext));
- _snprintf(statustext, sizeof(statustext), " %s", Translate("Processing data stopped by user."));
- SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext);
- db_set_b(AContact, MODULENAME, STOP_KEY, 0);
- db_set_w(AContact, MODULENAME, "Status", ID_STATUS_ONLINE);
- db_set_s(AContact, "CList", "StatusMsg", statustext);
- AlreadyDownloading = 0;
- return;
- }
- RemoveInvis(truncated, AmountWspcRem);
- Sleep(100); // avoid 100% CPU
-
- ZeroMemory(&statustext, sizeof(statustext));
- _snprintf(statustext, sizeof(statustext), " %s", Translate("Processing data (Stage 7)"));
- //SetDlgItemText(hwndDlg, IDC_DATA, truncated);
- /**/SendToRichEdit(hwndDlg,
- truncated,
- TextClr,
- BackgoundClr
- );/**/
- if (db_get_b(AContact, MODULENAME, STOP_KEY, 1) == 1)
- {
-
- ZeroMemory(&statustext, sizeof(statustext));
- _snprintf(statustext, sizeof(statustext), " %s", Translate("Processing data stopped by user."));
- SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext);
- db_set_b(AContact, MODULENAME, STOP_KEY, 0);
- db_set_w(AContact, MODULENAME, "Status", ID_STATUS_ONLINE);
- db_set_s(AContact, "CList", "StatusMsg", statustext);
- AlreadyDownloading = 0;
- return;
- }
- SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext);
- Removewhitespace(truncated);
-
-
- ZeroMemory(&statustext, sizeof(statustext));
- _snprintf(statustext, sizeof(statustext), " %s", Translate("Processing data (Stage 8)"));
- //SetDlgItemText(hwndDlg, IDC_DATA, truncated);
- SendToRichEdit(hwndDlg,
- truncated,
- TextClr,
- BackgoundClr
- );
- //
-
- #ifdef UNICODE_VERISON
-
-//semi works
-
- wchar_t tmp3[strlen(truncated)];
- const char *wobbles;
-
- int c = lstrlenA(truncated);
- //mir_utf8encode(truncated);
- //utf8_encode(truncated, tmp3);
- //utf8_encode(truncated, wobbles);
-
- //MessageBox(NULL, utf8encode(truncated),"TEST", MB_OK);
-
-MultiByteToWideChar(CP_UTF8, 0, truncated, -1, tmp3, strlen(truncated));
-SetDlgItemTextW(hwndDlg, IDC_DATA, (wchar_t *)&tmp3);
- #endif
-
- //
- /* SendToRichEdit(hwndDlg,
- truncated,
- TextClr,
- BackgoundClr
- );*/
- SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext);
-
-
- //data in popup
- #ifdef UNICODE_VERISON
- if (TherewasAlert)
- {
- if ((db_get_b(NULL, MODULENAME, DATA_POPUP_KEY, 0)))
- WAlertWPopup((WPARAM)AContact, tmp3);
- }
- #endif
- #ifndef UNICODE_VERISON
- if (TherewasAlert)
- {
- if ((db_get_b(NULL, MODULENAME, DATA_POPUP_KEY, 0)))
- WAlertPopup((WPARAM)AContact, truncated);
- }
- #endif
-
-
- if (db_get_b(AContact, MODULENAME, STOP_KEY, 1) == 1)
- {
-
- ZeroMemory(&statustext, sizeof(statustext));
- _snprintf(statustext, sizeof(statustext), " %s", Translate("Processing data stopped by user."));
- SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext);
- db_set_b(AContact, MODULENAME, STOP_KEY, 0);
- db_set_w(AContact, MODULENAME, "Status", ID_STATUS_ONLINE);
- db_set_s(AContact, "CList", "StatusMsg", statustext);
- AlreadyDownloading = 0;
- return;
- }
- // removed any excess characters at the end.
- if ((truncated[strlen(truncated) - 1] == truncated[strlen(truncated) - 2]) && (truncated[strlen(truncated) - 2] == truncated[strlen(truncated) - 3]))
- {
- int counterx = 0;
-
- while (1)
- {
- counterx++;
- if (truncated[strlen(truncated) - counterx] != truncated[strlen(truncated) - 1])
- {
- truncated[(strlen(truncated) - counterx) + 2] = '\0';
- break;
- }
- }
- }
- //
-
-
- }
- }
- if (TherewasAlert)
- {
- db_set_w(AContact, MODULENAME, "Status", ID_STATUS_OCCUPIED);
- ZeroMemory(&statustext, sizeof(statustext));
- _snprintf(statustext, sizeof(statustext), "%s", Translate("Alert!"));
- db_set_s(AContact, "CList", "StatusMsg", statustext);
- }
- else
- {
- db_set_w(AContact, MODULENAME, "Status", ID_STATUS_ONLINE);
- ZeroMemory(&statustext, sizeof(statustext));
- _snprintf(statustext, sizeof(statustext), "%s", Translate("Online"));
- db_set_s(AContact, "CList", "StatusMsg", statustext);
- }
- }
- // /////
- if (db_get_b(AContact, MODULENAME, 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)
- {
- ZeroMemory(&statustext, sizeof(statustext));
- _snprintf(statustext, sizeof(statustext), " %s", Translate("A site is already downloading, try again in a moment."));
- SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext);
- }
- if (DownloadSuccess) // download success
-
- {
-
- char BytesString[128];
- //char *BytesString;
- HWND hwndDlg = (WindowList_Find(hWindowList, AContact));
-
- // update window if the update only on alert option isn't ticked or
- // there was an alert or the update button was clicked
- if ((!(db_get_b(NULL, MODULENAME, UPDATE_ONALERT_KEY, 0))) || (TherewasAlert == 1) || (PosButnClick == 1))
- {
-/*
-#ifdef UNICODE_VERISON
- wchar_t tmp[500];
-
- int a = lstrlenA(raw);
-
-MultiByteToWideChar(CP_ACP, 0, truncated, (lstrlenA(truncated)), tmp, (lstrlenA(truncated)));
-
-//MessageBoxW(NULL, tmp, "Yeah I know", MB_OK);
-
- char tempchar1[200];
-
- _snprintf(tempchar1, sizeof(tempchar1), "raw strlen is %d, truncated strlen is %d", (lstrlenA(raw)),(lstrlenA(truncated)));
- //MessageBox(NULL, tempchar1, MODULENAME, MB_OK);
-
- // utf8_encode(truncated, &tmp);
-
- // MessageBox(NULL, tmp, MODULENAME, MB_OK);
-
- SetDlgItemTextW(hwndDlg, IDC_DATA, tmp);
-
-
- free(tmp);
-#endif
-*/
- /**/
-#ifndef UNICODE_VERISON
-
- SendToRichEdit(hwndDlg,
- truncated,
- TextClr,
- BackgoundClr
- );
-#endif
-
- if (TherewasAlert)
- {
- // highlight text when part of change changes
- if (eventIndex == 2)
- {
- CHARRANGE sel2 = {location, location2};
-
- //
- SendMessage(GetDlgItem(hwndDlg, IDC_DATA), EM_EXSETSEL, 0, (LPARAM) & sel2);
- SetFocus(GetDlgItem(hwndDlg, IDC_DATA));
-
- DWORD HiBackgoundClr;
- DWORD HiTextClr;
-
- HiBackgoundClr = db_get_dw(NULL, MODULENAME, BG_COLOR_KEY, 0);
- HiTextClr = db_get_dw(NULL, MODULENAME, TXT_COLOR_KEY, 0);
-
- 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);
- SendMessage(GetDlgItem(hwndDlg, IDC_DATA), EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM) & Format);
-
- }
- }
- SetDlgItemText(hwndDlg, IDC_STATUSBAR, timestring);
- sprintf(BytesString, "%s: %d | %s: %lu", (Translate("Bytes in display")), (GetWindowTextLength(GetDlgItem(hwndDlg, IDC_DATA))), (Translate("Bytes downloaded")), downloadsize);
-
-/*
- #ifdef UNICODE_VERISON
-
- wchar_t unicodestr[256];
-
- char *ansistr = "Hello"; //works 1
-
-
-//int a = lstrlenA(ansistr);//works 1
-
-//MultiByteToWideChar(CP_ACP, 0, ansistr, a, unicodestr, a); //works 1
-// MessageBoxW(NULL, unicodestr, MODULENAME, MB_OK); //works 1
-
-
-
-int b = lstrlenA(BytesString);
-
-MultiByteToWideChar(CP_ACP, 0, BytesString, b, unicodestr, b);
-
- SendMessageW(GetDlgItem(hwndDlg, IDC_STATUSBAR), SB_SETTEXT, 1, (LPARAM)unicodestr);
- // free(unicodestr);
- #endif
-*/
- //#ifndef UNICODE_VERISON
- SendMessage(GetDlgItem(hwndDlg, IDC_STATUSBAR), SB_SETTEXT, 1, (LPARAM) BytesString);
- //#endif
-
- } else
- {
- ZeroMemory(&statustext, sizeof(statustext));
- _snprintf(statustext, sizeof(statustext), " %s", Translate("Alert test conditions not met; press the refresh button to view content."));
- SetDlgItemText(hwndDlg, IDC_STATUSBAR, statustext);
- }
-
- }
- EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE_BUTTON), 1);
-
- if (!Startingup)
- db_set_b(NULL, MODULENAME, HAS_CRASHED_KEY, 0);
-
+ int statpos = 0, dispos = 0, statposend = 0;
+ char*pos;
+ DBVARIANT dbv;
+ NETLIBHTTPREQUEST nlhr = {0}
+ , *nlhrReply;
+ NETLIBHTTPHEADER headers[2];
+ char tempstring[300], tempstring2[300];
+ int MallocSize = 0;
+ int DownloadSuccess = 0;
+ char*raw;
+ char*szInfo;
+ char truncated[MAXSIZE1];
+ char truncated2[MAXSIZE2];
+ int trunccount = 0;
+ char url[300];
+ unsigned long downloadsize = 0;
+ int AmountWspcRem = 0;
+ static char contactname[100];
+ char statustext[200];
+ 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;
+
+ ZeroMemory(&url, sizeof(url));
+ ZeroMemory(&contactname, sizeof(contactname));
+ ZeroMemory(&tempstring, sizeof(tempstring));
+ ZeroMemory(&tempstring2, sizeof(tempstring2));
+ ZeroMemory(&szInfo, sizeof(szInfo));
+ ZeroMemory(&dbv, sizeof(dbv));
+ ZeroMemory(&tstr, sizeof(tstr));
+ ZeroMemory(&timestring, sizeof(timestring));
+
+ db_set_b(hContact, MODULENAME, STOP_KEY, 0);
+
+ if (db_get_s(hContact, MODULENAME, PRESERVE_NAME_KEY, &dbv)) {
+ db_free(&dbv);
+ db_get_s(hContact, "CList", "MyHandle", &dbv);
+ db_set_s(hContact, MODULENAME, PRESERVE_NAME_KEY, dbv.pszVal);
+ db_free(&dbv);
+ }
+ db_get_s(hContact, MODULENAME, PRESERVE_NAME_KEY, &dbv);
+ _snprintf(contactname, sizeof(contactname), "%s", dbv.pszVal);
+ db_free(&dbv);
+
+ url[0] = '\0';
+
+ if (!Startingup)
+ db_set_b(NULL, MODULENAME, HAS_CRASHED_KEY, 1);
+
+ db_get_s(hContact, MODULENAME, START_STRING_KEY, &dbv);
+ _snprintf(tempstring, sizeof(tempstring), "%s", dbv.pszVal);
+ db_free(&dbv);
+
+ db_get_s(hContact, MODULENAME, END_STRING_KEY, &dbv);
+ _snprintf(tempstring2, sizeof(tempstring2), "%s", dbv.pszVal);
+ db_free(&dbv);
+
+ db_get_s(hContact, MODULENAME, URL_KEY, &dbv);
+ _snprintf(url, sizeof(url), "%s", dbv.pszVal);
+ db_free(&dbv);
+
+ if (strlen(url) < 3)
+ WErrorPopup(hContact, TranslateT("URL not supplied"));
+
+ nlhr.cbSize = sizeof(nlhr);
+ nlhr.requestType = REQUEST_GET;
+ nlhr.flags = NLHRF_DUMPASTEXT;
+ nlhr.szUrl = url;
+ nlhr.headersCount = 2;
+
+ headers[0].szName = "User-Agent";
+ headers[0].szValue = "Mozilla/4.0 (compatible; MSIE 6.0; Win32)";
+
+ headers[1].szName = "Content-Length";
+ headers[1].szValue = NULL;
+
+ nlhr.headers = headers;
+
+ if ( db_get_b(NULL, MODULENAME, 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..."));
+
+ ZeroMemory(&statustext, sizeof(statustext));
+ _snprintf(statustext, sizeof(statustext), "%s", Translate("Updating..."));
+ db_set_s(hContact, "CList", "StatusMsg", statustext);
+
+ db_set_w(hContact, MODULENAME, "Status", ID_STATUS_DND); // download
+
+ nlhrReply = (NETLIBHTTPREQUEST *) CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM) hNetlibUser, (LPARAM) & nlhr);
+ if (nlhrReply) {
+ if (nlhrReply->resultCode < 200 || nlhrReply->resultCode >= 300) {
+ db_set_w(hContact, MODULENAME, "Status", ID_STATUS_AWAY);
+
+ TCHAR *statusText = TranslateT("The server replied with a failure code");
+ HWND hwndDlg = WindowList_Find(hWindowList, hContact);
+ SetDlgItemText(hwndDlg, IDC_STATUSBAR, statusText);
+ WErrorPopup(hContact, statusText);
+ db_set_ts(hContact, "CList", "StatusMsg", statusText);
+ }
+ if (nlhrReply->dataLength) {
+ szInfo = (char*)malloc(lstrlenA(nlhrReply->pData) + 2);
+ lstrcpynA(szInfo, nlhrReply->pData, lstrlenA(nlhrReply->pData));
+ downloadsize = lstrlenA(nlhrReply->pData);
+
+ trunccount = 0;
+ lstrcpynA(truncated2, szInfo, MAXSIZE2);
+ free(szInfo);
+
+ ////////////////////////////////////////////
+ sprintf(truncated2, "%s", nlhrReply->pData);
+ AlreadyDownloading = 1;
+ } // END DATELENGTH
+ } // END REPLY
+
+ if (!nlhrReply) {
+ db_set_w(hContact, MODULENAME, "Status", ID_STATUS_NA);
+ HWND hwndDlg = (WindowList_Find(hWindowList, hContact));
+
+ SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("The server is down or lagging."));
+ WErrorPopup(hContact, TranslateT("The server is down or lagging."));
+
+ ZeroMemory(&statustext, sizeof(statustext));
+ _snprintf(statustext, sizeof(statustext), "%s", Translate("The server is down."));
+ db_set_s(hContact, "CList", "StatusMsg", statustext);
+ }
+
+ if (!(nlhrReply))
+ DownloadSuccess = 0;
+
+ if ((nlhrReply) && (nlhrReply->resultCode < 200 || nlhrReply->resultCode >= 300))
+ DownloadSuccess = 0;
+ else if (nlhrReply)
+ DownloadSuccess = 1;
+
+ CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM) nlhrReply);
+
+ if (DownloadSuccess) {
+ HWND hwndDlg = (WindowList_Find(hWindowList, hContact));
+ SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Download successful; about to process data..."));
+ }
+ ///get data in desired range
+
+ // download successful
+ if (DownloadSuccess) {
+ // all the site
+ if (db_get_b(hContact, MODULENAME, U_ALLSITE_KEY, 0) == 1)
+ lstrcpynA(truncated, truncated2, MAXSIZE1);
+ else { // use start and end string
+ // putting data into string
+ if (((strstr(truncated2, tempstring)) != 0) && ((strstr(truncated2, tempstring2)) != 0)) {
+ // start string
+ pos = strstr(truncated2, tempstring);
+ statpos = pos - truncated2;
+
+ ZeroMemory(&pos, sizeof(pos));
+ // end string
+ pos = strstr(truncated2, tempstring2);
+ statposend = pos - truncated2 + (int)strlen(tempstring2);
+
+ if (statpos > statposend) {
+ memset(&truncated2, ' ', statpos);
+ ZeroMemory(&pos, sizeof(pos));
+ pos = strstr(truncated2, tempstring2);
+ statposend = pos - truncated2 + (int)strlen(tempstring2);
+ }
+ if (statpos < statposend) {
+ ZeroMemory(&raw, 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)strlen(tempstring2);
+
+ if (statpos > statposend) {
+ memset(&truncated2, ' ', statpos);
+ ZeroMemory(&pos, sizeof(pos));
+ pos = strstr(truncated2, tempstring2);
+ statposend = pos - truncated2 + (int)strlen(tempstring2);
+ }
+ dispos = 0;
+
+ strncpy(raw, &truncated2[statpos], MallocSize);
+ raw[MallocSize] = '\0';
+
+ trunccount = 0;
+
+ lstrcpynA(truncated, raw, MAXSIZE1);
+
+ free(raw);
+
+ DownloadSuccess = 1;
+ }
+ else if (db_get_b(hContact, MODULENAME, U_ALLSITE_KEY, 0) == 0) {
+ TCHAR *szStatusText = TranslateT("Invalid search parameters.");
+ WErrorPopup(hContact, szStatusText);
+ HWND hwndDlg = WindowList_Find(hWindowList, hContact);
+
+ DownloadSuccess = 0;
+ SetDlgItemText(hwndDlg, IDC_STATUSBAR, szStatusText);
+ db_set_w(hContact, MODULENAME, "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 (db_get_b(hContact, MODULENAME, U_ALLSITE_KEY, 0) == 0) {
+ TCHAR *statusText = TranslateT("Both search strings not found or strings not set.");
+ WErrorPopup(hContact, statusText);
+ db_set_ts(hContact, "CList", "StatusMsg", statusText);
+
+ HWND hwndDlg = WindowList_Find(hWindowList, hContact);
+ DownloadSuccess = 0;
+ SetDlgItemText(hwndDlg, IDC_STATUSBAR, statusText);
+ TherewasAlert = ProcessAlerts(hContact, _T2A(statusText), contactname, contactname, 1);
+ db_set_w(hContact, MODULENAME, "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;
+
+ setlocale(LC_ALL, "");
+
+ if (!db_get_s(hContact, MODULENAME, PRESERVE_NAME_KEY, &dbv)) {
+ ZeroMemory(&temptime, sizeof(temptime));
+ ZeroMemory(&tstr, sizeof(tstr));
+ ftime = time(NULL);
+ nTime = localtime(&ftime);
+ // 12 hour
+ if (db_get_b(hContact, MODULENAME, USE_24_HOUR_KEY, 0) == 0)
+ strftime(temptime, 128, "(%b %d,%I:%M %p)", nTime);
+ // 24 hour
+ if (db_get_b(hContact, MODULENAME, USE_24_HOUR_KEY, 0) == 1)
+ strftime(temptime, 128, "(%b %d,%H:%M:%S)", nTime);
+
+ if (db_get_b(hContact, MODULENAME, CONTACT_PREFIX_KEY, 1) == 1)
+ _snprintf(tstr, sizeof(tstr), "%s %s", temptime, dbv.pszVal);
+ if (db_get_b(hContact, MODULENAME, CONTACT_PREFIX_KEY, 1) == 0)
+ _snprintf(tstr, sizeof(tstr), "%s %s", dbv.pszVal, temptime);
+ db_free(&dbv);
+ }
+ else if (db_get_s(hContact, MODULENAME, PRESERVE_NAME_KEY, &dbv)) {
+ db_free(&dbv);
+ db_get_s(hContact, "CList", "MyHandle", &dbv);
+ ZeroMemory(&temptime, sizeof(temptime));
+ ZeroMemory(&tstr, sizeof(tstr));
+ ftime = time(NULL);
+ nTime = localtime(&ftime);
+ // 12 hour
+ if (db_get_b(hContact, MODULENAME, USE_24_HOUR_KEY, 0) == 0)
+ strftime(temptime, 128, "(%b %d,%I:%M %p)", nTime);
+ // 24 hour
+ if (db_get_b(hContact, MODULENAME, USE_24_HOUR_KEY, 0) == 1)
+ strftime(temptime, 128, "(%b %d,%H:%M:%S)", nTime);
+
+ db_set_s(hContact, MODULENAME, PRESERVE_NAME_KEY, dbv.pszVal);
+ if (db_get_b(hContact, MODULENAME, CONTACT_PREFIX_KEY, 1) == 1)
+ _snprintf(tstr, sizeof(tstr), "%s %s", temptime, dbv.pszVal);
+ if (db_get_b(hContact, MODULENAME, CONTACT_PREFIX_KEY, 1) == 0)
+ _snprintf(tstr, sizeof(tstr), "%s %s", dbv.pszVal, temptime);
+ db_free(&dbv);
+ }
+
+ ZeroMemory(&timeprefix, sizeof(timeprefix));
+ ZeroMemory(&temptime1, sizeof(temptime1));
+ ZeroMemory(&timeat, sizeof(timeat));
+ ZeroMemory(&temptime2, sizeof(temptime2));
+ ZeroMemory(&timestring, sizeof(timestring));
+
+ ftime = time(NULL);
+ nTime = localtime(&ftime);
+
+ _snprintf(timeprefix, sizeof(timeprefix), " %s ", (Translate("Last updated on")));
+ strftime(temptime1, 32, " %a, %b %d, %Y ", nTime);
+ _snprintf(timeat, sizeof(timeat), "%s", (Translate("at the time")));
+ strftime(temptime2, 32, " %I:%M %p.", nTime);
+ _snprintf(timestring, sizeof(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 = db_get_b(hContact, MODULENAME, EVNT_INDEX_KEY, 0);
+ if (eventIndex == 2) {
+ strncpy(buff, truncated, sizeof(buff));
+ Filter(buff);
+
+ db_get_s(hContact, MODULENAME, ALRT_S_STRING_KEY, &dbv);
+ _snprintf(Alerttempstring, sizeof(Alerttempstring), "%s", dbv.pszVal);
+ db_free(&dbv);
+
+ db_get_s(hContact, MODULENAME, ALRT_E_STRING_KEY, &dbv);
+ _snprintf(Alerttempstring2, sizeof(Alerttempstring2), "%s", dbv.pszVal);
+ db_free(&dbv);
+
+ // putting data into string
+ if (((strstr(buff, Alerttempstring)) != 0) && ((strstr(buff, Alerttempstring2)) != 0)) {
+ location = (strstr(buff, Alerttempstring)) - buff;
+ location2 = (strstr(buff, Alerttempstring2)) - buff;
+ }
+ }
+ }
+
+ if ((((strstr(truncated2, tempstring)) != 0) && ((strstr(truncated2, tempstring2)) != 0) && (db_get_b(hContact, MODULENAME, U_ALLSITE_KEY, 0) == 0)) || (db_get_b(hContact, MODULENAME, U_ALLSITE_KEY, 0) == 1)) {
+ RemoveTabs(truncated);
+
+ if ( db_get_b(hContact, MODULENAME, CLEAR_DISPLAY_KEY, 0)) {
+ HWND hwndDlg = (WindowList_Find(hWindowList, hContact));
+
+ SendToRichEdit(hwndDlg, truncated, TextClr, BackgoundClr);
+ SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Processing data (Stage 1)"));
+
+ if (db_get_b(hContact, MODULENAME, STOP_KEY, 1) == 1) {
+LBL_Stop: TCHAR *statusText = TranslateT("Processing data stopped by user.");
+ SetDlgItemText(hwndDlg, IDC_STATUSBAR, statusText);
+ db_set_b(hContact, MODULENAME, STOP_KEY, 0);
+ db_set_w(hContact, MODULENAME, "Status", ID_STATUS_ONLINE);
+ db_set_ts(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 (db_get_b(hContact, MODULENAME, 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 (db_get_b(hContact, MODULENAME, 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 (db_get_b(hContact, MODULENAME, 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 (db_get_b(hContact, MODULENAME, 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 = db_get_b(hContact, MODULENAME, RWSPACE_KEY, 0);
+ if (db_get_b(hContact, MODULENAME, 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 (db_get_b(hContact, MODULENAME, 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 ( db_get_b(NULL, MODULENAME, DATA_POPUP_KEY, 0))
+ WAlertPopup(hContact, _A2T(truncated));
+
+ if (db_get_b(hContact, MODULENAME, STOP_KEY, 1) == 1)
+ goto LBL_Stop;
+
+ // removed any excess characters at the end.
+ if ((truncated[strlen(truncated) - 1] == truncated[strlen(truncated) - 2]) && (truncated[strlen(truncated) - 2] == truncated[strlen(truncated) - 3])) {
+ int counterx = 0;
+
+ while (1) {
+ counterx++;
+ if (truncated[strlen(truncated) - counterx] != truncated[strlen(truncated) - 1]) {
+ truncated[(strlen(truncated) - counterx) + 2] = '\0';
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ if (TherewasAlert) {
+ db_set_w(hContact, MODULENAME, "Status", ID_STATUS_OCCUPIED);
+ db_set_ts(hContact, "CList", "StatusMsg", TranslateT("Alert!"));
+ }
+ else {
+ db_set_w(hContact, MODULENAME, "Status", ID_STATUS_ONLINE);
+ db_set_ts(hContact, "CList", "StatusMsg", TranslateT("Online"));
+ }
+ }
+
+ if (db_get_b(hContact, MODULENAME, 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];
+ HWND hwndDlg = (WindowList_Find(hWindowList, hContact));
+
+ // update window if the update only on alert option isn't ticked or
+ // there was an alert or the update button was clicked
+ if ((!(db_get_b(NULL, MODULENAME, 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};
+
+ SendMessage(GetDlgItem(hwndDlg, IDC_DATA), EM_EXSETSEL, 0, (LPARAM) & sel2);
+ SetFocus(GetDlgItem(hwndDlg, IDC_DATA));
+
+ DWORD HiBackgoundClr = db_get_dw(NULL, MODULENAME, BG_COLOR_KEY, Def_color_bg);
+ DWORD HiTextClr = db_get_dw(NULL, MODULENAME, 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);
+ SendMessage(GetDlgItem(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);
+
+ SendMessage(GetDlgItem(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)
+ db_set_b(NULL, MODULENAME, HAS_CRASHED_KEY, 0);
}
-
-/*****************/
-
-
-
diff --git a/plugins/WebView/src/webview_opts.cpp b/plugins/WebView/src/webview_opts.cpp
index 99239a34ed..c739027a4a 100644
--- a/plugins/WebView/src/webview_opts.cpp
+++ b/plugins/WebView/src/webview_opts.cpp
@@ -1,1742 +1,1317 @@
/*
- * 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.
- */
+* 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 TCHAR *szTrackerBarDescr[] = {
+ _T("No whitespace removal"),
+ _T("Minimal level of whitespace removal"),
+ _T("Medium level of whitespace removal"),
+ _T("Large level of whitespace removal"),
+ _T("Remove all whitespace")
+};
-const char *szTrackerBarDescr[] = {"No whitespace removal", "Minimal level of whitespace removal", "Medium level of whitespace removal", "Large level of whitespace removal", "Remove all whitespace",};
-static char *fontSizes[] = {"8", "10", "14", "16", "18", "20", "24", "28"};
-static char *AlertTypes[] = {"Popup Plugin", "Log To File", "Open Data Display Window", "Use OSD Plugin"};
-static char *EventTypes[] = {"A String Is Present", "The Web Page Changes", "A Specific Part of Web Page Changes"};
+static char *fontSizes[] = {"8", "10", "14", "16", "18", "20", "24", "28"};
+static TCHAR *AlertTypes[] = { _T("Popup Plugin"), _T("Log To File"), _T("Open Data Display Window"), _T("Use OSD Plugin") };
+static TCHAR *EventTypes[] = { _T("A String Is Present"), _T("The Web Page Changes"), _T("A Specific Part of Web Page Changes") };
#define M_FILLSCRIPTCOMBO (WM_USER+16)
-/*********************/
-static int CALLBACK EnumFontScriptsProc(ENUMLOGFONTEX * lpelfe, NEWTEXTMETRICEX * lpntme, int FontType, LPARAM lParam)
+void strdel(TCHAR *parBuffer, int len )
{
- if (SendMessage((HWND) lParam, CB_FINDSTRINGEXACT, -1, (LPARAM) lpelfe->elfScript) == CB_ERR)
- {
- int i = SendMessage((HWND) lParam, CB_ADDSTRING, 0, (LPARAM) lpelfe->elfScript);
+ TCHAR* p;
+ for (p = parBuffer+len; *p != 0; p++)
+ p[ -len ] = *p;
- SendMessage((HWND) lParam, CB_SETITEMDATA, i, lpelfe->elfLogFont.lfCharSet);
- }
- return TRUE;
+ p[ -len ] = '\0';
}
-/********************/
-/*********************/
-// copied and modified from NewStatusNotify
-BOOL CALLBACK DlgPopUpOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
+/*****************************************************************************/
+static int CALLBACK EnumFontScriptsProc(ENUMLOGFONTEX * lpelfe, NEWTEXTMETRICEX * lpntme, int FontType, 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);
- char str[512];
- DWORD BGColour = 0;
- DWORD TextColour = 0;
- DWORD delay = 0;
- static int test = 0;
-
- switch (msg)
- {
- case WM_INITDIALOG:
- {
- TranslateDialogDefault(hdlg);
-
-//
-//CheckDlgButton(hdlg, IDC_PUALERT, db_get_b(NULL, MODULENAME, INBUILTPOP_KEY, 0));
-//
- delay = db_get_dw(NULL, MODULENAME, POP_DELAY_KEY, 0);
+ SendMessage((HWND) lParam, CB_SETITEMDATA, i, lpelfe->elfLogFont.lfCharSet);
+ }
+ return TRUE;
+}
- // setting popup delay option
- itoa(delay, str, 10);
+/*****************************************************************************/
+// copied and modified from NewStatusNotify
+INT_PTR CALLBACK DlgPopUpOpts(HWND hdlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
- SetDlgItemText(hdlg, IDC_DELAY, str);
-//
-/*
- if (delay == -1)
- CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD2);
- else if (delay == 0)
- CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD1);
- else if (delay != 0 && delay != -1)
- CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD3);
-*/
-/*
- if (delay == -1)
- CheckDlgButton(hdlg, IDC_PD2, BST_CHECKED);
- else if (delay == 0)
- CheckDlgButton(hdlg, IDC_PD1, BST_CHECKED);
- else if (delay != 0 && delay != -1)
- CheckDlgButton(hdlg, IDC_PD3, BST_CHECKED);
-*/
-
-//
-
- BGColour = db_get_dw(NULL, MODULENAME, POP_BG_CLR_KEY, 0);
- TextColour = db_get_dw(NULL, MODULENAME, POP_TXT_CLR_KEY, 0);
-
- // 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, db_get_b(NULL, MODULENAME, POP_USEWINCLRS_KEY, 0));
- CheckDlgButton(hdlg, IDC_POP_USESAMECOLORS, db_get_b(NULL, MODULENAME, POP_USESAMECLRS_KEY, 0));
- CheckDlgButton(hdlg, IDC_POP_USECUSTCOLORS, db_get_b(NULL, MODULENAME, POP_USECUSTCLRS_KEY, 0));
- //
- 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, db_get_b(NULL, MODULENAME, LCLK_WINDOW_KEY, 0));
- CheckDlgButton(hdlg, IDC_LCLK_WEB_PGE, db_get_b(NULL, MODULENAME, LCLK_WEB_PGE_KEY, 0));
- CheckDlgButton(hdlg, IDC_LCLK_DISMISS, db_get_b(NULL, MODULENAME, LCLK_DISMISS_KEY, 0));
-
- CheckDlgButton(hdlg, IDC_RCLK_WINDOW, db_get_b(NULL, MODULENAME, RCLK_WINDOW_KEY, 0));
- CheckDlgButton(hdlg, IDC_RCLK_WEB_PGE, db_get_b(NULL, MODULENAME, RCLK_WEB_PGE_KEY, 0));
- CheckDlgButton(hdlg, IDC_RCLK_DISMISS, db_get_b(NULL, MODULENAME, RCLK_DISMISS_KEY, 0));
-
- return TRUE;
- }
- break;
- 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:
- // Popup delay setting from PopUp plugin
- SetDlgItemText(hdlg, IDC_DELAY, "0");
- // CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD1);
- break;
- case IDC_PD2:
- // Popup delay = permanent
- SetDlgItemText(hdlg, IDC_DELAY, "-1");
- // CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD2);
- break;
-// case IDC_PD3:
-// CheckRadioButton(hdlg, IDC_PD1, IDC_PD3, IDC_PD3);
-// 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:
- {
- char str3[512];
- POPUPDATAEX ppd;
-
- ZeroMemory(&ppd, sizeof(POPUPDATA));
- GetDlgItemText(hdlg, IDC_DELAY, str3, sizeof(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;
- strcpy(ppd.lpzContactName, MODULENAME);
- ppd.lchIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_SITE));
- sprintf(ppd.lpzText, Translate("This is a preview popup."));
- ppd.colorBack = BGColour;
- ppd.colorText = TextColour;
- ppd.PluginWindowProc = NULL;
- ppd.iSeconds = (atol(str3));
- // display popups
- if (!ServiceExists(MS_POPUP_ADDPOPUPEX)) // old version
- CallService(MS_POPUP_ADDPOPUP, (WPARAM) & ppd, 0);
- else
- { // new version with delay
- ppd.iSeconds = (atol(str3));
- CallService(MS_POPUP_ADDPOPUPEX, (WPARAM) & ppd, 0);
- }
- }
- break;
-
- }
- break;
- // End WM_COMMAND
- case WM_NOTIFY: // Here we have pressed either the OK or the APPLY
- // button.
-
- switch (((LPNMHDR) lParam)->code)
- {
- case PSN_APPLY:
- {
- int popupdelayval = 0;
- char str2[512];
-
- GetDlgItemText(hdlg, IDC_DELAY, str2, sizeof(str2));
-
- popupdelayval = atol(str2);
- db_set_dw(NULL, MODULENAME, POP_DELAY_KEY, popupdelayval);
-
-//
-// db_set_b(NULL, MODULENAME, INBUILTPOP_KEY, (BYTE) IsDlgButtonChecked(hdlg, IDC_PUALERT));
-
- db_set_b(NULL, MODULENAME, LCLK_WINDOW_KEY, (BYTE) IsDlgButtonChecked(hdlg, IDC_LCLK_WINDOW));
- db_set_b(NULL, MODULENAME, LCLK_WEB_PGE_KEY, (BYTE) IsDlgButtonChecked(hdlg, IDC_LCLK_WEB_PGE));
- db_set_b(NULL, MODULENAME, LCLK_DISMISS_KEY, (BYTE) IsDlgButtonChecked(hdlg, IDC_LCLK_DISMISS));
-
- db_set_b(NULL, MODULENAME, RCLK_WINDOW_KEY, (BYTE) IsDlgButtonChecked(hdlg, IDC_RCLK_WINDOW));
- db_set_b(NULL, MODULENAME, RCLK_WEB_PGE_KEY, (BYTE) IsDlgButtonChecked(hdlg, IDC_RCLK_WEB_PGE));
- db_set_b(NULL, MODULENAME, RCLK_DISMISS_KEY, (BYTE) IsDlgButtonChecked(hdlg, IDC_RCLK_DISMISS));
-
-//
- db_set_b(NULL, MODULENAME, POP_USECUSTCLRS_KEY, (BYTE) IsDlgButtonChecked(hdlg, IDC_POP_USECUSTCOLORS));
- db_set_b(NULL, MODULENAME, POP_USEWINCLRS_KEY, (BYTE) IsDlgButtonChecked(hdlg, IDC_POP_USEWINCOLORS));
- db_set_b(NULL, MODULENAME, 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));
-
- db_set_dw(NULL, MODULENAME, POP_BG_CLR_KEY, BGColour);
- db_set_dw(NULL, MODULENAME, POP_TXT_CLR_KEY, TextColour);
-
- test = 0;
-
- return TRUE;
- }
- }
- break;
- }
- return FALSE;
+ char str[512];
+ DWORD BGColour = 0;
+ DWORD TextColour = 0;
+ DWORD delay = 0;
+ static int test = 0;
+
+ switch (msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hdlg);
+ {
+ delay = db_get_dw(NULL, MODULENAME, POP_DELAY_KEY, 0);
+
+ // setting popup delay option
+ _itoa(delay, str, 10);
+ SetDlgItemTextA(hdlg, IDC_DELAY, str);
+
+ BGColour = db_get_dw(NULL, MODULENAME, POP_BG_CLR_KEY, Def_color_bg);
+ TextColour = db_get_dw(NULL, MODULENAME, 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, db_get_b(NULL, MODULENAME, POP_USEWINCLRS_KEY, 0));
+ CheckDlgButton(hdlg, IDC_POP_USESAMECOLORS, db_get_b(NULL, MODULENAME, POP_USESAMECLRS_KEY, 1));
+ CheckDlgButton(hdlg, IDC_POP_USECUSTCOLORS, db_get_b(NULL, MODULENAME, POP_USECUSTCLRS_KEY, 0));
+
+ 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, db_get_b(NULL, MODULENAME, LCLK_WINDOW_KEY, 0));
+ CheckDlgButton(hdlg, IDC_LCLK_WEB_PGE, db_get_b(NULL, MODULENAME, LCLK_WEB_PGE_KEY, 0));
+ CheckDlgButton(hdlg, IDC_LCLK_DISMISS, db_get_b(NULL, MODULENAME, LCLK_DISMISS_KEY, 1));
+
+ CheckDlgButton(hdlg, IDC_RCLK_WINDOW, db_get_b(NULL, MODULENAME, RCLK_WINDOW_KEY, 0));
+ CheckDlgButton(hdlg, IDC_RCLK_WEB_PGE, db_get_b(NULL, MODULENAME, RCLK_WEB_PGE_KEY, 1));
+ CheckDlgButton(hdlg, IDC_RCLK_DISMISS, db_get_b(NULL, MODULENAME, RCLK_DISMISS_KEY, 0));
+ }
+ 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:
+ SetDlgItemTextA(hdlg, IDC_DELAY, "0");
+ break;
+ case IDC_PD2:
+ // Popup delay = permanent
+ SetDlgItemTextA(hdlg, IDC_DELAY, "-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:
+ {
+ TCHAR str3[512];
+ POPUPDATAT ppd = { 0 };
+
+ GetDlgItemText(hdlg, IDC_DELAY, str3, SIZEOF(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;
+ _tcscpy(ppd.lptzContactName, _A2T(MODULENAME));
+ ppd.lchIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_SITE));
+ _tcscpy(ppd.lptzText, TranslateT("This is a preview popup."));
+ ppd.colorBack = BGColour;
+ ppd.colorText = TextColour;
+ ppd.PluginWindowProc = NULL;
+ ppd.iSeconds = _ttol(str3);
+ // display popups
+ CallService(MS_POPUP_ADDPOPUPT, (WPARAM)&ppd, 0);
+ }
+ }
+ 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;
+ TCHAR str2[512];
+ GetDlgItemText(hdlg, IDC_DELAY, str2, SIZEOF(str2));
+
+ popupdelayval = _ttol(str2);
+ db_set_dw(NULL, MODULENAME, POP_DELAY_KEY, popupdelayval);
+
+ db_set_b(NULL, MODULENAME, LCLK_WINDOW_KEY, (BYTE)IsDlgButtonChecked(hdlg, IDC_LCLK_WINDOW));
+ db_set_b(NULL, MODULENAME, LCLK_WEB_PGE_KEY, (BYTE)IsDlgButtonChecked(hdlg, IDC_LCLK_WEB_PGE));
+ db_set_b(NULL, MODULENAME, LCLK_DISMISS_KEY, (BYTE)IsDlgButtonChecked(hdlg, IDC_LCLK_DISMISS));
+
+ db_set_b(NULL, MODULENAME, RCLK_WINDOW_KEY, (BYTE)IsDlgButtonChecked(hdlg, IDC_RCLK_WINDOW));
+ db_set_b(NULL, MODULENAME, RCLK_WEB_PGE_KEY, (BYTE)IsDlgButtonChecked(hdlg, IDC_RCLK_WEB_PGE));
+ db_set_b(NULL, MODULENAME, RCLK_DISMISS_KEY, (BYTE)IsDlgButtonChecked(hdlg, IDC_RCLK_DISMISS));
+
+ db_set_b(NULL, MODULENAME, POP_USECUSTCLRS_KEY, (BYTE)IsDlgButtonChecked(hdlg, IDC_POP_USECUSTCOLORS));
+ db_set_b(NULL, MODULENAME, POP_USEWINCLRS_KEY, (BYTE)IsDlgButtonChecked(hdlg, IDC_POP_USEWINCOLORS));
+ db_set_b(NULL, MODULENAME, 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));
+
+ db_set_dw(NULL, MODULENAME, POP_BG_CLR_KEY, BGColour);
+ db_set_dw(NULL, MODULENAME, POP_TXT_CLR_KEY, TextColour);
+
+ test = 0;
+ return TRUE;
+ }
+ }
+ break;
+ }
+ return FALSE;
}
-/********************/
-/**************/
-static BOOL CALLBACK DlgProcAlertOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+/*****************************************************************************/
+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;
-
- ParentHwnd = GetParent(hwndDlg);
-
- switch (msg)
- {
- case WM_INITDIALOG:
- {
- char transCBstr[50];
-
- test = 0;
- TranslateDialogDefault(hwndDlg);
- HANDLE hContact = (HANDLE) lParam;
-
-
- SetWindowLong(hwndDlg, GWL_USERDATA, (LONG) hContact);
-
-
- /*
- if ((WindowList_Find(hWindowList,hContact))==NULL)
- WindowList_Add(hWindowList, hwndDlg, hContact);
- else
- {
- WindowList_Remove(hWindowList, hwndDlg);
- DestroyWindow(hwndDlg);
- }
- */
-
-
- SetWindowText(hwndDlg, Translate("Alert Options"));
-
- SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM) LoadIcon(hInst, MAKEINTRESOURCE(IDI_ALERT)));
-
-
- EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_APPLY), 0);
-
- if (!DBGetContactSetting(hContact, MODULENAME, ALERT_STRING_KEY, &dbv))
- {
- SetDlgItemText(hwndDlg, IDC_ALERT_STRING, dbv.pszVal);
- DBFreeVariant(&dbv);
- }
- if (!DBGetContactSetting(hContact, MODULENAME, ALRT_S_STRING_KEY, &dbv))
- {
- SetDlgItemText(hwndDlg, IDC_START2, dbv.pszVal);
- DBFreeVariant(&dbv);
- }
- if (!DBGetContactSetting(hContact, MODULENAME, ALRT_E_STRING_KEY, &dbv))
- {
- SetDlgItemText(hwndDlg, IDC_END2, dbv.pszVal);
- DBFreeVariant(&dbv);
- }
- CheckDlgButton(hwndDlg, IDC_ENABLE_ALERTS, db_get_b(hContact, MODULENAME, ENABLE_ALERTS_KEY, 0));
- CheckDlgButton(hwndDlg, IDC_ADD_DATE_NAME, db_get_b(hContact, MODULENAME, APND_DATE_NAME_KEY, 0));
- CheckDlgButton(hwndDlg, IDC_24_HOUR, db_get_b(hContact, MODULENAME, USE_24_HOUR_KEY, 0));
- CheckDlgButton(hwndDlg, IDC_ALWAYS_LOG, db_get_b(hContact, MODULENAME, ALWAYS_LOG_KEY, 0));
-
- if (!DBGetContactSetting(hContact, MODULENAME, ALRT_INDEX_KEY, &dbv))
- {
- int indexAlrtVal = 0;
-
- indexAlrtVal = db_get_b(hContact, MODULENAME, ALRT_INDEX_KEY, 0);
-
- ZeroMemory(&transCBstr, sizeof(transCBstr));
- _snprintf(transCBstr, sizeof(transCBstr), "%s", Translate(AlertTypes[indexAlrtVal]));
- SetDlgItemText(hwndDlg, IDC_ALERT_TYPE, transCBstr);
- DBFreeVariant(&dbv);
- }
- if (DBGetContactSetting(hContact, MODULENAME, ALRT_INDEX_KEY, &dbv))
- {
- ZeroMemory(&transCBstr, sizeof(transCBstr));
- _snprintf(transCBstr, sizeof(transCBstr), "%s", Translate(AlertTypes[0]));
- SetDlgItemText(hwndDlg, IDC_ALERT_TYPE, transCBstr);
- db_set_b(hContact, MODULENAME, ALRT_INDEX_KEY, 0);
- DBFreeVariant(&dbv);
- }
- if (!DBGetContactSetting(hContact, MODULENAME, EVNT_INDEX_KEY, &dbv))
- {
- int indexEvntVal = 0;
-
- indexEvntVal = db_get_b(hContact, MODULENAME, EVNT_INDEX_KEY, 0);
-
- ZeroMemory(&transCBstr, sizeof(transCBstr));
- _snprintf(transCBstr, sizeof(transCBstr), "%s", Translate(EventTypes[indexEvntVal]));
- SetDlgItemText(hwndDlg, IDC_EVENT_TYPE, transCBstr);
- DBFreeVariant(&dbv);
- }
- if (DBGetContactSetting(hContact, MODULENAME, EVNT_INDEX_KEY, &dbv))
- {
- ZeroMemory(&transCBstr, sizeof(transCBstr));
- _snprintf(transCBstr, sizeof(transCBstr), "%s", Translate(EventTypes[1]));
- SetDlgItemText(hwndDlg, IDC_EVENT_TYPE, transCBstr);
- db_set_b(hContact, MODULENAME, EVNT_INDEX_KEY, 1);
- DBFreeVariant(&dbv);
- }
- for (i = 0; i < sizeof(EventTypes) / sizeof(EventTypes[0]); i++)
- {
- ZeroMemory(&transCBstr, sizeof(transCBstr));
- _snprintf(transCBstr, sizeof(transCBstr), "%s", Translate(EventTypes[i]));
- SendDlgItemMessage(hwndDlg, IDC_EVENT_TYPE, CB_ADDSTRING, 0, (LPARAM) transCBstr);
- }
- for (i = 0; i < sizeof(AlertTypes) / sizeof(AlertTypes[0]); i++)
- {
- ZeroMemory(&transCBstr, sizeof(transCBstr));
- _snprintf(transCBstr, sizeof(transCBstr), "%s", Translate(AlertTypes[i]));
- SendDlgItemMessage(hwndDlg, IDC_ALERT_TYPE, CB_ADDSTRING, 0, (LPARAM) transCBstr);
- }
-
- if (DBGetContactSetting(hContact, MODULENAME, ENABLE_ALERTS_KEY, &dbv))
- {
- 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 (!DBGetContactSetting(hContact, MODULENAME, EVNT_INDEX_KEY, &dbv))
- {
- eventIndex = db_get_b(hContact, MODULENAME, EVNT_INDEX_KEY, 0);
- DBFreeVariant(&dbv);
- }
- if (!DBGetContactSetting(hContact, MODULENAME, ALRT_INDEX_KEY, &dbv))
- {
- alertIndex = db_get_b(hContact, MODULENAME, ALRT_INDEX_KEY, 0);
- DBFreeVariant(&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 (!DBGetContactSetting(hContact, MODULENAME, FILE_KEY, &dbv))
- {
- SetDlgItemText(hwndDlg, IDC_FILENAME, dbv.pszVal);
- DBFreeVariant(&dbv);
- }
- CheckDlgButton(hwndDlg, IDC_APPEND, db_get_b(hContact, MODULENAME, APPEND_KEY, 0));
- CheckDlgButton(hwndDlg, IDC_SAVE_AS_RAW, db_get_b(hContact, MODULENAME, SAVE_AS_RAW_KEY, 0));
-
- if (db_get_b(hContact, MODULENAME, CONTACT_PREFIX_KEY, 1) == 1)
- CheckRadioButton(hwndDlg, IDC_PREFIX, IDC_SUFFIX, IDC_PREFIX);
- else
- CheckRadioButton(hwndDlg, IDC_PREFIX, IDC_SUFFIX, IDC_SUFFIX);
- // ///
-
- // //
- if ((db_get_b(hContact, MODULENAME, 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;
- }
- break;
-
- case WM_COMMAND:
-
- switch (LOWORD(wParam))
- {
- char stringone[255];
-
- case IDC_BROWSE:
- {
- char szFileName[MAX_PATH];
- OPENFILENAME ofn;
-
- ZeroMemory(&ofn, sizeof(ofn));
- GetDlgItemText(hwndDlg, IDC_FILENAME, szFileName, sizeof(szFileName));
- ofn.lStructSize = sizeof(ofn);
- ofn.hwndOwner = hwndDlg;
- ofn.hInstance = NULL;
- ofn.lpstrFilter = "TEXT Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0\0";
- ofn.lpstrFile = szFileName;
- ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
- ofn.nMaxFile = sizeof(szFileName);
- ofn.nMaxFileTitle = MAX_PATH;
- ofn.lpstrDefExt = "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:
- {
- HANDLE hContact = (HANDLE) GetWindowLong(hwndDlg, GWL_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)));
-
- if (!DBGetContactSetting(hContact, MODULENAME, EVNT_INDEX_KEY, &dbv))
- {
- eventIndex = db_get_b(hContact, MODULENAME, EVNT_INDEX_KEY, 0);
- DBFreeVariant(&dbv);
- }
- if (!DBGetContactSetting(hContact, MODULENAME, ALRT_INDEX_KEY, &dbv))
- {
- alertIndex = db_get_b(hContact, MODULENAME, ALRT_INDEX_KEY, 0);
- DBFreeVariant(&dbv);
- }
- 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:
- {
- int alertIndex;
- HANDLE hContact = (HANDLE) GetWindowLong(hwndDlg, GWL_USERDATA);
-
- alertIndex = SendDlgItemMessage(hwndDlg, IDC_ALERT_TYPE, CB_GETCURSEL, 0, 0);
-
- if (HIWORD(wParam) != CBN_SELCHANGE && HIWORD(wParam) != CBN_EDITCHANGE)
- return FALSE;
- /**/
-
- if (HIWORD(wParam) == CBN_SELCHANGE)
- {
-
- 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);
- db_set_b(hContact, MODULENAME, ALRT_INDEX_KEY, alertIndex);
- } 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);
- db_set_b(hContact, MODULENAME, ALRT_INDEX_KEY, alertIndex);
- } 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);
- db_set_b(hContact, MODULENAME, ALRT_INDEX_KEY, alertIndex);
- } 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);
- db_set_b(hContact, MODULENAME, ALRT_INDEX_KEY, alertIndex);
- }
- 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:
- {
- int eventIndex;
- HANDLE hContact = (HANDLE) GetWindowLong(hwndDlg, GWL_USERDATA);
-
- eventIndex = SendDlgItemMessage(hwndDlg, IDC_EVENT_TYPE, CB_GETCURSEL, 0, 0);
-
- if (HIWORD(wParam) != CBN_SELCHANGE && HIWORD(wParam) != CBN_EDITCHANGE)
- return FALSE;
-
- /**/
-
- if (HIWORD(wParam) == CBN_SELCHANGE)
- {
- 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);
- db_set_b(hContact, MODULENAME, EVNT_INDEX_KEY, eventIndex);
- } 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);
- db_set_b(hContact, MODULENAME, EVNT_INDEX_KEY, eventIndex);
- } 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);
- db_set_b(hContact, MODULENAME, EVNT_INDEX_KEY, eventIndex);
- }
- }
- EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_APPLY), 1);
- }
- break;
-
- case IDC_ALERT_APPLY:
- case IDC_OK2:
- {
- HANDLE hContact = (HANDLE) GetWindowLong(hwndDlg, GWL_USERDATA);
- char szFileName[MAX_PATH];
-
- if (!DBGetContactSetting(hContact, MODULENAME, EVNT_INDEX_KEY, &dbv))
- {
- eventIndex = db_get_b(hContact, MODULENAME, EVNT_INDEX_KEY, 0);
- DBFreeVariant(&dbv);
- }
- if (!DBGetContactSetting(hContact, MODULENAME, ALRT_INDEX_KEY, &dbv))
- {
- alertIndex = db_get_b(hContact, MODULENAME, ALRT_INDEX_KEY, 0);
- DBFreeVariant(&dbv);
- }
- db_set_b(hContact, MODULENAME, ENABLE_ALERTS_KEY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS));
- db_set_b(hContact, MODULENAME, APND_DATE_NAME_KEY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_ADD_DATE_NAME));
- db_set_b(hContact, MODULENAME, USE_24_HOUR_KEY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_24_HOUR));
- db_set_b(hContact, MODULENAME, ALWAYS_LOG_KEY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_ALWAYS_LOG));
-
-//if alerts is unticked delete the cache
- if (!(IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)))
- SiteDeleted((WPARAM) hContact, 0);
-
- if (eventIndex == 0) // string present
-
- {
- if (!(GetWindowTextLength(GetDlgItem(hwndDlg, IDC_ALERT_STRING))))
- {
- if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))
- {
- MessageBox(NULL, Translate("You need to supply a search string."), 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(NULL, Translate("You need to supply a start string."), MODULENAME, MB_OK);
- break;
- }
- if (!(GetWindowTextLength(GetDlgItem(hwndDlg, IDC_END2))))
- {
- MessageBox(NULL, Translate("You need to supply an end string."), MODULENAME, MB_OK);
- break;
- }
- }
- }
- //
- if (alertIndex == 1) // log to file
-
- {
- if (!(GetWindowTextLength(GetDlgItem(hwndDlg, IDC_FILENAME))))
- {
- if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))
- {
- MessageBox(NULL, Translate("You need to supply a file name and path."), MODULENAME, MB_OK);
- break;
- }
- }
- }
- //
- if (IsDlgButtonChecked(hwndDlg, IDC_ALWAYS_LOG))
- {
- if (!(GetWindowTextLength(GetDlgItem(hwndDlg, IDC_FILENAME))))
- {
- if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS))
- {
- MessageBox(NULL, Translate("You need to supply a file name and path."), MODULENAME, MB_OK);
- break;
- }
- }
- }
- //
-
- GetDlgItemText(hwndDlg, IDC_FILENAME, szFileName, sizeof(szFileName));
- db_set_s(hContact, MODULENAME, FILE_KEY, szFileName);
-
- db_set_b(hContact, MODULENAME, APPEND_KEY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_APPEND));
- db_set_b(hContact, MODULENAME, SAVE_AS_RAW_KEY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_SAVE_AS_RAW));
-
- //
- ZeroMemory(&stringone, sizeof(stringone));
- GetDlgItemText(hwndDlg, IDC_ALERT_STRING, stringone, sizeof(stringone));
- db_set_s(hContact, MODULENAME, ALERT_STRING_KEY, stringone);
-
- ZeroMemory(&stringone, sizeof(stringone));
- GetDlgItemText(hwndDlg, IDC_START2, stringone, sizeof(stringone));
- db_set_s(hContact, MODULENAME, ALRT_S_STRING_KEY, stringone);
-
- ZeroMemory(&stringone, sizeof(stringone));
- GetDlgItemText(hwndDlg, IDC_END2, stringone, sizeof(stringone));
- db_set_s(hContact, MODULENAME, ALRT_E_STRING_KEY, stringone);
-
- db_set_b(hContact, MODULENAME, CONTACT_PREFIX_KEY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_PREFIX));
-
- EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_APPLY), 0);
-
- if (LOWORD(wParam) == IDC_OK2)
- {
- EnableWindow(GetDlgItem(ParentHwnd, IDC_ALERT_BUTTON), 1);
- EnableWindow(GetDlgItem(ParentHwnd, IDC_OPTIONS_BUTTON), 1);
- WindowList_Remove(hWindowList, hwndDlg);
- DestroyWindow(hwndDlg);
- }
- }
- break;
-
- case IDC_ALERT_CANCEL:
- {
- EnableWindow(GetDlgItem(ParentHwnd, IDC_ALERT_BUTTON), 1);
- EnableWindow(GetDlgItem(ParentHwnd, IDC_OPTIONS_BUTTON), 1);
- WindowList_Remove(hWindowList, hwndDlg);
- if (hwndDlg)
- {
- DestroyWindow(hwndDlg);
- hwndDlg = NULL;
- }
- }
- break;
-
- case WM_DESTROY:
- case IDC_CANCEL:
- {
- EnableWindow(GetDlgItem(ParentHwnd, IDC_ALERT_BUTTON), 1);
- EnableWindow(GetDlgItem(ParentHwnd, IDC_OPTIONS_BUTTON), 1);
- WindowList_Remove(hWindowList, hwndDlg);
- DestroyWindow(hwndDlg);
- return 0;
- }
- break;
-
- }
- break;
- }
- return FALSE;
+ HWND ParentHwnd;
+ DBVARIANT dbv;
+ int i;
+ int alertIndex = 0;
+ int eventIndex = 0;
+ static int test;
+ HANDLE hContact;
+
+ ParentHwnd = GetParent(hwndDlg);
+
+ switch (msg) {
+ case WM_INITDIALOG:
+ test = 0;
+ TranslateDialogDefault(hwndDlg);
+ hContact = (HANDLE)lParam;
+
+ SetWindowLong(hwndDlg, GWLP_USERDATA, (LONG) hContact);
+
+ SetWindowText(hwndDlg, TranslateT("Alert Options"));
+
+ SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM) LoadIcon(hInst, MAKEINTRESOURCE(IDI_ALERT)));
+
+ EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_APPLY), 0);
+
+ if (!db_get_ts(hContact, MODULENAME, ALERT_STRING_KEY, &dbv)) {
+ SetDlgItemText(hwndDlg, IDC_ALERT_STRING, dbv.ptszVal);
+ db_free(&dbv);
+ }
+ if (!db_get_ts(hContact, MODULENAME, ALRT_S_STRING_KEY, &dbv)) {
+ SetDlgItemText(hwndDlg, IDC_START2, dbv.ptszVal);
+ db_free(&dbv);
+ }
+ if (!db_get_ts(hContact, MODULENAME, ALRT_E_STRING_KEY, &dbv)) {
+ SetDlgItemText(hwndDlg, IDC_END2, dbv.ptszVal);
+ db_free(&dbv);
+ }
+ CheckDlgButton(hwndDlg, IDC_ENABLE_ALERTS, db_get_b(hContact, MODULENAME, ENABLE_ALERTS_KEY, 0));
+ CheckDlgButton(hwndDlg, IDC_ADD_DATE_NAME, db_get_b(hContact, MODULENAME, APND_DATE_NAME_KEY, 0));
+ CheckDlgButton(hwndDlg, IDC_24_HOUR, db_get_b(hContact, MODULENAME, USE_24_HOUR_KEY, 0));
+ CheckDlgButton(hwndDlg, IDC_ALWAYS_LOG, db_get_b(hContact, MODULENAME, ALWAYS_LOG_KEY, 0));
+
+ SetDlgItemText(hwndDlg, IDC_ALERT_TYPE, TranslateTS(AlertTypes[db_get_b(hContact, MODULENAME, ALRT_INDEX_KEY, 0)]));
+ SetDlgItemText(hwndDlg, IDC_EVENT_TYPE, TranslateTS(EventTypes[db_get_b(hContact, MODULENAME, EVNT_INDEX_KEY, 0)]));
+
+ for (i = 0; i < SIZEOF(AlertTypes); i++)
+ SendDlgItemMessage(hwndDlg, IDC_ALERT_TYPE, CB_ADDSTRING, 0, (LPARAM)TranslateTS(AlertTypes[i]));
+
+ for (i = 0; i < sizeof(EventTypes); i++)
+ SendDlgItemMessage(hwndDlg, IDC_EVENT_TYPE, CB_ADDSTRING, 0, (LPARAM)TranslateTS(EventTypes[i]));
+
+ if (db_get_b(hContact, MODULENAME, 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 (!db_get_s(hContact, MODULENAME, EVNT_INDEX_KEY, &dbv)) {
+ eventIndex = db_get_b(hContact, MODULENAME, EVNT_INDEX_KEY, 0);
+ db_free(&dbv);
+ }
+ if (!db_get_s(hContact, MODULENAME, ALRT_INDEX_KEY, &dbv)) {
+ alertIndex = db_get_b(hContact, MODULENAME, 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 ( !db_get_ts(hContact, MODULENAME, FILE_KEY, &dbv)) {
+ SetDlgItemText(hwndDlg, IDC_FILENAME, dbv.ptszVal);
+ db_free(&dbv);
+ }
+
+ CheckDlgButton(hwndDlg, IDC_APPEND, db_get_b(hContact, MODULENAME, APPEND_KEY, 0));
+ CheckDlgButton(hwndDlg, IDC_SAVE_AS_RAW, db_get_b(hContact, MODULENAME, SAVE_AS_RAW_KEY, 0));
+
+ if (db_get_b(hContact, MODULENAME, CONTACT_PREFIX_KEY, 1) == 1)
+ CheckRadioButton(hwndDlg, IDC_PREFIX, IDC_SUFFIX, IDC_PREFIX);
+ else
+ CheckRadioButton(hwndDlg, IDC_PREFIX, IDC_SUFFIX, IDC_SUFFIX);
+
+ if ( db_get_b(hContact, MODULENAME, 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:
+ {
+ TCHAR szFileName[MAX_PATH];
+ GetDlgItemText(hwndDlg, IDC_FILENAME, szFileName, SIZEOF(szFileName));
+
+ OPENFILENAME ofn = { 0 };
+ ofn.lStructSize = sizeof(ofn);
+ ofn.hwndOwner = hwndDlg;
+ ofn.hInstance = NULL;
+ ofn.lpstrFilter = _T("TEXT Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0\0");
+ ofn.lpstrFile = szFileName;
+ ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT;
+ ofn.nMaxFile = sizeof(szFileName);
+ ofn.nMaxFileTitle = MAX_PATH;
+ ofn.lpstrDefExt = _T("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 = (HANDLE) GetWindowLong(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 = db_get_b(hContact, MODULENAME, EVNT_INDEX_KEY, 0);
+ alertIndex = db_get_b(hContact, MODULENAME, 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 = (HANDLE) GetWindowLong(hwndDlg, GWLP_USERDATA);
+ int alertIndex = SendDlgItemMessage(hwndDlg, IDC_ALERT_TYPE, CB_GETCURSEL, 0, 0);
+
+ if (HIWORD(wParam) == CBN_SELCHANGE) {
+ db_set_b(hContact, MODULENAME, 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) {
+ HANDLE hContact = (HANDLE) GetWindowLong(hwndDlg, GWLP_USERDATA);
+ int eventIndex = SendDlgItemMessage(hwndDlg, IDC_EVENT_TYPE, CB_GETCURSEL, 0, 0);
+
+ if (HIWORD(wParam) == CBN_SELCHANGE) {
+ db_set_b(hContact, MODULENAME, 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 = (HANDLE) GetWindowLong(hwndDlg, GWLP_USERDATA);
+ TCHAR buf[MAX_PATH];
+
+ eventIndex = db_get_b(hContact, MODULENAME, EVNT_INDEX_KEY, 0);
+ alertIndex = db_get_b(hContact, MODULENAME, ALRT_INDEX_KEY, 0);
+
+ db_set_b(hContact, MODULENAME, ENABLE_ALERTS_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS));
+ db_set_b(hContact, MODULENAME, APND_DATE_NAME_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_ADD_DATE_NAME));
+ db_set_b(hContact, MODULENAME, USE_24_HOUR_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_24_HOUR));
+ db_set_b(hContact, MODULENAME, ALWAYS_LOG_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_ALWAYS_LOG));
+
+ //if alerts is unticked delete the cache
+ if (!(IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)))
+ SiteDeleted((WPARAM) hContact, 0);
+
+ if (eventIndex == 0) // string present
+ if (!(GetWindowTextLength(GetDlgItem(hwndDlg, IDC_ALERT_STRING))))
+ if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) {
+ MessageBox(NULL, TranslateT("You need to supply a search string."), _T(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(NULL, TranslateT("You need to supply a start string."), _T(MODULENAME), MB_OK);
+ break;
+ }
+ if (!(GetWindowTextLength(GetDlgItem(hwndDlg, IDC_END2)))) {
+ MessageBox(NULL, TranslateT("You need to supply an end string."), _T(MODULENAME), MB_OK);
+ break;
+ }
+ }
+
+ if (alertIndex == 1) // log to file
+ if (!(GetWindowTextLength(GetDlgItem(hwndDlg, IDC_FILENAME))))
+ if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) {
+ MessageBox(NULL, TranslateT("You need to supply a file name and path."), _T(MODULENAME), MB_OK);
+ break;
+ }
+
+ if (IsDlgButtonChecked(hwndDlg, IDC_ALWAYS_LOG))
+ if (!(GetWindowTextLength(GetDlgItem(hwndDlg, IDC_FILENAME))))
+ if (IsDlgButtonChecked(hwndDlg, IDC_ENABLE_ALERTS)) {
+ MessageBox(NULL, TranslateT("You need to supply a file name and path."), _T(MODULENAME), MB_OK);
+ break;
+ }
+
+ GetDlgItemText(hwndDlg, IDC_FILENAME, buf, SIZEOF(buf));
+ db_set_ts(hContact, MODULENAME, FILE_KEY, buf);
+
+ db_set_b(hContact, MODULENAME, APPEND_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_APPEND));
+ db_set_b(hContact, MODULENAME, SAVE_AS_RAW_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SAVE_AS_RAW));
+
+ GetDlgItemText(hwndDlg, IDC_ALERT_STRING, buf, SIZEOF(buf));
+ db_set_ts(hContact, MODULENAME, ALERT_STRING_KEY, buf);
+
+ GetDlgItemText(hwndDlg, IDC_START2, buf, sizeof(buf));
+ db_set_ts(hContact, MODULENAME, ALRT_S_STRING_KEY, buf);
+
+ GetDlgItemText(hwndDlg, IDC_END2, buf, sizeof(buf));
+ db_set_ts(hContact, MODULENAME, ALRT_E_STRING_KEY, buf);
+
+ db_set_b(hContact, MODULENAME, CONTACT_PREFIX_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_PREFIX));
+
+ EnableWindow(GetDlgItem(hwndDlg, IDC_ALERT_APPLY), 0);
+
+ if (LOWORD(wParam) == IDC_OK2) {
+ EnableWindow(GetDlgItem(ParentHwnd, IDC_ALERT_BUTTON), 1);
+ EnableWindow(GetDlgItem(ParentHwnd, IDC_OPTIONS_BUTTON), 1);
+ WindowList_Remove(hWindowList, hwndDlg);
+ DestroyWindow(hwndDlg);
+ }
+ }
+ }
+ break;
+
+ case IDC_ALERT_CANCEL:
+ EnableWindow(GetDlgItem(ParentHwnd, IDC_ALERT_BUTTON), 1);
+ EnableWindow(GetDlgItem(ParentHwnd, IDC_OPTIONS_BUTTON), 1);
+ WindowList_Remove(hWindowList, hwndDlg);
+ if (hwndDlg) {
+ DestroyWindow(hwndDlg);
+ hwndDlg = NULL;
+ }
+ break;
+
+ case WM_DESTROY:
+ case IDC_CANCEL:
+ EnableWindow(GetDlgItem(ParentHwnd, IDC_ALERT_BUTTON), 1);
+ EnableWindow(GetDlgItem(ParentHwnd, IDC_OPTIONS_BUTTON), 1);
+ WindowList_Remove(hWindowList, hwndDlg);
+ DestroyWindow(hwndDlg);
+ }
+ return FALSE;
}
-/**************/
-
-/*******************************/
+/*****************************************************************************/
-BOOL CALLBACK DlgProcContactOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+INT_PTR CALLBACK DlgProcContactOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- DBVARIANT dbv;
- char url[300];
- HWND ParentHwnd;
- static int test;
- static int test2;
-
-
- ParentHwnd = GetParent(hwndDlg);
-
- switch (msg)
- {
- case WM_INITDIALOG:
- {
- TranslateDialogDefault(hwndDlg);
-
- HANDLE hContact = (HANDLE) lParam;
-
- test = 0;
- test2 = 0;
-
- SetWindowLong(hwndDlg, GWL_USERDATA, (LONG) hContact);
- WindowList_Add(hWindowList, hwndDlg, hContact);
-
- SetWindowText(hwndDlg, Translate("Contact Options"));
-
- SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM) LoadIcon(hInst, MAKEINTRESOURCE(IDI_OPTIONS)));
-
- EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_APPLY), 0);
-
- if (!DBGetContactSetting(hContact, MODULENAME, URL_KEY, &dbv))
- {
- SetDlgItemText(hwndDlg, IDC_URL, dbv.pszVal);
- DBFreeVariant(&dbv);
- }
- if (!DBGetContactSetting(hContact, MODULENAME, START_STRING_KEY, &dbv))
- {
- SetDlgItemText(hwndDlg, IDC_START, dbv.pszVal);
- DBFreeVariant(&dbv);
- }
- if (!DBGetContactSetting(hContact, MODULENAME, END_STRING_KEY, &dbv))
- {
- SetDlgItemText(hwndDlg, IDC_END, dbv.pszVal);
- DBFreeVariant(&dbv);
- }
- if (DBGetContactSetting(hContact, MODULENAME, PRESERVE_NAME_KEY, &dbv))
- {
- DBFreeVariant(&dbv);
- DBGetContactSetting(hContact, "CList", "MyHandle", &dbv);
- db_set_s(hContact, MODULENAME, PRESERVE_NAME_KEY, dbv.pszVal);
- DBFreeVariant(&dbv);
- }
- if (!DBGetContactSetting(hContact, MODULENAME, PRESERVE_NAME_KEY, &dbv))
- {
- SetDlgItemText(hwndDlg, IDC_SITE_NAME, dbv.pszVal);
- DBFreeVariant(&dbv);
- }
- //
- CheckDlgButton(hwndDlg, IDC_CLEAN, db_get_b(hContact, MODULENAME, CLEAR_DISPLAY_KEY, 0));
-//
-
-//
- SendDlgItemMessage(hwndDlg, IDC_RWSPACE, TBM_SETRANGE, FALSE, MAKELONG(0, 4));
- SendDlgItemMessage(hwndDlg, IDC_RWSPACE, TBM_SETPOS, TRUE, db_get_b(hContact, MODULENAME, RWSPACE_KEY, 0));
- SetDlgItemText(hwndDlg, IDC_RWSPC_TEXT, Translate(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 (db_get_b(hContact, MODULENAME, 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 (db_get_b(hContact, MODULENAME, 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, Translate(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 = NULL;
- }
- return TRUE;
- }
- break;
-
- 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:
- {
- char string[128];
- HANDLE hContact = (HANDLE) GetWindowLong(hwndDlg, GWL_USERDATA);
-
- ZeroMemory(&string, sizeof(string));
- GetDlgItemText(hwndDlg, IDC_START, string, sizeof(string));
- db_set_s(hContact, MODULENAME, ALRT_S_STRING_KEY, string);
-
- ZeroMemory(&string, sizeof(string));
- GetDlgItemText(hwndDlg, IDC_END, string, sizeof(string));
- db_set_s(hContact, MODULENAME, ALRT_E_STRING_KEY, string);
-
- db_set_w(hContact, MODULENAME, 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_CPY_STR_TXT), (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:
- {
- char str[128];
- char contactname[128];
-
- //
-
- if (!(GetWindowTextLength(GetDlgItem(hwndDlg, IDC_URL))))
- {
- MessageBox(NULL, Translate("You need to supply a URL."), MODULENAME, MB_OK);
- break;
- }
- if (!(GetWindowTextLength(GetDlgItem(hwndDlg, IDC_START))))
- {
- if (IsDlgButtonChecked(hwndDlg, IDC_U_SE_STRINGS))
- {
- MessageBox(NULL, Translate("You need to supply a start string."), MODULENAME, MB_OK);
- break;
- }
- }
- if (!(GetWindowTextLength(GetDlgItem(hwndDlg, IDC_END))))
- {
- if (IsDlgButtonChecked(hwndDlg, IDC_U_SE_STRINGS))
- {
- MessageBox(NULL, Translate("You need to supply an end string."), MODULENAME, MB_OK);
- break;
- }
- }
- if (!(GetWindowTextLength(GetDlgItem(hwndDlg, IDC_SITE_NAME))))
- {
- MessageBox(NULL, Translate("You need to supply a name for the contact."), MODULENAME, MB_OK);
- break;
- }
- ZeroMemory(&contactname, sizeof(contactname));
- GetDlgItemText(hwndDlg, IDC_SITE_NAME, contactname, sizeof(contactname));
-
- if (strchr(contactname, '\\') != NULL)
- {
- MessageBox(NULL, Translate("Invalid symbol present in contact name."), MODULENAME, MB_OK);
- break;
- }
- if (strchr(contactname, '/') != NULL)
- {
- MessageBox(NULL, Translate("Invalid symbol present in contact name."), MODULENAME, MB_OK);
- break;
- }
- if (strchr(contactname, ':') != NULL)
- {
- MessageBox(NULL, Translate("Invalid symbol present in contact name."), MODULENAME, MB_OK);
- break;
- }
- if (strchr(contactname, '*') != NULL)
- {
- MessageBox(NULL, Translate("Invalid symbol present in contact name."), MODULENAME, MB_OK);
- break;
- }
- if (strchr(contactname, '?') != NULL)
- {
- MessageBox(NULL, Translate("Invalid symbol present in contact name."), MODULENAME, MB_OK);
- break;
- }
- if (strchr(contactname, '\"') != NULL)
- {
- MessageBox(NULL, Translate("Invalid symbol present in contact name."), MODULENAME, MB_OK);
- break;
- }
- if (strchr(contactname, '<') != NULL)
- {
- MessageBox(NULL, Translate("Invalid symbol present in contact name."), MODULENAME, MB_OK);
- break;
- }
- if (strchr(contactname, '>') != NULL)
- {
- MessageBox(NULL, Translate("Invalid symbol present in contact name."), MODULENAME, MB_OK);
- break;
- }
- if (strchr(contactname, '|') != NULL)
- {
- MessageBox(NULL, Translate("Invalid symbol present in contact name."), MODULENAME, MB_OK);
- break;
- }
- //
-
- HANDLE hContact = (HANDLE) GetWindowLong(hwndDlg, GWL_USERDATA);
-
- ZeroMemory(&url, sizeof(url));
- GetDlgItemText(hwndDlg, IDC_URL, url, sizeof(url));
- db_set_s(hContact, MODULENAME, URL_KEY, url);
- db_set_s(hContact, MODULENAME, "Homepage", url);
-
- ZeroMemory(&str, sizeof(str));
- GetDlgItemText(hwndDlg, IDC_START, str, sizeof(str));
- db_set_s(hContact, MODULENAME, START_STRING_KEY, str);
-
- ZeroMemory(&str, sizeof(str));
- GetDlgItemText(hwndDlg, IDC_END, str, sizeof(str));
- db_set_s(hContact, MODULENAME, END_STRING_KEY, str);
-
- ZeroMemory(&str, sizeof(str));
- GetDlgItemText(hwndDlg, IDC_SITE_NAME, str, sizeof(str));
- db_set_s(hContact, "CList", "MyHandle", str);
-
- db_set_b(hContact, MODULENAME, DBLE_WIN_KEY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_DBLE_WIN));
- db_set_b(hContact, MODULENAME, U_ALLSITE_KEY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_U_ALLSITE));
-
- db_set_b(hContact, MODULENAME, CLEAR_DISPLAY_KEY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_CLEAN));
- db_set_b(hContact, MODULENAME, RWSPACE_KEY, (BYTE) (SendDlgItemMessage(hwndDlg, IDC_RWSPACE, TBM_GETPOS, 0, 0)));
-
- // //
- char buttontext[256];
- char stringbefore[256];
- char*stringafter;
- char newbuttontext[256];
- int pos = 0;
- int posafter = 0;
- int posbefore = 0;
-
- ZeroMemory(&buttontext, sizeof(buttontext));
- ZeroMemory(&newbuttontext, sizeof(newbuttontext));
-
- _snprintf(buttontext, sizeof(buttontext), "%s", url);
- _snprintf(newbuttontext, sizeof(newbuttontext), "%s", url);
-
- if ((strstr(newbuttontext, "&")) != 0)
- {
-
- while (1)
- {
-
- ZeroMemory(&stringbefore, sizeof(stringbefore));
-
- if ((strstr(newbuttontext, "&")) == 0)
- break;
-
- _snprintf(buttontext, sizeof(buttontext), "%s", newbuttontext);
- stringafter = strstr(buttontext, "&");
- pos = (stringafter - buttontext);
- posbefore = (stringafter - buttontext) - 1;
- posafter = (stringafter - buttontext) + 1;
- strncpy(&stringafter[0], &stringafter[1], strlen(stringafter));
- _snprintf(stringbefore, pos, "%s", buttontext);
- _snprintf(newbuttontext, sizeof(buttontext), "%s%s%s", stringbefore, "!!", stringafter);
-
- posafter = 0;
- posbefore = 0;
- }
-
- while (1)
- {
- if ((strstr(newbuttontext, "!")) != 0)
- {
- stringafter = strstr(newbuttontext, "!");
- pos = (stringafter - newbuttontext);
- newbuttontext[pos] = '&';
- }
- if ((strstr(newbuttontext, "!")) == 0)
- break;
- }
- }
- SetDlgItemText(ParentHwnd, IDC_OPEN_URL, newbuttontext);
- //SetDlgItemText(ParentHwnd, IDC_HIDDEN_URL, url);
- // //
-
- //
- SetWindowText(ParentHwnd, str);
- EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_APPLY), 0);
-
- if (LOWORD(wParam) == IDOK)
- {
- EnableWindow(GetDlgItem(ParentHwnd, IDC_OPTIONS_BUTTON), 1);
- EnableWindow(GetDlgItem(ParentHwnd, IDC_ALERT_BUTTON), 1);
- if (hwndDlg)
- {
- DestroyWindow(hwndDlg);
- hwndDlg = NULL;
- }
- }
- //
- }
- break;
- case IDC_OPT_CANCEL:
- {
- EnableWindow(GetDlgItem(ParentHwnd, IDC_OPTIONS_BUTTON), 1);
- EnableWindow(GetDlgItem(ParentHwnd, IDC_ALERT_BUTTON), 1);
- WindowList_Remove(hWindowList, hwndDlg);
- if (hwndDlg)
- {
- DestroyWindow(hwndDlg);
- hwndDlg = NULL;
- }
- }
- break;
-
- }
- break;
-
- case WM_DESTROY:
- {
- EnableWindow(GetDlgItem(ParentHwnd, IDC_OPTIONS_BUTTON), 1);
- EnableWindow(GetDlgItem(ParentHwnd, IDC_ALERT_BUTTON), 1);
- WindowList_Remove(hWindowList, hwndDlg);
- DestroyWindow(hwndDlg);
- return 0;
- }
- break;
-
- //
- case WM_NOTIFY:
- switch (((LPNMHDR) lParam)->code)
- {
- case PSN_APPLY:
- {
- }
- break; // end apply
-
- }
- break; // end notify
- //
-
- }
- return FALSE;
+ DBVARIANT dbv;
+ TCHAR url[300];
+ HWND ParentHwnd = GetParent(hwndDlg);
+ static int test;
+ static int test2;
+ HANDLE hContact;
+
+ switch (msg) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault(hwndDlg);
+
+ hContact = (HANDLE) lParam;
+
+ test = 0;
+ test2 = 0;
+
+ SetWindowLong(hwndDlg, GWLP_USERDATA, (LONG) hContact);
+ WindowList_Add(hWindowList, hwndDlg, hContact);
+
+ SetWindowText(hwndDlg, TranslateT("Contact Options"));
+
+ SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM) LoadIcon(hInst, MAKEINTRESOURCE(IDI_OPTIONS)));
+
+ EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_APPLY), 0);
+
+ if (!db_get_ts(hContact, MODULENAME, URL_KEY, &dbv)) {
+ SetDlgItemText(hwndDlg, IDC_URL, dbv.ptszVal);
+ db_free(&dbv);
+ }
+ if (!db_get_ts(hContact, MODULENAME, START_STRING_KEY, &dbv)) {
+ SetDlgItemText(hwndDlg, IDC_START, dbv.ptszVal);
+ db_free(&dbv);
+ }
+ if (!db_get_ts(hContact, MODULENAME, END_STRING_KEY, &dbv)) {
+ SetDlgItemText(hwndDlg, IDC_END, dbv.ptszVal);
+ db_free(&dbv);
+ }
+ if (db_get_ts(hContact, MODULENAME, PRESERVE_NAME_KEY, &dbv)) {
+ db_free(&dbv);
+ db_get_ts(hContact, "CList", "MyHandle", &dbv);
+ db_set_ts(hContact, MODULENAME, PRESERVE_NAME_KEY, dbv.ptszVal);
+ db_free(&dbv);
+ }
+ if (!db_get_ts(hContact, MODULENAME, PRESERVE_NAME_KEY, &dbv)) {
+ SetDlgItemText(hwndDlg, IDC_SITE_NAME, dbv.ptszVal);
+ db_free(&dbv);
+ }
+
+ CheckDlgButton(hwndDlg, IDC_CLEAN, db_get_b(hContact, MODULENAME, CLEAR_DISPLAY_KEY, 0));
+
+ SendDlgItemMessage(hwndDlg, IDC_RWSPACE, TBM_SETRANGE, FALSE, MAKELONG(0, 4));
+ SendDlgItemMessage(hwndDlg, IDC_RWSPACE, TBM_SETPOS, TRUE, db_get_b(hContact, MODULENAME, RWSPACE_KEY, 0));
+ SetDlgItemText(hwndDlg, IDC_RWSPC_TEXT, TranslateTS(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 (db_get_b(hContact, MODULENAME, 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 (db_get_b(hContact, MODULENAME, 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, TranslateTS(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 = NULL;
+ }
+ 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:
+ {
+ TCHAR string[128];
+ hContact = (HANDLE) GetWindowLong(hwndDlg, GWLP_USERDATA);
+
+ GetDlgItemText(hwndDlg, IDC_START, string, SIZEOF(string));
+ db_set_ts(hContact, MODULENAME, ALRT_S_STRING_KEY, string);
+
+ GetDlgItemText(hwndDlg, IDC_END, string, SIZEOF(string));
+ db_set_ts(hContact, MODULENAME, ALRT_E_STRING_KEY, string);
+
+ db_set_w(hContact, MODULENAME, 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:
+ {
+ TCHAR str[128], contactname[128];
+ if (!GetWindowTextLength(GetDlgItem(hwndDlg, IDC_URL))) {
+ MessageBox(NULL, TranslateT("You need to supply a URL."), _T(MODULENAME), MB_OK);
+ break;
+ }
+ if (!GetWindowTextLength(GetDlgItem(hwndDlg, IDC_START))) {
+ if (IsDlgButtonChecked(hwndDlg, IDC_U_SE_STRINGS)) {
+ MessageBox(NULL, TranslateT("You need to supply a start string."), _T(MODULENAME), MB_OK);
+ break;
+ }
+ }
+ if (!GetWindowTextLength(GetDlgItem(hwndDlg, IDC_END))) {
+ if (IsDlgButtonChecked(hwndDlg, IDC_U_SE_STRINGS)) {
+ MessageBox(NULL, TranslateT("You need to supply an end string."), _T(MODULENAME), MB_OK);
+ break;
+ }
+ }
+ if (!GetWindowTextLength(GetDlgItem(hwndDlg, IDC_SITE_NAME))) {
+ MessageBox(NULL, TranslateT("You need to supply a name for the contact."), _T(MODULENAME), MB_OK);
+ break;
+ }
+
+ GetDlgItemText(hwndDlg, IDC_SITE_NAME, contactname, SIZEOF(contactname));
+ if (_tcschr(contactname, '\\') != NULL) {
+ MessageBox(NULL, TranslateT("Invalid symbol present in contact name."), _T(MODULENAME), MB_OK);
+ break;
+ }
+ if (_tcschr(contactname, '/') != NULL) {
+ MessageBox(NULL, TranslateT("Invalid symbol present in contact name."), _T(MODULENAME), MB_OK);
+ break;
+ }
+ if (_tcschr(contactname, ':') != NULL) {
+ MessageBox(NULL, TranslateT("Invalid symbol present in contact name."), _T(MODULENAME), MB_OK);
+ break;
+ }
+ if (_tcschr(contactname, '*') != NULL) {
+ MessageBox(NULL, TranslateT("Invalid symbol present in contact name."), _T(MODULENAME), MB_OK);
+ break;
+ }
+ if (_tcschr(contactname, '?') != NULL) {
+ MessageBox(NULL, TranslateT("Invalid symbol present in contact name."), _T(MODULENAME), MB_OK);
+ break;
+ }
+ if (_tcschr(contactname, '\"') != NULL) {
+ MessageBox(NULL, TranslateT("Invalid symbol present in contact name."), _T(MODULENAME), MB_OK);
+ break;
+ }
+ if (_tcschr(contactname, '<') != NULL) {
+ MessageBox(NULL, TranslateT("Invalid symbol present in contact name."), _T(MODULENAME), MB_OK);
+ break;
+ }
+ if (_tcschr(contactname, '>') != NULL) {
+ MessageBox(NULL, TranslateT("Invalid symbol present in contact name."), _T(MODULENAME), MB_OK);
+ break;
+ }
+ if (_tcschr(contactname, '|') != NULL) {
+ MessageBox(NULL, TranslateT("Invalid symbol present in contact name."), _T(MODULENAME), MB_OK);
+ break;
+ }
+
+ hContact = (HANDLE) GetWindowLong(hwndDlg, GWLP_USERDATA);
+
+ GetDlgItemText(hwndDlg, IDC_URL, url, SIZEOF(url));
+ db_set_ts(hContact, MODULENAME, URL_KEY, url);
+ db_set_ts(hContact, MODULENAME, "Homepage", url);
+
+ GetDlgItemText(hwndDlg, IDC_START, str, SIZEOF(str));
+ db_set_ts(hContact, MODULENAME, START_STRING_KEY, str);
+
+ GetDlgItemText(hwndDlg, IDC_END, str, SIZEOF(str));
+ db_set_ts(hContact, MODULENAME, END_STRING_KEY, str);
+
+ GetDlgItemText(hwndDlg, IDC_SITE_NAME, str, SIZEOF(str));
+ db_set_ts(hContact, "CList", "MyHandle", str);
+
+ db_set_b(hContact, MODULENAME, DBLE_WIN_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_DBLE_WIN));
+ db_set_b(hContact, MODULENAME, U_ALLSITE_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_U_ALLSITE));
+
+ db_set_b(hContact, MODULENAME, CLEAR_DISPLAY_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_CLEAN));
+ db_set_b(hContact, MODULENAME, RWSPACE_KEY, (BYTE)(SendDlgItemMessage(hwndDlg, IDC_RWSPACE, TBM_GETPOS, 0, 0)));
+
+ // //
+ TCHAR buttontext[256], stringbefore[256], newbuttontext[256];
+ _tcsncpy_s(buttontext, SIZEOF(buttontext), url, _TRUNCATE);
+ _tcsncpy_s(newbuttontext, SIZEOF(newbuttontext), url, _TRUNCATE);
+
+ if ( _tcschr(newbuttontext, '&') != 0) {
+ while (true) {
+ if ( _tcschr(newbuttontext, '&') == 0)
+ break;
+
+ _tcsncpy_s(buttontext, SIZEOF(buttontext), newbuttontext, _TRUNCATE);
+ TCHAR *stringafter = _tcschr(buttontext, '&');
+ int pos = (stringafter - buttontext);
+ int posbefore = (stringafter - buttontext) - 1;
+ int posafter = (stringafter - buttontext) + 1;
+ strdel(stringafter, 1);
+ _tcsncpy_s(stringbefore, pos, buttontext, _TRUNCATE);
+ mir_sntprintf(newbuttontext, SIZEOF(buttontext), _T("%s%S%s"), stringbefore, "!!", stringafter);
+
+ posafter = 0;
+ posbefore = 0;
+ }
+
+ while (true) {
+ if ( _tcschr(newbuttontext, '!') != 0) {
+ TCHAR *stringafter = _tcschr(newbuttontext, '!');
+ int pos = (stringafter - newbuttontext);
+ newbuttontext[pos] = '&';
+ }
+ if ( _tcschr(newbuttontext, '!') == 0)
+ break;
+ }
+ }
+ SetDlgItemText(ParentHwnd, IDC_OPEN_URL, newbuttontext);
+
+ SetWindowText(ParentHwnd, str);
+ EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_APPLY), 0);
+
+ if (LOWORD(wParam) == IDOK) {
+ EnableWindow(GetDlgItem(ParentHwnd, IDC_OPTIONS_BUTTON), 1);
+ EnableWindow(GetDlgItem(ParentHwnd, IDC_ALERT_BUTTON), 1);
+ if (hwndDlg) {
+ DestroyWindow(hwndDlg);
+ hwndDlg = NULL;
+ }
+ }
+ }
+ break;
+
+ case IDC_OPT_CANCEL:
+ EnableWindow(GetDlgItem(ParentHwnd, IDC_OPTIONS_BUTTON), 1);
+ EnableWindow(GetDlgItem(ParentHwnd, IDC_ALERT_BUTTON), 1);
+ WindowList_Remove(hWindowList, hwndDlg);
+ if (hwndDlg) {
+ DestroyWindow(hwndDlg);
+ hwndDlg = NULL;
+ }
+ }
+ break;
+
+ case WM_DESTROY:
+ EnableWindow(GetDlgItem(ParentHwnd, IDC_OPTIONS_BUTTON), 1);
+ EnableWindow(GetDlgItem(ParentHwnd, IDC_ALERT_BUTTON), 1);
+ WindowList_Remove(hWindowList, hwndDlg);
+ DestroyWindow(hwndDlg);
+ }
+ return FALSE;
}
-/***********************/
-/***********************/
-static BOOL CALLBACK DlgProcOpt(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+/*****************************************************************************/
+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:
- {
- int i;
-
- test = 0;
- TranslateDialogDefault(hwndDlg);
-
- SendDlgItemMessage(hwndDlg, IDC_SPIN1, UDM_SETRANGE, 0, MAKELONG(999, 0));
- SendDlgItemMessage(hwndDlg, IDC_SPIN2, UDM_SETRANGE, 0, MAKELONG(120, 0));
-
- SetDlgItemInt(hwndDlg, IDC_TIME, DBGetContactSettingWord(NULL, MODULENAME, REFRESH_KEY, 60), FALSE);
- SetDlgItemInt(hwndDlg, IDC_START_DELAY, DBGetContactSettingWord(NULL, MODULENAME, START_DELAY_KEY, 0), FALSE);
-
- forkthread((void *) FillFontListThread, 0, hwndDlg);
-
- CheckDlgButton(hwndDlg, IDC_DISABLEMENU, db_get_b(NULL, MODULENAME, MENU_OFF, 0));
- CheckDlgButton(hwndDlg, IDC_SUPPRESS, db_get_b(NULL, MODULENAME, SUPPRESS_ERR_KEY, 0));
- CheckDlgButton(hwndDlg, IDC_UPDATE_ONSTART, db_get_b(NULL, MODULENAME, UPDATE_ONSTART_KEY, 0));
- CheckDlgButton(hwndDlg, IDC_UPDATE_ON_OPEN, db_get_b(NULL, MODULENAME, UPDATE_ON_OPEN_KEY, 0));
- CheckDlgButton(hwndDlg, IDC_HIDE_STATUS_ICON, db_get_b(NULL, MODULENAME, HIDE_STATUS_ICON_KEY, 0));
- CheckDlgButton(hwndDlg, IDC_FONT_BOLD, db_get_b(NULL, MODULENAME, FONT_BOLD_KEY, 0));
- CheckDlgButton(hwndDlg, IDC_FONT_ITALIC, db_get_b(NULL, MODULENAME, FONT_ITALIC_KEY, 0));
- CheckDlgButton(hwndDlg, IDC_FONT_UNDERLINE, db_get_b(NULL, MODULENAME, FONT_UNDERLINE_KEY, 0));
- CheckDlgButton(hwndDlg, IDC_ERROR_POPUP, db_get_b(NULL, MODULENAME, ERROR_POPUP_KEY, 0));
- CheckDlgButton(hwndDlg, IDC_UPDATE_ONALERT, db_get_b(NULL, MODULENAME, UPDATE_ONALERT_KEY, 0));
- CheckDlgButton(hwndDlg, IDC_SAVE_INDIVID_POS, db_get_b(NULL, MODULENAME, SAVE_INDIVID_POS_KEY, 0));
- CheckDlgButton(hwndDlg, IDC_NO_PROTECT, db_get_b(NULL, MODULENAME, NO_PROTECT_KEY, 0));
- CheckDlgButton(hwndDlg, IDC_DATAPOPUP, db_get_b(NULL, MODULENAME, DATA_POPUP_KEY, 0));
-
-
-
- if (!DBGetContactSetting(NULL, MODULENAME, FONT_FACE_KEY, &dbv))
- {
- SetDlgItemText(hwndDlg, IDC_TYPEFACE, dbv.pszVal);
- DBFreeVariant(&dbv);
- }
- for (i = 0; i < sizeof(fontSizes) / sizeof(fontSizes[0]); i++)
- SendDlgItemMessage(hwndDlg, IDC_FONTSIZE, CB_ADDSTRING, 0, (LPARAM) fontSizes[i]);
-
- SendMessage(hwndDlg, M_FILLSCRIPTCOMBO, wParam, 0);
-
- if (!DBGetContactSetting(NULL, MODULENAME, FONT_SIZE_KEY, &dbv))
- {
- SetDlgItemInt(hwndDlg, IDC_FONTSIZE, (db_get_b(NULL, MODULENAME, FONT_SIZE_KEY, 0)), FALSE);
- DBFreeVariant(&dbv);
- }
- //
- 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 ((db_get_b(NULL, MODULENAME, 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_ADDPOPUP) != 0))
- EnableWindow(GetDlgItem(hwndDlg, IDC_ERROR_POPUP), 1);
- }
-
- if ((ServiceExists(MS_POPUP_ADDPOPUP) == 0))
- EnableWindow(GetDlgItem(hwndDlg, IDC_ERROR_POPUP), 0);
-
- if ((db_get_b(NULL, MODULENAME, 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, sizeof(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) ((db_get_b(NULL, MODULENAME, FONT_SCRIPT_KEY, 1))))
- {
- 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);
- db_set_dw(NULL, MODULENAME, 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);
- db_set_dw(NULL, MODULENAME, 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_ADDPOPUP) != 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:
- {
- char str[100];
-
- db_set_b(NULL, MODULENAME, MENU_OFF, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_DISABLEMENU));
- db_set_b(NULL, MODULENAME, SUPPRESS_ERR_KEY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_SUPPRESS));
- db_set_b(NULL, MODULENAME, UPDATE_ONSTART_KEY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_UPDATE_ONSTART));
- db_set_b(NULL, MODULENAME, UPDATE_ON_OPEN_KEY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_UPDATE_ON_OPEN));
- db_set_b(NULL, MODULENAME, HIDE_STATUS_ICON_KEY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_HIDE_STATUS_ICON));
- db_set_b(NULL, MODULENAME, FONT_BOLD_KEY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_FONT_BOLD));
- db_set_b(NULL, MODULENAME, FONT_ITALIC_KEY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_FONT_ITALIC));
- db_set_b(NULL, MODULENAME, FONT_UNDERLINE_KEY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_FONT_UNDERLINE));
- db_set_b(NULL, MODULENAME, UPDATE_ONALERT_KEY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_UPDATE_ONALERT));
- db_set_b(NULL, MODULENAME, SAVE_INDIVID_POS_KEY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_SAVE_INDIVID_POS));
- db_set_b(NULL, MODULENAME, NO_PROTECT_KEY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_NO_PROTECT));
- db_set_b(NULL, MODULENAME, DATA_POPUP_KEY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_DATAPOPUP));
-
- GetDlgItemText(hwndDlg, IDC_TYPEFACE, str, sizeof(str));
- db_set_s(NULL, MODULENAME, FONT_FACE_KEY, str);
- //
- db_set_b(NULL, MODULENAME, FONT_SIZE_KEY, (GetDlgItemInt(hwndDlg, IDC_FONTSIZE, NULL, FALSE)));
- db_set_b(NULL, MODULENAME, FONT_SCRIPT_KEY, ((BYTE) SendDlgItemMessage(hwndDlg, IDC_SCRIPT, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_SCRIPT, CB_GETCURSEL, 0, 0), 0)));
- //
- db_set_b(NULL, MODULENAME, ERROR_POPUP_KEY, (BYTE) IsDlgButtonChecked(hwndDlg, IDC_ERROR_POPUP));
-
- timerval = GetDlgItemInt(hwndDlg, IDC_TIME, NULL, FALSE);
- db_set_dw(NULL, MODULENAME, REFRESH_KEY, timerval);
- db_set_dw(NULL, MODULENAME, COUNTDOWN_KEY, timerval);
-
-
- delaytime = GetDlgItemInt(hwndDlg, IDC_START_DELAY, NULL, FALSE);
- db_set_dw(NULL, MODULENAME, START_DELAY_KEY, delaytime);
-
- BackgoundClr = (SendDlgItemMessage(hwndDlg, IDC_BGCOLOR, CPM_GETCOLOUR, 0, 0));
- TextClr = (SendDlgItemMessage(hwndDlg, IDC_TXTCOLOR, CPM_GETCOLOUR, 0, 0));
-
- if ((db_get_dw(NULL, MODULENAME, REFRESH_KEY, 0) != 0))
- {
- KillTimer(NULL, timerId);
- KillTimer(NULL, Countdown);
- timerId = SetTimer(NULL, 0, ((db_get_dw(NULL, MODULENAME, REFRESH_KEY, 0)) * MINUTE), (TIMERPROC) timerfunc);
- Countdown = SetTimer(NULL, 0, MINUTE, (TIMERPROC) Countdownfunc);
- }
- if ((db_get_dw(NULL, MODULENAME, REFRESH_KEY, 0) == 0))
- {
- KillTimer(NULL, timerId);
- KillTimer(NULL, Countdown);
- }
- test = 0;
- }
- break; // end apply
-
- }
- break; // end notify
-
- default:
- break;
- }
-
- return 0;
+ 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, db_get_dw(NULL, MODULENAME, REFRESH_KEY, TIME), FALSE);
+ SetDlgItemInt(hwndDlg, IDC_START_DELAY, db_get_w(NULL, MODULENAME, START_DELAY_KEY, 0), FALSE);
+
+ mir_forkthread(FillFontListThread, hwndDlg);
+
+ CheckDlgButton(hwndDlg, IDC_DISABLEMENU, db_get_b(NULL, MODULENAME, MENU_OFF, 0));
+ CheckDlgButton(hwndDlg, IDC_SUPPRESS, db_get_b(NULL, MODULENAME, SUPPRESS_ERR_KEY, 0));
+ CheckDlgButton(hwndDlg, IDC_UPDATE_ONSTART, db_get_b(NULL, MODULENAME, UPDATE_ONSTART_KEY, 0));
+ CheckDlgButton(hwndDlg, IDC_UPDATE_ON_OPEN, db_get_b(NULL, MODULENAME, UPDATE_ON_OPEN_KEY, 0));
+ CheckDlgButton(hwndDlg, IDC_HIDE_STATUS_ICON, db_get_b(NULL, MODULENAME, HIDE_STATUS_ICON_KEY, 0));
+ CheckDlgButton(hwndDlg, IDC_FONT_BOLD, db_get_b(NULL, MODULENAME, FONT_BOLD_KEY, 0));
+ CheckDlgButton(hwndDlg, IDC_FONT_ITALIC, db_get_b(NULL, MODULENAME, FONT_ITALIC_KEY, 0));
+ CheckDlgButton(hwndDlg, IDC_FONT_UNDERLINE, db_get_b(NULL, MODULENAME, FONT_UNDERLINE_KEY, 0));
+ CheckDlgButton(hwndDlg, IDC_ERROR_POPUP, db_get_b(NULL, MODULENAME, ERROR_POPUP_KEY, 0));
+ CheckDlgButton(hwndDlg, IDC_UPDATE_ONALERT, db_get_b(NULL, MODULENAME, UPDATE_ONALERT_KEY, 0));
+ CheckDlgButton(hwndDlg, IDC_SAVE_INDIVID_POS, db_get_b(NULL, MODULENAME, SAVE_INDIVID_POS_KEY, 0));
+ CheckDlgButton(hwndDlg, IDC_NO_PROTECT, db_get_b(NULL, MODULENAME, NO_PROTECT_KEY, 0));
+ CheckDlgButton(hwndDlg, IDC_DATAPOPUP, db_get_b(NULL, MODULENAME, DATA_POPUP_KEY, 0));
+
+ if (!db_get_ts(NULL, MODULENAME, FONT_FACE_KEY, &dbv)) {
+ SetDlgItemText(hwndDlg, IDC_TYPEFACE, dbv.ptszVal);
+ db_free(&dbv);
+ }
+ else SetDlgItemText(hwndDlg, IDC_TYPEFACE, Def_font_face);
+
+ for (int i = 0; i < SIZEOF(fontSizes); i++)
+ SendDlgItemMessage(hwndDlg, IDC_FONTSIZE, CB_ADDSTRING, 0, (LPARAM)fontSizes[i]);
+
+ SendMessage(hwndDlg, M_FILLSCRIPTCOMBO, wParam, 0);
+
+ SetDlgItemInt(hwndDlg, IDC_FONTSIZE, db_get_b(NULL, MODULENAME, 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 ( db_get_b(NULL, MODULENAME, 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_ADDPOPUP) != 0))
+ EnableWindow(GetDlgItem(hwndDlg, IDC_ERROR_POPUP), 1);
+ }
+
+ if (ServiceExists(MS_POPUP_ADDPOPUP) == 0)
+ EnableWindow(GetDlgItem(hwndDlg, IDC_ERROR_POPUP), 0);
+
+ if ( db_get_b(NULL, MODULENAME, 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, sizeof(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)((db_get_b(NULL, MODULENAME, 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);
+ db_set_dw(NULL, MODULENAME, 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);
+ db_set_dw(NULL, MODULENAME, 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_ADDPOPUP) != 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:
+ db_set_b(NULL, MODULENAME, MENU_OFF, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_DISABLEMENU));
+ db_set_b(NULL, MODULENAME, SUPPRESS_ERR_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SUPPRESS));
+ db_set_b(NULL, MODULENAME, UPDATE_ONSTART_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_UPDATE_ONSTART));
+ db_set_b(NULL, MODULENAME, UPDATE_ON_OPEN_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_UPDATE_ON_OPEN));
+ db_set_b(NULL, MODULENAME, HIDE_STATUS_ICON_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_HIDE_STATUS_ICON));
+ db_set_b(NULL, MODULENAME, FONT_BOLD_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_FONT_BOLD));
+ db_set_b(NULL, MODULENAME, FONT_ITALIC_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_FONT_ITALIC));
+ db_set_b(NULL, MODULENAME, FONT_UNDERLINE_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_FONT_UNDERLINE));
+ db_set_b(NULL, MODULENAME, UPDATE_ONALERT_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_UPDATE_ONALERT));
+ db_set_b(NULL, MODULENAME, SAVE_INDIVID_POS_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_SAVE_INDIVID_POS));
+ db_set_b(NULL, MODULENAME, NO_PROTECT_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_NO_PROTECT));
+ db_set_b(NULL, MODULENAME, DATA_POPUP_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_DATAPOPUP));
+
+ TCHAR str[100];
+ GetDlgItemText(hwndDlg, IDC_TYPEFACE, str, SIZEOF(str));
+ db_set_ts(NULL, MODULENAME, FONT_FACE_KEY, str);
+
+ db_set_b(NULL, MODULENAME, FONT_SIZE_KEY, (GetDlgItemInt(hwndDlg, IDC_FONTSIZE, NULL, FALSE)));
+ db_set_b(NULL, MODULENAME, FONT_SCRIPT_KEY, ((BYTE)SendDlgItemMessage(hwndDlg, IDC_SCRIPT, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, IDC_SCRIPT, CB_GETCURSEL, 0, 0), 0)));
+
+ db_set_b(NULL, MODULENAME, ERROR_POPUP_KEY, (BYTE)IsDlgButtonChecked(hwndDlg, IDC_ERROR_POPUP));
+
+ timerval = GetDlgItemInt(hwndDlg, IDC_TIME, NULL, FALSE);
+ db_set_dw(NULL, MODULENAME, REFRESH_KEY, timerval);
+ db_set_dw(NULL, MODULENAME, COUNTDOWN_KEY, timerval);
+
+
+ delaytime = GetDlgItemInt(hwndDlg, IDC_START_DELAY, NULL, FALSE);
+ db_set_dw(NULL, MODULENAME, START_DELAY_KEY, delaytime);
+
+ BackgoundClr = (SendDlgItemMessage(hwndDlg, IDC_BGCOLOR, CPM_GETCOLOUR, 0, 0));
+ TextClr = (SendDlgItemMessage(hwndDlg, IDC_TXTCOLOR, CPM_GETCOLOUR, 0, 0));
+
+ if ((db_get_dw(NULL, MODULENAME, REFRESH_KEY, 0) != 0))
+ {
+ KillTimer(NULL, timerId);
+ KillTimer(NULL, Countdown);
+ timerId = SetTimer(NULL, 0, ((db_get_dw(NULL, MODULENAME, REFRESH_KEY, 0)) * MINUTE), (TIMERPROC) timerfunc);
+ Countdown = SetTimer(NULL, 0, MINUTE, (TIMERPROC) Countdownfunc);
+ }
+ if ((db_get_dw(NULL, MODULENAME, REFRESH_KEY, 0) == 0))
+ {
+ KillTimer(NULL, timerId);
+ KillTimer(NULL, Countdown);
+ }
+ test = 0;
+ }
+ break; // end apply
+ }
+
+ return 0;
}
/********************/
diff --git a/plugins/WebView/src/webview_private.h b/plugins/WebView/src/webview_private.h
deleted file mode 100644
index e57fcf9f45..0000000000
--- a/plugins/WebView/src/webview_private.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/* THIS FILE WILL BE OVERWRITTEN BY DEV-C++ */
-/* DO NOT EDIT ! */
-
-#ifndef WEBVIEW_PRIVATE_H
-#define WEBVIEW_PRIVATE_H
-
-/* VERSION DEFINITIONS */
-#define VER_STRING "0.1.3.10"
-#define VER_MAJOR 0
-#define VER_MINOR 1
-#define VER_RELEASE 3
-#define VER_BUILD 10
-#define COMPANY_NAME ""
-#define FILE_VERSION "0.1.3.10"
-#define FILE_DESCRIPTION "Webview protocol plugin for Miranda IM"
-#define INTERNAL_NAME ""
-#define LEGAL_COPYRIGHT ""
-#define LEGAL_TRADEMARKS ""
-#define ORIGINAL_FILENAME ""
-#define PRODUCT_NAME ""
-#define PRODUCT_VERSION ""
-
-#endif /*WEBVIEW_PRIVATE_H*/
diff --git a/plugins/WebView/src/webview_services.cpp b/plugins/WebView/src/webview_services.cpp
index 884408e8cd..1992092f8c 100644
--- a/plugins/WebView/src/webview_services.cpp
+++ b/plugins/WebView/src/webview_services.cpp
@@ -1,772 +1,469 @@
/*
- * 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.
- */
+* 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 sID[32];
+static int searchId = -1;
+static TCHAR sID[32];
+
+/*****************************************************************************/
+static char szInvalidChars[] = { '\\', '/', ':', '*', '?', '\"', '<', '>', '|' };
-/************************/
int DBSettingChanged(WPARAM wParam, LPARAM lParam)
{
-
- DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *) lParam;
- char *invalidchar;
-
- // We can't upload changes to NULL contact
- if ((HANDLE) wParam == NULL)
- return 0;
-
- if (!strcmp(cws->szModule, "CList"))
- {
- HANDLE hContact;
- DBVARIANT dbv;
- char*szProto;
- FILE *pcachefile;
- char cachepath[MAX_PATH];
-
- char cachedirectorypath[MAX_PATH];
-
- char newcachepath[MAX_PATH + 50];
- char renamedcachepath[MAX_PATH + 50];
- char*cacheend;
- char OLDcontactname[100];
- char NEWcontactname[100];
- int ranNum;
- char ranStr[7];
- int invalidpresent = 0;
-
-
- hContact = (HANDLE) wParam;
- szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0);
- if (szProto == NULL || strcmp(szProto, MODULENAME))
- return 0;
-
- // A contact is renamed
- if (!strcmp(cws->szSetting, "MyHandle"))
- {
- hContact = (HANDLE) wParam;
- szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0);
- if (szProto == NULL || strcmp(szProto, MODULENAME))
- return 0;
-///////
- if (!DBGetContactSetting(hContact, MODULENAME, PRESERVE_NAME_KEY, &dbv))
- {
- char nick[100];
-
- ZeroMemory(&OLDcontactname, sizeof(OLDcontactname));
- ZeroMemory(&NEWcontactname, sizeof(NEWcontactname));
-
- DBFreeVariant(&dbv);
-
- ZeroMemory(&nick, sizeof(nick));
-
- DBGetContactSetting(hContact, "CList", "MyHandle", &dbv);
- _snprintf(nick, sizeof(nick), "%s", dbv.pszVal);
- DBFreeVariant(&dbv);
-
- DBGetContactSetting((HANDLE) wParam, MODULENAME, PRESERVE_NAME_KEY, &dbv);
- _snprintf(OLDcontactname, sizeof(OLDcontactname), "%s", dbv.pszVal);
- DBFreeVariant(&dbv);
-
- if (strchr(nick, '\\') != NULL)
- {
- WErrorPopup("ERROR", Translate("Invalid symbol present in contact name."));
- invalidchar = strchr(nick, '\\');
- *invalidchar = '_';
- invalidpresent =1;
- }
-
- if (strchr(nick, '/') != NULL)
- {
- WErrorPopup("ERROR", Translate("Invalid symbol present in contact name."));
- invalidchar = strchr(nick, '/');
- *invalidchar = '_';
- invalidpresent =1;
- }
-
- if (strchr(nick, ':') != NULL)
- {
- WErrorPopup("ERROR", Translate("Invalid symbol present in contact name."));
- invalidchar = strchr(nick, ':');
- *invalidchar = '_';
- invalidpresent =1;
- }
-
- if (strchr(nick, '*') != NULL)
- {
- WErrorPopup("ERROR", Translate("Invalid symbol present in contact name."));
- invalidchar = strchr(nick, '*');
- *invalidchar = '_';
- invalidpresent =1;
- }
-
- if (strchr(nick, '?') != NULL)
- {
- WErrorPopup("ERROR", Translate("Invalid symbol present in contact name."));
- invalidchar = strchr(nick, '?');
- *invalidchar = '_';
- invalidpresent =1;
- }
-
- if (strchr(nick, '\"') != NULL)
- {
- WErrorPopup("ERROR", Translate("Invalid symbol present in contact name."));
- invalidchar = strchr(nick, '\"');
- *invalidchar = '_';
- invalidpresent =1;
- }
-
- if (strchr(nick, '<') != NULL)
- {
- WErrorPopup("ERROR", Translate("Invalid symbol present in contact name."));
- invalidchar = strchr(nick, '<');
- *invalidchar = '_';
- invalidpresent =1;
- }
-
- if (strchr(nick, '>') != NULL)
- {
- WErrorPopup("ERROR", Translate("Invalid symbol present in contact name."));
- invalidchar = strchr(nick, '>');
- *invalidchar = '_';
- invalidpresent =1;
- }
-
- if (strchr(nick, '|') != NULL)
- {
- WErrorPopup("ERROR", Translate("Invalid symbol present in contact name."));
- invalidchar = strchr(nick, '|');
- *invalidchar = '_';
- invalidpresent =1;
- }
-
- if(invalidpresent)
- {
- srand((unsigned) time(NULL));
- ranNum = (int) 10000 *rand() / (RAND_MAX + 1.0);
- _snprintf(ranStr, sizeof(ranStr), "%d", ranNum);
- strcat(nick, ranStr);
- }
-
-
-
- if (((strchr(nick, '(')) == 0))
- {
- db_set_s(hContact, MODULENAME, PRESERVE_NAME_KEY, nick);
- db_set_s(hContact, MODULENAME, "Nick", nick);
- db_set_s(hContact, "CList", "MyHandle", nick);
- }
- DBGetContactSetting((HANDLE) wParam, MODULENAME, PRESERVE_NAME_KEY, &dbv);
- _snprintf(NEWcontactname, sizeof(NEWcontactname), "%s", dbv.pszVal);
- DBFreeVariant(&dbv);
-
-//
-
- // TEST GET NAME FOR CACHE
- GetModuleFileName(hInst, cachepath, sizeof(cachepath));
- cacheend = strrchr(cachepath, '\\');
- cacheend++;
- *cacheend = '\0';
- _snprintf(cachedirectorypath, sizeof(cachedirectorypath), "%s%s%s", cachepath, MODULENAME, "cache\\");
- CreateDirectory(cachedirectorypath, NULL);
-
-
-
- _snprintf(newcachepath, sizeof(newcachepath), "%s%s%s%s%s", cachepath, MODULENAME, "cache\\", OLDcontactname, ".txt");
- _snprintf(renamedcachepath, sizeof(newcachepath), "%s%s%s%s%s", cachepath, MODULENAME, "cache\\", NEWcontactname, ".txt");
-
-
-
- // file exists?
- if ((_access(newcachepath, 0)) != -1)
- {
- if ((pcachefile = fopen(newcachepath, "r")) != NULL)
- {
- fclose(pcachefile);
- if (lstrcmp(newcachepath, renamedcachepath))
- {
- MoveFile(newcachepath, renamedcachepath);
- db_set_s(hContact, MODULENAME, CACHE_FILE_KEY, renamedcachepath);
- }
-
- }
- }
-//
-
- }
-////////
- }
- }
- return 0;
+ // We can't upload changes to NULL contact
+ HANDLE hContact = (HANDLE)wParam;
+ if (hContact == NULL)
+ return 0;
+
+ DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *) lParam;
+ if (!strcmp(cws->szModule, "CList")) {
+ int invalidpresent = 0;
+
+ char *szProto = GetContactProto(hContact);
+ if (szProto == NULL || strcmp(szProto, MODULENAME))
+ return 0;
+
+ // A contact is renamed
+ if (!strcmp(cws->szSetting, "MyHandle")) {
+ ptrT oldName( db_get_tsa(hContact, MODULENAME, PRESERVE_NAME_KEY));
+ if (oldName == NULL)
+ return 0;
+
+ TCHAR nick[100];
+ ptrT oldnick( db_get_tsa(hContact, "CList", "MyHandle"));
+ if (oldnick != NULL)
+ _tcsncpy_s(nick, SIZEOF(nick), oldnick, _TRUNCATE);
+ else
+ nick[0] = 0;
+
+ for (int i=0; i < SIZEOF(szInvalidChars); i++ ) {
+ TCHAR *p = _tcschr(nick, szInvalidChars[i]);
+ if (p != NULL) {
+ WErrorPopup("ERROR", TranslateT("Invalid symbol present in contact name."));
+ *p = '_';
+ invalidpresent =1;
+ }
+ }
+
+ if (invalidpresent) {
+ srand((unsigned)time(NULL));
+ TCHAR ranStr[7];
+ _itot((int)10000 *rand() / (RAND_MAX + 1.0), ranStr, 10);
+ _tcscat(nick, ranStr);
+ }
+
+ if ( _tcschr(nick, '(') == 0) {
+ db_set_ts(hContact, MODULENAME, PRESERVE_NAME_KEY, nick);
+ db_set_ts(hContact, MODULENAME, "Nick", nick);
+ db_set_ts(hContact, "CList", "MyHandle", nick);
+ }
+
+ // TEST GET NAME FOR CACHE
+ TCHAR cachepath[MAX_PATH], cachedirectorypath[MAX_PATH];
+ GetModuleFileName(hInst, cachepath, SIZEOF(cachepath));
+ TCHAR *cacheend = _tcsrchr(cachepath, '\\');
+ cacheend++;
+ *cacheend = '\0';
+ mir_sntprintf(cachedirectorypath, SIZEOF(cachedirectorypath), _T("%s%S%S"), cachepath, MODULENAME, "cache\\");
+ CreateDirectory(cachedirectorypath, NULL);
+
+ TCHAR newcachepath[MAX_PATH + 50], renamedcachepath[MAX_PATH + 50];
+ mir_sntprintf(newcachepath, SIZEOF(newcachepath), _T("%s%S%S%s%S"), cachepath, MODULENAME, "cache\\", oldName, ".txt");
+ mir_sntprintf(renamedcachepath, SIZEOF(newcachepath), _T("%s%S%S%s%S"), cachepath, MODULENAME, "cache\\", nick, ".txt");
+
+ // file exists?
+ if ( _taccess(newcachepath, 0) != -1) {
+ FILE *pcachefile = _tfopen(newcachepath, _T("r"));
+ if (pcachefile != NULL) {
+ fclose(pcachefile);
+ if (lstrcmp(newcachepath, renamedcachepath)) {
+ MoveFile(newcachepath, renamedcachepath);
+ db_set_ts(hContact, MODULENAME, CACHE_FILE_KEY, renamedcachepath);
+ }
+ }
+ }
+ }
+ }
+ return 0;
}
-/************************/
-/************************/
+/*****************************************************************************/
int SiteDeleted(WPARAM wParam, LPARAM lParam)
{
- FILE *pcachefile;
- char cachepath[MAX_PATH];
- char cachedirectorypath[MAX_PATH];
- char newcachepath[MAX_PATH + 50];
- char*cacheend;
- char contactname[100];
- DBVARIANT dbv;
-
- ZeroMemory(&contactname, sizeof(contactname));
- ZeroMemory(&dbv, sizeof(dbv));
-
- if (lstrcmp((char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, wParam, 0), MODULENAME))
- return 0;
-
- DBGetContactSetting((HANDLE) wParam, MODULENAME, PRESERVE_NAME_KEY, &dbv);
- _snprintf(contactname, sizeof(contactname), "%s", dbv.pszVal);
- DBFreeVariant(&dbv);
-
- // TEST GET NAME FOR CACHE
- GetModuleFileName(hInst, cachepath, sizeof(cachepath));
- cacheend = strrchr(cachepath, '\\');
- cacheend++;
- *cacheend = '\0';
-
- _snprintf(cachedirectorypath, sizeof(cachedirectorypath), "%s%s%s", cachepath, MODULENAME, "cache\\");
- CreateDirectory(cachedirectorypath, NULL);
- _snprintf(newcachepath, sizeof(newcachepath), "%s%s%s%s%s", cachepath, MODULENAME, "cache\\", contactname, ".txt");
- // file exists?
- if ((_access(newcachepath, 0)) != -1)
- {
- if ((pcachefile = fopen(newcachepath, "r")) != NULL)
- {
- fclose(pcachefile);
- DeleteFile(newcachepath);
- db_set_s((HANDLE) wParam, MODULENAME, CACHE_FILE_KEY, "");
- }
- }
- return 0;
+ HANDLE hContact = (HANDLE)wParam;
+ if (lstrcmpA(GetContactProto(hContact), MODULENAME))
+ return 0;
+
+ ptrT contactName( db_get_tsa(hContact, MODULENAME, PRESERVE_NAME_KEY));
+
+ // TEST GET NAME FOR CACHE
+ TCHAR cachepath[MAX_PATH], cachedirectorypath[MAX_PATH], newcachepath[MAX_PATH + 50];
+ GetModuleFileName(hInst, cachepath, SIZEOF(cachepath));
+ TCHAR *cacheend = _tcsrchr(cachepath, '\\');
+ cacheend++;
+ *cacheend = '\0';
+
+ mir_sntprintf(cachedirectorypath, SIZEOF(cachedirectorypath), _T("%s%S%S"), cachepath, MODULENAME, "cache\\");
+ CreateDirectory(cachedirectorypath, NULL);
+ mir_sntprintf(newcachepath, SIZEOF(newcachepath), _T("%s%S%S%s%S"), cachepath, MODULENAME, "cache\\", contactName, ".txt");
+ // file exists?
+ if ( _taccess(newcachepath, 0) != -1) {
+ FILE *pcachefile = _tfopen(newcachepath, _T("r"));
+ if (pcachefile != NULL) {
+ fclose(pcachefile);
+ DeleteFile(newcachepath);
+ db_set_s(hContact, MODULENAME, CACHE_FILE_KEY, "");
+ }
+ }
+ return 0;
}
-/************************/
-/************************/
+/*****************************************************************************/
INT_PTR OpenCacheDir(WPARAM wParam, LPARAM lParam)
{
- char cachepath[MAX_PATH];
- char cachedirectorypath[MAX_PATH];
- char*cacheend;
- DIR *pdir = NULL;
-
-
- //GET NAME FOR CACHE
- GetModuleFileName(hInst, cachepath, sizeof(cachepath));
- cacheend = strrchr(cachepath, '\\');
- cacheend++;
- *cacheend = '\0';
-
- _snprintf(cachedirectorypath, sizeof(cachedirectorypath), "%s%s%s%s", cachepath, MODULENAME, "cache\\", cacheend);
-
- if((pdir = opendir(cachedirectorypath)) == NULL)
- {
- WErrorPopup("ERROR", Translate("Cache folder does not exist."));
- return 0;
- }
-
- ShellExecute(NULL, "open", cachedirectorypath, NULL, NULL, SW_SHOWNORMAL);
-
- return 0;
+ //GET NAME FOR CACHE
+ TCHAR cachepath[MAX_PATH], cachedirectorypath[MAX_PATH];
+ GetModuleFileName(hInst, cachepath, sizeof(cachepath));
+ TCHAR *cacheend = _tcsrchr(cachepath, '\\');
+ cacheend++;
+ *cacheend = '\0';
+
+ mir_sntprintf(cachedirectorypath, SIZEOF(cachedirectorypath), _T("%s%S%S%s"), cachepath, MODULENAME, "cache\\", cacheend);
+
+ if( _taccess(cachedirectorypath, 0) != 0)
+ WErrorPopup("ERROR", TranslateT("Cache folder does not exist."));
+ else
+ ShellExecute(NULL, _T("open"), cachedirectorypath, NULL, NULL, SW_SHOWNORMAL);
+ return 0;
}
-/************************/
-/************************/
+
+/*****************************************************************************/
INT_PTR PingWebsiteMenuCommand(WPARAM wParam, LPARAM lParam)
{
- DBVARIANT dbv;
- char url[300];
- static char *Newnick;
- static char *Oldnick;
- char*Nend;
- char Cnick[255];
- FILE *pfile = NULL;
-
- if ((pfile = fopen("psite.bat", "r")) == NULL)
- {
- WErrorPopup("ERROR", Translate("Missing \"psite.bat\" file."));
- return 0;
- }
-
- ZeroMemory(&Cnick, sizeof(Cnick));
- ZeroMemory(&url, sizeof(url));
-
- DBGetContactSetting((HANDLE) wParam, MODULENAME, "URL", &dbv);
- wsprintf(url, "%s", dbv.pszVal);
- DBFreeVariant(&dbv);
-
- strncpy(Cnick, url, sizeof(Cnick));
- Oldnick = strdup(Cnick);
-
- /**/
- if ((strstr(Cnick, "://")) != 0)
- {
- Oldnick = strstr(Cnick, "://");
- Oldnick = Oldnick + 3;
- } else if ((strstr(Cnick, "://")) == 0)
- {
- strcpy(Oldnick, Cnick);
- }
-
- Newnick = strdup(Oldnick);
- if (strchr(Newnick, '/'))
- {
- Nend = strchr(Newnick, '/');
- *Nend = '\0';
- }
-
- //MessageBox(NULL, Newnick, MODULENAME, MB_OK);
-
- ShellExecute(NULL, "open", "psite.bat", Newnick, NULL, SW_HIDE);
-
-
- return 0;
+ FILE *pfile = fopen("psite.bat", "r");
+ if (pfile == NULL) {
+ WErrorPopup("ERROR", TranslateT("Missing \"psite.bat\" file."));
+ return 0;
+ }
+
+ ptrT url( db_get_tsa((HANDLE) wParam, MODULENAME, "URL"));
+ if (url == NULL)
+ return 0;
+
+ TCHAR Cnick[200], *Oldnick;
+ _tcsncpy(Cnick, url, sizeof(Cnick));
+ if ((Oldnick = _tcsstr(Cnick, _T("://"))) != 0)
+ Oldnick += 3;
+ else
+ Oldnick = Cnick;
+
+ TCHAR *Nend = _tcschr(Oldnick, '/');
+ if (Nend) *Nend = '\0';
+
+ ShellExecute(NULL, _T("open"), _T("psite.bat"), Oldnick, NULL, SW_HIDE);
+ return 0;
}
-/************************/
-
-/************************/
+/*****************************************************************************/
INT_PTR StpPrcssMenuCommand(WPARAM wParam, LPARAM lParam)
{
- DBVARIANT dbv;
-
- db_set_b((HANDLE) wParam, MODULENAME, STOP_KEY, 1);
-
- return 0;
+ db_set_b((HANDLE)wParam, MODULENAME, STOP_KEY, 1);
+ return 0;
}
-/************************/
-
-
//=======================================================
// GetCaps
// =======================================================
-int GetCaps(WPARAM wParam, LPARAM lParam)
+INT_PTR GetCaps(WPARAM wParam, LPARAM lParam)
{
- int ret = 0;
-
- if (wParam == PFLAGNUM_1)
- ret = PF1_BASICSEARCH | PF1_ADDSEARCHRES | PF1_VISLIST;
-
- if (wParam == PFLAGNUM_2)
- {
- if (!(db_get_b(NULL, MODULENAME, HIDE_STATUS_ICON_KEY, 0)))
- return PF2_ONLINE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_LIGHTDND | PF2_HEAVYDND; // add
- // the
- // possible
- // statuses here
-
- }
- if (wParam == PFLAG_UNIQUEIDTEXT)
- ret = (int) Translate("Site URL");
-
- if (wParam == PFLAGNUM_3)
- ret = 0;
-
-
- if (wParam == PFLAGNUM_5)
- ret = PF2_INVISIBLE|PF2_SHORTAWAY|PF2_LONGAWAY|PF2_LIGHTDND|PF2_HEAVYDND|PF2_FREECHAT|
- PF2_OUTTOLUNCH|PF2_ONTHEPHONE;
-
- if (wParam == PFLAG_UNIQUEIDSETTING)
- ret = (int) "PreserveName";
-
- return ret;
+ if (wParam == PFLAGNUM_1)
+ return PF1_BASICSEARCH | PF1_ADDSEARCHRES | PF1_VISLIST;
+
+ if (wParam == PFLAGNUM_2)
+ if (!(db_get_b(NULL, MODULENAME, HIDE_STATUS_ICON_KEY, 0)))
+ return PF2_ONLINE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_LIGHTDND | PF2_HEAVYDND; // add
+
+ if (wParam == PFLAG_UNIQUEIDTEXT)
+ return (INT_PTR)Translate("Site URL");
+
+ if (wParam == PFLAGNUM_3)
+ return 0;
+
+ if (wParam == PFLAGNUM_5)
+ return PF2_INVISIBLE|PF2_SHORTAWAY|PF2_LONGAWAY|PF2_LIGHTDND|PF2_HEAVYDND|PF2_FREECHAT|PF2_OUTTOLUNCH|PF2_ONTHEPHONE;
+
+ if (wParam == PFLAG_UNIQUEIDSETTING)
+ return (INT_PTR)"PreserveName";
+
+ return 0;
}
-//=======================================================
// =======================================================
// GetName
// =======================================================
-int GetName(WPARAM wParam, LPARAM lParam)
+
+INT_PTR GetName(WPARAM wParam, LPARAM lParam)
{
- lstrcpyn((char *) lParam, MODULENAME, wParam);
- return 0;
+ lstrcpynA((char*) lParam, MODULENAME, wParam);
+ return 0;
}
+
//=======================================================
// SetStatus
// =======================================================
-int SetStatus(WPARAM wParam, LPARAM lParam)
+
+INT_PTR SetStatus(WPARAM wParam, LPARAM lParam)
{
- int oldStatus;
- DBVARIANT dbv;
-
- oldStatus = bpStatus;
- char*szProto;
- HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
-
- 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 (DBGetContactSetting(NULL, MODULENAME, "FirstTime", &dbv))
- {
- while (hContact)
- {
- szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0);
- if (szProto != NULL && !lstrcmp(MODULENAME, szProto))
- {
- db_set_w(hContact, MODULENAME, "Status", ID_STATUS_ONLINE);
- }
- hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0);
- }
- if (DBGetContactSetting(NULL, MODULENAME, "FirstTime", &dbv))
- db_set_b(NULL, MODULENAME, "FirstTime", 1);
- }
- DBFreeVariant(&dbv);
- /**/
-
- if (bpStatus == ID_STATUS_OFFLINE)
- db_set_b(NULL, MODULENAME, OFFLINE_STATUS, 1);
- else
- db_set_b(NULL, MODULENAME, OFFLINE_STATUS, 0);
-
- return 0;
+ 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 ( db_get_b(NULL, MODULENAME, "FirstTime", 100) == 100) {
+ for (HANDLE hContact = db_find_first(MODULENAME); hContact != NULL; hContact = db_find_next(hContact, MODULENAME))
+ db_set_w(hContact, MODULENAME, "Status", ID_STATUS_ONLINE);
+
+ db_set_b(NULL, MODULENAME, "FirstTime", 1);
+ }
+
+ db_set_b(NULL, MODULENAME, OFFLINE_STATUS, bpStatus == ID_STATUS_OFFLINE);
+ return 0;
}
+
//=======================================================
// GetStatus
// =======================================================
-int GetStatus(WPARAM wParam, LPARAM lParam)
+INT_PTR GetStatus(WPARAM wParam, LPARAM lParam)
{
-
- if (bpStatus == ID_STATUS_ONLINE)
- return ID_STATUS_ONLINE;
- else if (bpStatus == ID_STATUS_AWAY)
- return ID_STATUS_AWAY;
- else if (bpStatus == ID_STATUS_NA)
- return ID_STATUS_NA;
- else if (bpStatus == ID_STATUS_OCCUPIED)
- return ID_STATUS_OCCUPIED;
- else if (bpStatus == ID_STATUS_DND)
- return ID_STATUS_DND;
- else
- return ID_STATUS_OFFLINE;
-
+ 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 BPLoadIcon(WPARAM wParam, LPARAM lParam)
+INT_PTR BPLoadIcon(WPARAM wParam, LPARAM lParam)
{
- UINT id;
-
- switch (wParam & 0xFFFF)
- {
- case PLI_PROTOCOL:
- id = IDI_SITE;
- break;
- default:
- return (int) (HICON) NULL;
- }
- return (int) LoadImage(hInst, MAKEINTRESOURCE(id), IMAGE_ICON, GetSystemMetrics(wParam & PLIF_SMALL ? SM_CXSMICON : SM_CXICON), GetSystemMetrics(wParam & PLIF_SMALL ? SM_CYSMICON : SM_CYICON), 0);
+ UINT id;
+
+ switch (wParam & 0xFFFF) {
+ case PLI_PROTOCOL:
+ id = IDI_SITE;
+ break;
+ default:
+ return 0;
+ }
+ return (INT_PTR)LoadImage(hInst, 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(void *pszNick)
{
- PROTOSEARCHRESULT psr;
-
- ZeroMemory(&psr, sizeof(psr));
- psr.cbSize = sizeof(psr);
- psr.nick = (char *) pszNick;
- //
+ PROTOSEARCHRESULT psr = { sizeof(psr) };
+ psr.nick = (TCHAR*) 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);
+ // 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;
+ // exit the search
+ searchId = -1;
}
-/*******************/
-
-/*******************/
-int BasicSearch(WPARAM wParam, LPARAM lParam)
+INT_PTR BasicSearch(WPARAM wParam, LPARAM lParam)
{
- static char buf[300];
-
+ static TCHAR buf[300];
- if (lParam)
- lstrcpyn(buf, (const char *) lParam, 256);
- //
+ if (lParam)
+ lstrcpyn(buf, (const TCHAR*) lParam, 256);
- if (searchId != -1)
- return 0; // only one search at a time
+ if (searchId != -1)
+ return 0; // only one search at a time
- lstrcpyn(sID, (char *) lParam, sizeof(sID));
- searchId = 1;
- // create a thread for the ID search
- forkthread(BasicSearchTimerProc, 0, &buf);
+ lstrcpyn(sID, (TCHAR*)lParam, SIZEOF(sID));
+ searchId = 1;
- return searchId;
+ // create a thread for the ID search
+ mir_forkthread(BasicSearchTimerProc, &buf);
+ return searchId;
}
-/*******************/
-/*******************/
-int AddToList(WPARAM wParam, LPARAM lParam)
+/*****************************************************************************/
+INT_PTR AddToList(WPARAM wParam, LPARAM lParam)
{
- PROTOSEARCHRESULT *psr = (PROTOSEARCHRESULT *) lParam;
- DBVARIANT dbv;
- static char *Newnick;
- static char *Oldnick;
- char*Nend;
- char Cnick[255];
- int sameurl = 0;
- int samename = 0;
-
-
- ZeroMemory(&Cnick, sizeof(Cnick));
-
-
- // search for existing contact
- HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
- HANDLE hContact2 = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
- char*szProto;
-
-
-
-
-
- while (hContact != NULL)
- {
- szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0);
- // check if it is a webview contact
- if (szProto != NULL && !lstrcmp(MODULENAME, szProto))
- {
- // check ID to see if the contact already exist in the database
-
- if (!DBGetContactSetting(hContact, MODULENAME, "URL", &dbv))
- {
- if (!lstrcmpi(psr->nick, dbv.pszVal))
- {
- // 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))
- {
- DBDeleteContactSetting(hContact, "CList", "NotOnList");
- DBDeleteContactSetting(hContact, "CList", "Hidden");
- }
- DBFreeVariant(&dbv);
- }
- }
- DBFreeVariant(&dbv);
-
- }
- hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0);
- }
-
-
-
- if (psr->nick == NULL)
- {
- WErrorPopup("ERROR", Translate("Please select site in Find/Add Contacts..."));
- return;
- }
-
- // if contact with the same ID was not found, add it
- if (psr->cbSize != sizeof(PROTOSEARCHRESULT))
- return (int) (HANDLE) NULL;
- hContact = (HANDLE) CallService(MS_DB_CONTACT_ADD, 0, 0);
- CallService(MS_PROTO_ADDTOCONTACT, (WPARAM) hContact, (LPARAM) MODULENAME);
-
-
-/////////write to db
- db_set_b(hContact, MODULENAME, ON_TOP_KEY, 0);
- db_set_b(hContact, MODULENAME, DBLE_WIN_KEY, 1);
- db_set_s(hContact, MODULENAME, END_STRING_KEY, "");
- db_set_b(hContact, MODULENAME, RWSPACE_KEY, 1);
-
-
-
-
-//Convert url into a name for contact
-///
- if (psr->nick != NULL)
- strncpy(Cnick, psr->nick, sizeof(Cnick));// this crashes
-///
-
- Oldnick = strdup(Cnick);
-
-
- /**/
- if ((strstr(Cnick, "://")) != 0)
- {
- Oldnick = strstr(Cnick, "://");
- Oldnick = Oldnick + 3;
-
- } else if ((strstr(Cnick, "://")) == 0)
- {
- strcpy(Oldnick, Cnick);
-
- }
- if ((strstr(Oldnick, "www.")) != 0)
- {
- Newnick = strstr(Oldnick, "www.");
- Newnick = Newnick + 4;
- Nend = strchr(Newnick, '.');
- *Nend = '\0';
-
- } else if ((strstr(Oldnick, "WWW.")) != 0)
- {
- Newnick = strstr(Oldnick, "WWW.");
- Newnick = Newnick + 4;
- Nend = strchr(Newnick, '.');
- *Nend = '\0';
-
- } else
- {
-
- Newnick = strdup(Oldnick);
- if (strchr(Newnick, '.'))
- {
- Nend = strchr(Newnick, '.');
- *Nend = '\0';
-
- }
- }
-
-
- while (hContact2 != NULL)
- {
- szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact2, 0);
- // check if it is a webview contact
- if (szProto != NULL && !lstrcmp(MODULENAME, szProto))
- {
- // check ID to see if the contact already exist in the database
-
-
-
- if (!DBGetContactSetting(hContact2, MODULENAME, PRESERVE_NAME_KEY, &dbv))
- {
- if (!lstrcmpi(Newnick, dbv.pszVal))
- {
- // 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))
- {
- DBDeleteContactSetting(hContact2, "CList", "NotOnList");
- DBDeleteContactSetting(hContact2, "CList", "Hidden");
- }
- DBFreeVariant(&dbv);
- }
- }
- DBFreeVariant(&dbv);
-
- }
- hContact2 = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact2, 0);
- }
-
-
-
- if ((sameurl > 0) || (samename > 0)) // contact has the same url or name as another contact, add rand
- // num to name
-
- {
- int ranNum;
- char ranStr[7];
-
- srand((unsigned) time(NULL));
-
- ranNum = (int) 10000 *rand() / (RAND_MAX + 1.0);
-
- _snprintf(ranStr, sizeof(ranStr), "%d", ranNum);
- strcat(Newnick, ranStr);
- }
-//end convert
-
- db_set_s(hContact, "CList", "MyHandle", Newnick);
- db_set_s(hContact, MODULENAME, PRESERVE_NAME_KEY, Newnick);
- db_set_s(hContact, MODULENAME, "Nick", Newnick);
- db_set_b(hContact, MODULENAME, CLEAR_DISPLAY_KEY, 1);
- db_set_s(hContact, MODULENAME, START_STRING_KEY, "");
- db_set_s(hContact, MODULENAME, URL_KEY, psr->nick);
- db_set_s(hContact, MODULENAME, "Homepage", psr->nick);
- db_set_b(hContact, MODULENAME, U_ALLSITE_KEY, 1);
- db_set_w(hContact, MODULENAME, "Status", ID_STATUS_ONLINE);
-////////////////////////
-
-
-
- // ignore status change
- db_set_dw(hContact, "Ignore", "Mask", 8);
-
- Sleep(2);
-
- DBFreeVariant(&dbv);
-
-
- return (int) hContact;
+ PROTOSEARCHRESULT *psr = (PROTOSEARCHRESULT *) lParam;
+ DBVARIANT dbv;
+ TCHAR Cnick[255];
+ int sameurl = 0;
+ int samename = 0;
+
+ ZeroMemory(&Cnick, sizeof(Cnick));
+
+ // search for existing contact
+ HANDLE hContact;
+ for (hContact = db_find_first(MODULENAME); hContact != NULL; hContact = db_find_next(hContact, MODULENAME)) {
+ // check ID to see if the contact already exist in the database
+ if (!db_get_ts(hContact, MODULENAME, "URL", &dbv)) {
+ if (!lstrcmpi(psr->nick, dbv.ptszVal)) {
+ // 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);
+ }
+ }
+ db_free(&dbv);
+ }
+
+ if (psr->nick == NULL) {
+ WErrorPopup("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;
+
+ hContact = (HANDLE) CallService(MS_DB_CONTACT_ADD, 0, 0);
+ CallService(MS_PROTO_ADDTOCONTACT, (WPARAM) hContact, (LPARAM) MODULENAME);
+
+ /////////write to db
+ db_set_b(hContact, MODULENAME, ON_TOP_KEY, 0);
+ db_set_b(hContact, MODULENAME, DBLE_WIN_KEY, 1);
+ db_set_s(hContact, MODULENAME, END_STRING_KEY, "");
+ db_set_b(hContact, MODULENAME, RWSPACE_KEY, 1);
+
+ //Convert url into a name for contact
+ if (psr->nick != NULL)
+ _tcsncpy(Cnick, psr->nick, SIZEOF(Cnick));
+
+ TCHAR *Oldnick = _tcsstr(Cnick, _T("://"));
+ if (Oldnick != 0)
+ Oldnick += 3;
+ else
+ Oldnick = Cnick;
+
+ TCHAR *Newnick = _tcsstr(Oldnick, _T("www."));
+ if (Newnick != 0)
+ Newnick += 4;
+ else {
+ Newnick = _tcsstr(Oldnick, _T("WWW."));
+ if (Newnick != 0)
+ Newnick += 4;
+ else
+ Newnick = Oldnick;
+ }
+
+ TCHAR *Nend = _tcschr(Newnick, '.');
+ *Nend = '\0';
+
+ for (HANDLE hContact2 = db_find_first(MODULENAME); hContact2 != NULL; hContact2 = db_find_next(hContact2, MODULENAME)) {
+ if (!db_get_ts(hContact2, MODULENAME, PRESERVE_NAME_KEY, &dbv)) {
+ if (!lstrcmpi(Newnick, dbv.ptszVal)) {
+ // 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(NULL));
+
+ TCHAR ranStr[10];
+ _itot((int) 10000 *rand() / (RAND_MAX + 1.0), ranStr, 10);
+ _tcscat(Newnick, ranStr);
+ }
+ //end convert
+
+ db_set_ts(hContact, "CList", "MyHandle", Newnick);
+ db_set_ts(hContact, MODULENAME, PRESERVE_NAME_KEY, Newnick);
+ db_set_ts(hContact, MODULENAME, "Nick", Newnick);
+ db_set_b(hContact, MODULENAME, CLEAR_DISPLAY_KEY, 1);
+ db_set_s(hContact, MODULENAME, START_STRING_KEY, "");
+ db_set_ts(hContact, MODULENAME, URL_KEY, psr->nick);
+ db_set_ts(hContact, MODULENAME, "Homepage", psr->nick);
+ db_set_b(hContact, MODULENAME, U_ALLSITE_KEY, 1);
+ db_set_w(hContact, MODULENAME, "Status", ID_STATUS_ONLINE);
+
+ // ignore status change
+ db_set_dw(hContact, "Ignore", "Mask", 8);
+
+ Sleep(2);
+
+ db_free(&dbv);
+
+
+ return (int) hContact;
}
-/*******************/
-/*******************/
-int GetInfo(WPARAM wParam, LPARAM lParam)
+/*****************************************************************************/
+INT_PTR GetInfo(WPARAM wParam, LPARAM lParam)
{
- forkthread(AckFunc, 0, NULL);
- return 1;
+ mir_forkthread(AckFunc, NULL);
+ return 1;
}
-/*******************/
-/*******************/
+
+/*****************************************************************************/
void AckFunc(void *dummy)
{
- HANDLE hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDFIRST, 0, 0);
- char*szProto;
-
- while (hContact != NULL)
- {
- szProto = (char *) CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM) hContact, 0);
- //
- if (szProto != NULL && !lstrcmp(MODULENAME, szProto))
- ProtoBroadcastAck(MODULENAME, hContact, ACKTYPE_GETINFO, ACKRESULT_SUCCESS, (HANDLE) 1, 0);
- //
- hContact = (HANDLE) CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM) hContact, 0);
- }
-
+ for (HANDLE hContact = db_find_first(MODULENAME); hContact != NULL; hContact = db_find_next(hContact, MODULENAME))
+ ProtoBroadcastAck(MODULENAME, hContact, ACKTYPE_GETINFO, ACKRESULT_SUCCESS, (HANDLE)1, 0);
}
-/*******************/
-