diff options
author | George Hazan <ghazan@miranda.im> | 2018-11-14 16:53:52 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-11-14 16:53:52 +0300 |
commit | fea80908985f5f79d8e5a8eb17df57ee44054fcc (patch) | |
tree | 7ec69f525cb209f7805e61547908325528792511 | |
parent | 24cad0c352040cb469b63b0b5d4a0007a64cae3c (diff) |
WebView -> g_plugin
-rw-r--r-- | plugins/WebView/src/webview.cpp | 8 | ||||
-rw-r--r-- | plugins/WebView/src/webview_alerts.cpp | 125 | ||||
-rw-r--r-- | plugins/WebView/src/webview_datawnd.cpp | 128 | ||||
-rw-r--r-- | plugins/WebView/src/webview_services.cpp | 77 |
4 files changed, 167 insertions, 171 deletions
diff --git a/plugins/WebView/src/webview.cpp b/plugins/WebView/src/webview.cpp index 6e72610729..9f65d3e435 100644 --- a/plugins/WebView/src/webview.cpp +++ b/plugins/WebView/src/webview.cpp @@ -421,13 +421,13 @@ int OnTopMenuCommand(WPARAM, LPARAM, MCONTACT 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);
+ if (((g_plugin.getByte(singlecontact, ON_TOP_KEY))) && done == 0) {
+ g_plugin.setByte(singlecontact, 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);
+ if ((!(g_plugin.getByte(singlecontact, ON_TOP_KEY, 0))) && done == 0) {
+ g_plugin.setByte(singlecontact, ON_TOP_KEY, 1);
ontop = 1;
done = 1;
}
diff --git a/plugins/WebView/src/webview_alerts.cpp b/plugins/WebView/src/webview_alerts.cpp index 2f4ad8b34f..d7f52a6cab 100644 --- a/plugins/WebView/src/webview_alerts.cpp +++ b/plugins/WebView/src/webview_alerts.cpp @@ -30,13 +30,13 @@ int CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) case WM_COMMAND:
case WM_CONTEXTMENU:
MCONTACT hContact = PUGetContact(hWnd);
- ptrW url( g_plugin.getWStringA(hContact, URL_KEY));
+ ptrW url(g_plugin.getWStringA(hContact, URL_KEY));
if (message == WM_COMMAND) { // left click
- if(hContact != NULL) {
+ if (hContact != NULL) {
// open data window
- if ( g_plugin.getByte(LCLK_WINDOW_KEY, 0)) {
- NotifyEventHooks(hHookDisplayDataAlert, (int) hContact, 0);
+ if (g_plugin.getByte(LCLK_WINDOW_KEY, 0)) {
+ NotifyEventHooks(hHookDisplayDataAlert, (int)hContact, 0);
mir_forkthread(GetData, (void*)hContact);
PUDeletePopup(hWnd);
}
@@ -44,20 +44,20 @@ int CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) if (g_plugin.getByte(LCLK_WEB_PGE_KEY, 0)) {
Utils_OpenUrlW(url);
PUDeletePopup(hWnd);
- db_set_w(wParam, MODULENAME, "Status", ID_STATUS_ONLINE);
+ g_plugin.setWord(wParam, "Status", ID_STATUS_ONLINE);
}
// dismiss
if (g_plugin.getByte(LCLK_DISMISS_KEY, 1))
PUDeletePopup(hWnd);
- }
+ }
else if (hContact == NULL)
- PUDeletePopup(hWnd);
- }
+ PUDeletePopup(hWnd);
+ }
else if (message == WM_CONTEXTMENU) { // right click
- if (hContact != NULL) {
+ if (hContact != NULL) {
// open datA window
if (g_plugin.getByte(RCLK_WINDOW_KEY, 0)) {
- NotifyEventHooks(hHookDisplayDataAlert, (int) hContact, 0);
+ NotifyEventHooks(hHookDisplayDataAlert, (int)hContact, 0);
mir_forkthread(GetData, (void*)hContact);
PUDeletePopup(hWnd);
}
@@ -65,14 +65,14 @@ int CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) if (g_plugin.getByte(RCLK_WEB_PGE_KEY, 1)) {
Utils_OpenUrlW(url);
PUDeletePopup(hWnd);
- db_set_w(wParam, MODULENAME, "Status", ID_STATUS_ONLINE);
+ g_plugin.setWord(wParam, "Status", ID_STATUS_ONLINE);
}
// dismiss
- if ( g_plugin.getByte(RCLK_DISMISS_KEY, 0))
+ if (g_plugin.getByte(RCLK_DISMISS_KEY, 0))
PUDeletePopup(hWnd);
}
- else if(hContact == NULL)
- PUDeletePopup(hWnd);
+ else if (hContact == NULL)
+ PUDeletePopup(hWnd);
}
break;
}
@@ -97,48 +97,45 @@ int WAlertPopup(MCONTACT hContact, wchar_t *displaytext) /*****************************************************************************/
int WErrorPopup(MCONTACT hContact, wchar_t *textdisplay)
{
- NotifyEventHooks(hHookErrorPopup, hContact, (LPARAM) textdisplay);
+ NotifyEventHooks(hHookErrorPopup, hContact, (LPARAM)textdisplay);
return 0;
}
/*****************************************************************************/
int WAlertOSD(MCONTACT hContact, wchar_t *displaytext)
{
- NotifyEventHooks(hHookAlertOSD, hContact, (LPARAM) displaytext);
+ NotifyEventHooks(hHookAlertOSD, hContact, (LPARAM)displaytext);
return 0;
}
/*****************************************************************************/
-int PopupAlert(WPARAM wParam, LPARAM lParam)
+int PopupAlert(WPARAM hContact, LPARAM lParam)
{
POPUPDATAT ppd = { 0 };
- if( ((HANDLE)wParam) != nullptr) {
- DBVARIANT dbv;
- db_get_ws(wParam, MODULENAME, PRESERVE_NAME_KEY, &dbv);
- mir_wstrncpy(ppd.lptzContactName, dbv.pwszVal, _countof(ppd.lptzContactName));
- db_free(&dbv);
- }
- else mir_wstrcpy(ppd.lptzContactName, _A2W(MODULENAME));
+ if (hContact != 0)
+ mir_wstrncpy(ppd.lptzContactName, ptrW(g_plugin.getWStringA(hContact, PRESERVE_NAME_KEY)), _countof(ppd.lptzContactName));
+ else
+ mir_wstrcpy(ppd.lptzContactName, _A2W(MODULENAME));
- ppd.lchContact = wParam;
+ ppd.lchContact = hContact;
ppd.lchIcon = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_SITE));
wchar_t *displaytext = (wchar_t*)lParam;
- if ((mir_wstrlen(displaytext) == MAX_SECONDLINE) || (mir_wstrlen(displaytext) > MAX_SECONDLINE))
+ if ((mir_wstrlen(displaytext) == MAX_SECONDLINE) || (mir_wstrlen(displaytext) > MAX_SECONDLINE))
mir_snwprintf(ppd.lptzText, displaytext);
else if (mir_wstrlen(displaytext) < MAX_SECONDLINE)
mir_snwprintf(ppd.lptzText, displaytext);
- if ( g_plugin.getByte(POP_USECUSTCLRS_KEY, 0)) {
+ if (g_plugin.getByte(POP_USECUSTCLRS_KEY, 0)) {
ppd.colorBack = g_plugin.getDword(POP_BG_CLR_KEY, Def_color_bg);
ppd.colorText = g_plugin.getDword(POP_TXT_CLR_KEY, Def_color_txt);
}
- else if ( g_plugin.getByte(POP_USEWINCLRS_KEY, 0)) {
+ else if (g_plugin.getByte(POP_USEWINCLRS_KEY, 0)) {
ppd.colorBack = GetSysColor(COLOR_BTNFACE);
ppd.colorText = GetSysColor(COLOR_WINDOWTEXT);
}
- else if ( g_plugin.getByte(POP_USESAMECLRS_KEY, 1)) {
+ else if (g_plugin.getByte(POP_USESAMECLRS_KEY, 1)) {
ppd.colorBack = BackgoundClr;
ppd.colorText = TextClr;
}
@@ -191,7 +188,7 @@ int ErrorMsgs(WPARAM wParam, LPARAM lParam) mir_snwprintf(newdisplaytext, L"%s\n%s", ptszContactName, displaytext);
PUShowMessageT(newdisplaytext, SM_WARNING);
}
- else if ( ServiceExists("OSD/Announce") && g_plugin.getByte(ERROR_POPUP_KEY, 0)) {
+ else if (ServiceExists("OSD/Announce") && g_plugin.getByte(ERROR_POPUP_KEY, 0)) {
mir_snwprintf(newdisplaytext, L"%s: %s", ptszContactName, TranslateW(displaytext));
CallService("OSD/Announce", (WPARAM)newdisplaytext, 0);
}
@@ -216,7 +213,7 @@ void SaveToFile(MCONTACT hContact, char *truncated) db_free(&dbv);
}
- if ( g_plugin.getString(hContact, FILE_KEY, &dbv))
+ if (g_plugin.getString(hContact, FILE_KEY, &dbv))
return;
FILE *pfile = fopen(dbv.pszVal, mode);
@@ -280,7 +277,7 @@ int ProcessAlerts(MCONTACT hContact, char *truncated, char *tstr, char *contactn Sleep(1000);
WAlertPopup(hContact, TranslateT("Start/end strings not found or strings not set."));
// contactlist name//
- if ( g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
+ if (g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
db_set_s(hContact, "CList", "MyHandle", tstr);
}
else if (alertIndex == 1) { // log to file
@@ -313,10 +310,10 @@ int ProcessAlerts(MCONTACT hContact, char *truncated, char *tstr, char *contactn SaveToFile(hContact, tempraw);
db_free(&tdbv);
- if ( g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
+ if (g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
db_set_s(hContact, "CList", "MyHandle", tstr);
}
- }
+ }
else if (alertIndex == 3) {
WAlertOSD(hContact, TranslateT("Alert start/end strings not found or strings not set."));
if (g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
@@ -325,7 +322,7 @@ int ProcessAlerts(MCONTACT hContact, char *truncated, char *tstr, char *contactn else if (eventIndex == 2) {
WDisplayDataAlert(hContact);
- if ( g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
+ if (g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
db_set_s(hContact, "CList", "MyHandle", tstr);
HWND hwndDlg = (WindowList_Find(hWindowList, hContact));
@@ -353,7 +350,7 @@ int ProcessAlerts(MCONTACT hContact, char *truncated, char *tstr, char *contactn WAlertPopup(hContact, displaystring);
// contactlist name//
- if ( g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
+ if (g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
db_set_s(hContact, "CList", "MyHandle", tstr);
} //
else if (alertIndex == 1) {
@@ -384,7 +381,7 @@ int ProcessAlerts(MCONTACT hContact, char *truncated, char *tstr, char *contactn SaveToFile(hContact, tempraw);
db_free(&tdbv);
- if ( g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
+ if (g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
db_set_s(hContact, "CList", "MyHandle", tstr);
}
}
@@ -393,13 +390,13 @@ int ProcessAlerts(MCONTACT hContact, char *truncated, char *tstr, char *contactn WAlertOSD(hContact, displaystring);
// contactlist name//
- if ( g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
+ if (g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
db_set_s(hContact, "CList", "MyHandle", tstr);
}
else if (alertIndex == 2) {
WDisplayDataAlert(hContact);
// contactlist name//
- if ( g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
+ if (g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
db_set_s(hContact, "CList", "MyHandle", tstr);
HWND hwndDlg = WindowList_Find(hWindowList, hContact);
@@ -422,7 +419,7 @@ int ProcessAlerts(MCONTACT hContact, char *truncated, char *tstr, char *contactn CreateDirectory(cachedirectorypath, nullptr);
mir_snwprintf(newcachepath, L"%s%S%S%S%S", cachepath, MODULENAME, "cache\\", contactname, ".txt");
// file exists?
- if ( _waccess(newcachepath, 0) != -1) {
+ if (_waccess(newcachepath, 0) != -1) {
if ((pcachefile = _wfopen(newcachepath, L"r")) == nullptr)
WErrorPopup((UINT_PTR)contactname, TranslateT("Cannot read from file"));
else {
@@ -451,13 +448,13 @@ int ProcessAlerts(MCONTACT hContact, char *truncated, char *tstr, char *contactn if (alertIndex == 0) { // popup
WAlertPopup(hContact, TranslateT("The web page has changed."));
// contactlist name//
- if ( g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
+ if (g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
db_set_s(hContact, "CList", "MyHandle", tstr);
}
else if (alertIndex == 3) { // osd
WAlertOSD(hContact, TranslateT("The web page has changed."));
// contactlist name//
- if ( g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
+ if (g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
db_set_s(hContact, "CList", "MyHandle", tstr);
}
else if (alertIndex == 1) { // log
@@ -490,14 +487,14 @@ int ProcessAlerts(MCONTACT hContact, char *truncated, char *tstr, char *contactn SaveToFile(hContact, tempraw);
db_free(&tdbv);
// contactlist name//
- if ( g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
+ if (g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
db_set_s(hContact, "CList", "MyHandle", tstr);
}
}
else if (alertIndex == 2) { // window
WDisplayDataAlert(hContact);
// contactlist name//
- if ( g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
+ if (g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
db_set_s(hContact, "CList", "MyHandle", tstr);
}
else MessageBox(nullptr, TranslateT("Unknown alert type."), _A2W(MODULENAME), MB_OK);
@@ -563,7 +560,7 @@ int ProcessAlerts(MCONTACT hContact, char *truncated, char *tstr, char *contactn Sleep(1000);
WAlertPopup(hContact, TranslateT("Alert start/end strings not found or strings not set."));
// contactlist name//
- if ( g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
+ if (g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
db_set_s(hContact, "CList", "MyHandle", tstr);
}
else if (alertIndex == 1) { // LOG
@@ -596,21 +593,21 @@ int ProcessAlerts(MCONTACT hContact, char *truncated, char *tstr, char *contactn SaveToFile(hContact, tempraw);
db_free(&tdbv);
// contactlist name
- if ( g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
+ if (g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
db_set_s(hContact, "CList", "MyHandle", tstr);
}
}
- }
+ }
else if (alertIndex == 3) { // osd
WAlertOSD(hContact, TranslateT("Alert start/end strings not found or strings not set."));
// contactlist name//
- if ( g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
+ if (g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
db_set_s(hContact, "CList", "MyHandle", tstr);
}
else if (alertIndex == 2) { // window
WDisplayDataAlert(hContact);
// contactlist name//
- if ( g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
+ if (g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
db_set_s(hContact, "CList", "MyHandle", tstr);
HWND hwndDlg = (WindowList_Find(hWindowList, hContact));
@@ -634,7 +631,7 @@ int ProcessAlerts(MCONTACT hContact, char *truncated, char *tstr, char *contactn CreateDirectory(cachedirectorypath, nullptr);
mir_snwprintf(newcachepath, L"%s%S%S%S%S", cachepath, MODULENAME, "cache\\", contactname, ".txt");
// file exists?
- if ( _waccess(newcachepath, 0) != -1) {
+ if (_waccess(newcachepath, 0) != -1) {
if ((pcachefile = _wfopen(newcachepath, L"r")) == nullptr)
WErrorPopup((UINT_PTR)contactname, TranslateT("Cannot read from file"));
else {
@@ -662,13 +659,13 @@ int ProcessAlerts(MCONTACT hContact, char *truncated, char *tstr, char *contactn if (alertIndex == 0) { // popup
WAlertPopup(hContact, TranslateT("Specific part of the web page has changed."));
// contactlist name//
- if ( g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
+ if (g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
db_set_s(hContact, "CList", "MyHandle", tstr);
}
else if (alertIndex == 3) { // osd
WAlertOSD(hContact, TranslateT("Specific part of the web page has changed."));
// contactlist name//
- if ( g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
+ if (g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
db_set_s(hContact, "CList", "MyHandle", tstr);
}
else if (alertIndex == 1) { // log to file
@@ -700,14 +697,14 @@ int ProcessAlerts(MCONTACT hContact, char *truncated, char *tstr, char *contactn SaveToFile(hContact, tempraw);
db_free(&tdbv);
// contactlist name
- if ( g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
+ if (g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
db_set_s(hContact, "CList", "MyHandle", tstr);
}
}
else if (alertIndex == 2) { // window
WDisplayDataAlert(hContact);
// contactlist name//
- if ( g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
+ if (g_plugin.getByte(hContact, APND_DATE_NAME_KEY, 0))
db_set_s(hContact, "CList", "MyHandle", tstr);
}
else MessageBox(nullptr, TranslateT("Unknown alert type."), _A2W(MODULENAME), MB_OK);
@@ -720,7 +717,7 @@ int ProcessAlerts(MCONTACT hContact, char *truncated, char *tstr, char *contactn //if always log to file option is enabled do this
if (wasAlert && alertIndex != 1) { // dont do for log to file alert
- if ( g_plugin.getByte(hContact, ALWAYS_LOG_KEY, 0)) {
+ if (g_plugin.getByte(hContact, ALWAYS_LOG_KEY, 0)) {
if (!g_plugin.getString(hContact, FILE_KEY, &tdbv)) {
int AmountWspcRem = 0;
@@ -760,13 +757,13 @@ int ProcessAlerts(MCONTACT hContact, char *truncated, char *tstr, char *contactn int DataWndAlertCommand(WPARAM wParam, LPARAM)
{
MCONTACT hContact = wParam;
- if ( WindowList_Find(hWindowList, hContact))
+ if (WindowList_Find(hWindowList, hContact))
return 0;
HWND hwndDlg = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_DISPLAY_DATA), nullptr, DlgProcDisplayData, hContact);
HWND hTopmost = g_plugin.getByte(hContact, ON_TOP_KEY, 0) ? HWND_TOPMOST : HWND_NOTOPMOST;
- SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) ((HICON) LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDI_STICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)));
- if ( g_plugin.getByte(SAVE_INDIVID_POS_KEY, 0))
+ SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM)((HICON)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDI_STICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0)));
+ if (g_plugin.getByte(SAVE_INDIVID_POS_KEY, 0))
SetWindowPos(hwndDlg, hTopmost,
g_plugin.getDword(hContact, "WVx", 100), // Xposition,
g_plugin.getDword(hContact, "WVy", 100), // Yposition,
@@ -788,7 +785,7 @@ void ReadFromFile(void *param) DBVARIANT dbv;
char truncated[MAXSIZE1];
int AmountWspcRem = 0;
- int fileexists = 0;
+ int fileexists = 0;
HWND hwndDlg = WindowList_Find(hWindowList, hContact);
@@ -798,23 +795,23 @@ void ReadFromFile(void *param) db_free(&dbv);
}
- if ( g_plugin.getString(hContact, CACHE_FILE_KEY, &dbv))
+ if (g_plugin.getString(hContact, CACHE_FILE_KEY, &dbv))
return;
FILE *pfile;
if ((pfile = fopen(dbv.pszVal, "r")) == nullptr) {
SendToRichEdit(hwndDlg, Translate("Cannot read from cache file"), TextClr, BackgoundClr);
fileexists = 0;
- }
+ }
else {
fread(truncated, sizeof(truncated), 1, pfile);
fclose(pfile);
- fileexists =1;
+ fileexists = 1;
}
db_free(&dbv);
- if(fileexists) {
+ if (fileexists) {
CodetoSymbol(truncated);
Sleep(100); // avoid 100% CPU
@@ -837,6 +834,6 @@ void ReadFromFile(void *param) Removewhitespace(truncated);
SendToRichEdit(hwndDlg, truncated, TextClr, BackgoundClr);
- SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Loaded from cache"));
+ SetDlgItemText(hwndDlg, IDC_STATUSBAR, TranslateT("Loaded from cache"));
}
}
diff --git a/plugins/WebView/src/webview_datawnd.cpp b/plugins/WebView/src/webview_datawnd.cpp index fba496f197..f87b88a16e 100644 --- a/plugins/WebView/src/webview_datawnd.cpp +++ b/plugins/WebView/src/webview_datawnd.cpp @@ -1,23 +1,23 @@ /*
-* 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.
*/
#include "stdafx.h"
@@ -39,7 +39,7 @@ INT_PTR CALLBACK DlgProcFind(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara TranslateDialogDefault(hwndDlg);
SetWindowLongPtr(hwndDlg, GWLP_USERDATA, lParam);
SetWindowText(hwndDlg, TranslateT("Find"));
- SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM) LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_FIND)));
+ SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_FIND)));
return TRUE;
case WM_COMMAND:
@@ -98,7 +98,7 @@ INT_PTR CALLBACK DlgProcFind(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara endsel = loc + (int)mir_strlen(NewSearchstr);
}
- CHARRANGE sel2 = {startsel, endsel};
+ CHARRANGE sel2 = { startsel, endsel };
SendDlgItemMessage(ParentHwnd, IDC_DATA, EM_EXSETSEL, 0, (LPARAM)&sel2);
SetFocus(GetDlgItem(ParentHwnd, IDC_DATA));
}
@@ -129,8 +129,8 @@ static MCONTACT FindContactByUrl(HWND hwndDlg) GetWindowText(hwndDlg, titlebartxt, _countof(titlebartxt));
for (auto &hContact : Contacts(MODULENAME)) {
- ptrW db1( g_plugin.getWStringA(hContact, URL_KEY));
- ptrW db2( g_plugin.getWStringA(hContact, PRESERVE_NAME_KEY));
+ ptrW db1(g_plugin.getWStringA(hContact, URL_KEY));
+ ptrW db2(g_plugin.getWStringA(hContact, PRESERVE_NAME_KEY));
if (!mir_wstrcmp(urltext, db1) && !mir_wstrcmp(titlebartxt, db2)) {
contactcount++;
@@ -157,58 +157,58 @@ INT_PTR CALLBACK DlgProcDisplayData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA {
MCONTACT hContact2 = lParam;
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR) hContact2);
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)hContact2);
WindowList_Add(hWindowList, hwndDlg, hContact2);
url[0] = '\0';
- if (!db_get_ws(hContact2, MODULENAME, URL_KEY, &dbv)) {
+ if (!g_plugin.getWString(hContact2, URL_KEY, &dbv)) {
wcsncpy_s(url, dbv.pwszVal, _TRUNCATE);
db_free(&dbv);
}
SetDlgItemText(hwndDlg, IDC_OPEN_URL, FixButtonText(url, _countof(url)));
char preservename[100];
- if (!db_get_s(hContact2, MODULENAME, PRESERVE_NAME_KEY, &dbv)) {
+ if (!g_plugin.getString(hContact2, PRESERVE_NAME_KEY, &dbv)) {
strncpy_s(preservename, _countof(preservename), dbv.pszVal, _TRUNCATE);
db_free(&dbv);
}
else preservename[0] = 0;
SetWindowTextA(hwndDlg, preservename);
- SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM) LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_SITE)));
+ SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM)LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_SITE)));
// //////
COLORREF colour = BackgoundClr;
COLORREF txtcolor;
SendDlgItemMessage(hwndDlg, IDC_DATA, EM_SETBKGNDCOLOR, 0, colour);
- SendDlgItemMessage(hwndDlg, IDC_UPDATE_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDI_UPDATE), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0));
- SendDlgItemMessage(hwndDlg, IDC_UPDATE_BUTTON, BUTTONADDTOOLTIP, (WPARAM) TranslateT("Update data"), BATF_UNICODE);
+ SendDlgItemMessage(hwndDlg, IDC_UPDATE_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDI_UPDATE), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0));
+ SendDlgItemMessage(hwndDlg, IDC_UPDATE_BUTTON, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Update data"), BATF_UNICODE);
- SendDlgItemMessage(hwndDlg, IDC_FIND_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDI_FIND), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0));
- SendDlgItemMessage(hwndDlg, IDC_FIND_BUTTON, BUTTONADDTOOLTIP, (WPARAM) TranslateT("Find"), BATF_UNICODE);
+ SendDlgItemMessage(hwndDlg, IDC_FIND_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDI_FIND), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0));
+ SendDlgItemMessage(hwndDlg, IDC_FIND_BUTTON, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Find"), BATF_UNICODE);
- SendDlgItemMessage(hwndDlg, IDC_OPTIONS_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDI_OPTIONS), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0));
- SendDlgItemMessage(hwndDlg, IDC_OPTIONS_BUTTON, BUTTONADDTOOLTIP, (WPARAM) TranslateT("Contact options"), BATF_UNICODE);
+ SendDlgItemMessage(hwndDlg, IDC_OPTIONS_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDI_OPTIONS), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0));
+ SendDlgItemMessage(hwndDlg, IDC_OPTIONS_BUTTON, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Contact options"), BATF_UNICODE);
- SendDlgItemMessage(hwndDlg, IDC_ALERT_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDI_ALERT), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0));
- SendDlgItemMessage(hwndDlg, IDC_ALERT_BUTTON, BUTTONADDTOOLTIP, (WPARAM) TranslateT("Alert options"), BATF_UNICODE);
+ SendDlgItemMessage(hwndDlg, IDC_ALERT_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDI_ALERT), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0));
+ SendDlgItemMessage(hwndDlg, IDC_ALERT_BUTTON, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Alert options"), BATF_UNICODE);
- SendDlgItemMessage(hwndDlg, IDC_STOP, BM_SETIMAGE, IMAGE_ICON, (LPARAM) LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDI_STOP), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0));
- SendDlgItemMessage(hwndDlg, IDC_STOP, BUTTONADDTOOLTIP, (WPARAM) TranslateT("Stop processing"), BATF_UNICODE);
+ SendDlgItemMessage(hwndDlg, IDC_STOP, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDI_STOP), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0));
+ SendDlgItemMessage(hwndDlg, IDC_STOP, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Stop processing"), BATF_UNICODE);
- SendDlgItemMessage(hwndDlg, IDC_OPEN_URL, BUTTONADDTOOLTIP, (WPARAM) TranslateT("Click here to open this URL in a browser window."), BATF_UNICODE);
+ SendDlgItemMessage(hwndDlg, IDC_OPEN_URL, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Click here to open this URL in a browser window."), BATF_UNICODE);
- if (!db_get_b(hContact2, MODULENAME, ON_TOP_KEY, 0)) {
- SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDI_UNSTICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0));
- SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BUTTONADDTOOLTIP, (WPARAM) TranslateT("Stick to the front"), BATF_UNICODE);
+ if (!g_plugin.getByte(hContact2, ON_TOP_KEY)) {
+ SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDI_UNSTICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0));
+ SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Stick to the front"), BATF_UNICODE);
}
else {
- SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM) LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDI_STICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0));
- SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BUTTONADDTOOLTIP, (WPARAM) TranslateT("Disable stick to the front"), BATF_UNICODE);
+ SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BM_SETIMAGE, IMAGE_ICON, (LPARAM)LoadImage(g_plugin.getInst(), MAKEINTRESOURCE(IDI_STICK), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0));
+ SendDlgItemMessage(hwndDlg, IDC_STICK_BUTTON, BUTTONADDTOOLTIP, (WPARAM)TranslateT("Disable stick to the front"), BATF_UNICODE);
}
- SendDlgItemMessage(hwndDlg, IDC_DATA, WM_SETFONT, (WPARAM) h_font, 1);
+ SendDlgItemMessage(hwndDlg, IDC_DATA, WM_SETFONT, (WPARAM)h_font, 1);
txtcolor = TextClr;
@@ -231,7 +231,7 @@ INT_PTR CALLBACK DlgProcDisplayData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA SendDlgItemMessage(hwndDlg, IDC_OPEN_URL, BUTTONSETASFLATBTN, 0, 0);
HDC hdc = GetDC(GetDlgItem(hwndDlg, IDC_STATUSBAR));
- SelectObject(hdc, (HFONT) SendDlgItemMessage(hwndDlg, IDC_STATUSBAR, WM_GETFONT, 0, 0));
+ SelectObject(hdc, (HFONT)SendDlgItemMessage(hwndDlg, IDC_STATUSBAR, WM_GETFONT, 0, 0));
SIZE textSize;
GetTextExtentPoint32(hdc, tszSizeString, _countof(tszSizeString), &textSize);
int partWidth[2] = { textSize.cx, -1 };
@@ -240,23 +240,23 @@ INT_PTR CALLBACK DlgProcDisplayData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA SendDlgItemMessage(hwndDlg, IDC_STATUSBAR, SB_SETPARTS, _countof(partWidth), (LPARAM)partWidth);
SendDlgItemMessage(hwndDlg, IDC_STATUSBAR, SB_SETTEXT, 1 | SBT_OWNERDRAW, 0);
- if ( g_plugin.getByte(SAVE_INDIVID_POS_KEY, 0))
+ if (g_plugin.getByte(SAVE_INDIVID_POS_KEY, 0))
Utils_RestoreWindowPosition(hwndDlg, hContact2, MODULENAME, "WV");
}
break;
case WM_NOTIFY:
- switch (((NMHDR *) lParam)->code) {
+ switch (((NMHDR *)lParam)->code) {
case EN_MSGFILTER:
- switch (((MSGFILTER *) lParam)->msg) {
+ switch (((MSGFILTER *)lParam)->msg) {
case WM_RBUTTONUP:
{
POINT pt;
- CHARRANGE sel, all = {0, -1};
+ CHARRANGE sel, all = { 0, -1 };
HMENU hSubMenu = GetSubMenu(hMenu, 0);
TranslateMenu(hSubMenu);
- SendMessage(((NMHDR *) lParam)->hwndFrom, EM_EXGETSEL, 0, (LPARAM) & sel);
+ SendMessage(((NMHDR *)lParam)->hwndFrom, EM_EXGETSEL, 0, (LPARAM)& sel);
EnableMenuItem(hSubMenu, IDM_COPY, MF_ENABLED);
EnableMenuItem(hSubMenu, IDM_CUT, MF_ENABLED);
@@ -267,34 +267,34 @@ INT_PTR CALLBACK DlgProcDisplayData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA 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);
+ pt.x = (short)LOWORD(((ENLINK *)lParam)->lParam);
+ pt.y = (short)HIWORD(((ENLINK *)lParam)->lParam);
+ ClientToScreen(((NMHDR *)lParam)->hwndFrom, &pt);
switch (TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, nullptr)) {
case IDM_COPY:
- SendMessage(((NMHDR *) lParam)->hwndFrom, WM_COPY, 0, 0);
+ 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);
+ 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);
+ SendMessage(((NMHDR *)lParam)->hwndFrom, EM_EXSETSEL, 0, (LPARAM)& all);
break;
case IDM_CUT:
- SendMessage(((NMHDR *) lParam)->hwndFrom, WM_CUT, 0, 0);
+ SendMessage(((NMHDR *)lParam)->hwndFrom, WM_CUT, 0, 0);
break;
case IDM_PASTE:
- SendMessage(((NMHDR *) lParam)->hwndFrom, WM_PASTE, 0, 0);
+ SendMessage(((NMHDR *)lParam)->hwndFrom, WM_PASTE, 0, 0);
break;
case IDM_DELETE:
- SendMessage(((NMHDR *) lParam)->hwndFrom, WM_CLEAR, 0, 0);
+ SendMessage(((NMHDR *)lParam)->hwndFrom, WM_CLEAR, 0, 0);
break;
case IDM_CLEAR_ALL:
@@ -307,19 +307,19 @@ INT_PTR CALLBACK DlgProcDisplayData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA break;
case EN_LINK:
- switch (((ENLINK *) lParam)->msg) {
+ switch (((ENLINK *)lParam)->msg) {
case WM_RBUTTONDOWN:
case WM_LBUTTONUP:
CHARRANGE sel;
- SendDlgItemMessage(hwndDlg, IDC_DATA, EM_EXGETSEL, 0, (LPARAM) & sel);
+ SendDlgItemMessage(hwndDlg, IDC_DATA, EM_EXGETSEL, 0, (LPARAM)& sel);
if (sel.cpMin != sel.cpMax)
break;
TEXTRANGEA tr;
- tr.chrg = ((ENLINK *) lParam)->chrg;
+ 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);
+ SendDlgItemMessage(hwndDlg, IDC_DATA, EM_GETTEXTRANGE, 0, (LPARAM)& tr);
if (strchr(tr.lpstrText, '@') != nullptr && strchr(tr.lpstrText, ':') == nullptr && strchr(tr.lpstrText, '/') == nullptr) {
memmove(tr.lpstrText + 7, tr.lpstrText, tr.chrg.cpMax - tr.chrg.cpMin + 1);
memcpy(tr.lpstrText, "mailto:", 7);
@@ -338,8 +338,8 @@ INT_PTR CALLBACK DlgProcDisplayData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA switch (LOWORD(wParam)) {
case IDC_OPEN_URL:
GetDlgItemText(hwndDlg, IDC_OPEN_URL, url, _countof(url));
- Utils_OpenUrlW(url);
- db_set_w(wParam, MODULENAME, "Status", ID_STATUS_ONLINE);
+ Utils_OpenUrlW(url);
+ g_plugin.setWord(wParam, "Status", ID_STATUS_ONLINE);
break;
case IDC_UPDATE_BUTTON:
@@ -351,7 +351,7 @@ INT_PTR CALLBACK DlgProcDisplayData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA case IDC_STOP:
if (hContact = FindContactByUrl(hwndDlg))
- g_plugin.setByte(hContact, STOP_KEY, 1);
+ g_plugin.setByte(hContact, STOP_KEY, 1);
break;
case IDC_STICK_BUTTON:
@@ -376,7 +376,7 @@ INT_PTR CALLBACK DlgProcDisplayData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA case IDC_FIND_BUTTON:
{
- HWND hwndFind = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_FIND), hwndDlg, DlgProcFind, (LPARAM) wParam);
+ HWND hwndFind = CreateDialogParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_FIND), hwndDlg, DlgProcFind, (LPARAM)wParam);
ShowWindow(hwndFind, SW_SHOW);
EnableWindow(GetDlgItem(hwndDlg, IDC_FIND_BUTTON), 0);
}
@@ -476,13 +476,13 @@ void SavewinSettings(void) if (Xposition == -32000)
Xposition = 100;
- g_plugin.setDword(Xpos_WIN_KEY, Xposition);
- g_plugin.setDword(Ypos_WIN_KEY, Yposition);
+ g_plugin.setDword(Xpos_WIN_KEY, Xposition);
+ g_plugin.setDword(Ypos_WIN_KEY, Yposition);
- g_plugin.setDword(BG_COLOR_KEY, BackgoundClr);
- g_plugin.setDword(TXT_COLOR_KEY, TextClr);
+ g_plugin.setDword(BG_COLOR_KEY, BackgoundClr);
+ g_plugin.setDword(TXT_COLOR_KEY, TextClr);
g_plugin.setDword(WIN_HEIGHT_KEY, WindowHeight);
- g_plugin.setDword(WIN_WIDTH_KEY, WindowWidth);
+ g_plugin.setDword(WIN_WIDTH_KEY, WindowWidth);
}
diff --git a/plugins/WebView/src/webview_services.cpp b/plugins/WebView/src/webview_services.cpp index 4e6f24f6f5..1a43c19f6f 100644 --- a/plugins/WebView/src/webview_services.cpp +++ b/plugins/WebView/src/webview_services.cpp @@ -1,23 +1,23 @@ /* -* 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. */ #include "stdafx.h" @@ -35,7 +35,7 @@ int DBSettingChanged(WPARAM wParam, LPARAM lParam) if (hContact == NULL) return 0; - DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *) lParam; + DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *)lParam; if (!strcmp(cws->szModule, "CList")) { int invalidpresent = 0; @@ -45,34 +45,34 @@ int DBSettingChanged(WPARAM wParam, LPARAM lParam) // A contact is renamed if (!strcmp(cws->szSetting, "MyHandle")) { - ptrW oldName( g_plugin.getWStringA(hContact, PRESERVE_NAME_KEY)); + ptrW oldName(g_plugin.getWStringA(hContact, PRESERVE_NAME_KEY)); if (oldName == NULL) return 0; wchar_t nick[100]; - ptrW oldnick( db_get_wsa(hContact, "CList", "MyHandle")); + ptrW oldnick(db_get_wsa(hContact, "CList", "MyHandle")); if (oldnick != NULL) wcsncpy_s(nick, oldnick, _TRUNCATE); else nick[0] = 0; - for (int i=0; i < _countof(szInvalidChars); i++ ) { + for (int i = 0; i < _countof(szInvalidChars); i++) { wchar_t *p = wcschr(nick, szInvalidChars[i]); if (p != nullptr) { WErrorPopup((UINT_PTR)"ERROR", TranslateT("Invalid symbol present in contact name.")); *p = '_'; - invalidpresent =1; + invalidpresent = 1; } } if (invalidpresent) { srand((unsigned)time(0)); wchar_t ranStr[7]; - _itow((int)10000 *rand() / (RAND_MAX + 1.0), ranStr, 10); - mir_wstrcat(nick, ranStr); - } + _itow((int)10000 * rand() / (RAND_MAX + 1.0), ranStr, 10); + mir_wstrcat(nick, ranStr); + } - if ( wcschr(nick, '(') == nullptr) { + if (wcschr(nick, '(') == nullptr) { g_plugin.setWString(hContact, PRESERVE_NAME_KEY, nick); g_plugin.setWString(hContact, "Nick", nick); db_set_ws(hContact, "CList", "MyHandle", nick); @@ -92,7 +92,7 @@ int DBSettingChanged(WPARAM wParam, LPARAM lParam) mir_snwprintf(renamedcachepath, L"%s" _A2W(MODULENAME) L"cache\\%s.txt", cachepath, nick); // file exists? - if ( _waccess(newcachepath, 0) != -1) { + if (_waccess(newcachepath, 0) != -1) { FILE *pcachefile = _wfopen(newcachepath, L"r"); if (pcachefile != nullptr) { fclose(pcachefile); @@ -114,7 +114,7 @@ int SiteDeleted(WPARAM wParam, LPARAM) if (mir_strcmp(GetContactProto(hContact), MODULENAME)) return 0; - ptrW contactName( g_plugin.getWStringA(hContact, PRESERVE_NAME_KEY)); + ptrW contactName(g_plugin.getWStringA(hContact, PRESERVE_NAME_KEY)); // TEST GET NAME FOR CACHE wchar_t cachepath[MAX_PATH], cachedirectorypath[MAX_PATH], newcachepath[MAX_PATH + 50]; @@ -125,9 +125,9 @@ int SiteDeleted(WPARAM wParam, LPARAM) mir_snwprintf(cachedirectorypath, L"%s" _A2W(MODULENAME) L"cache\\", cachepath); CreateDirectory(cachedirectorypath, nullptr); - mir_snwprintf(newcachepath, L"%s" _A2W(MODULENAME) L"cache\\%s.txt", cachepath, contactName); + mir_snwprintf(newcachepath, L"%s" _A2W(MODULENAME) L"cache\\%s.txt", cachepath, contactName); // file exists? - if ( _waccess(newcachepath, 0) != -1) { + if (_waccess(newcachepath, 0) != -1) { FILE *pcachefile = _wfopen(newcachepath, L"r"); if (pcachefile != nullptr) { fclose(pcachefile); @@ -150,7 +150,7 @@ INT_PTR OpenCacheDir(WPARAM, LPARAM) mir_snwprintf(cachedirectorypath, L"%s" _A2W(MODULENAME) L"cache\\%s", cachepath, cacheend); - if( _waccess(cachedirectorypath, 0) != 0) + if (_waccess(cachedirectorypath, 0) != 0) WErrorPopup((UINT_PTR)"ERROR", TranslateT("Cache folder does not exist.")); else ShellExecute(nullptr, L"open", cachedirectorypath, nullptr, nullptr, SW_SHOWNORMAL); @@ -166,7 +166,7 @@ INT_PTR PingWebsiteMenuCommand(WPARAM wParam, LPARAM) return 0; } - ptrW url( db_get_wsa(wParam, MODULENAME, "URL")); + ptrW url(g_plugin.getWStringA((wParam, "URL")); if (url == NULL) return 0; @@ -174,7 +174,7 @@ INT_PTR PingWebsiteMenuCommand(WPARAM wParam, LPARAM) wcsncpy(Cnick, url, _countof(Cnick)); if ((Oldnick = wcsstr(Cnick, L"://")) != nullptr) Oldnick += 3; - else + else Oldnick = Cnick; wchar_t *Nend = wcschr(Oldnick, '/'); @@ -187,7 +187,7 @@ INT_PTR PingWebsiteMenuCommand(WPARAM wParam, LPARAM) /*****************************************************************************/ INT_PTR StpPrcssMenuCommand(WPARAM wParam, LPARAM) { - db_set_b(wParam, MODULENAME, STOP_KEY, 1); + g_plugin.setByte(wParam, STOP_KEY, 1); return 0; } @@ -197,18 +197,17 @@ INT_PTR StpPrcssMenuCommand(WPARAM wParam, LPARAM) INT_PTR GetCaps(WPARAM wParam, LPARAM) { - switch(wParam) - { + switch (wParam) { case PFLAGNUM_1: return PF1_BASICSEARCH | PF1_ADDSEARCHRES | PF1_VISLIST; case PFLAGNUM_2: - return g_plugin.getByte(HIDE_STATUS_ICON_KEY, 0) ? 0 : (PF2_ONLINE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_LIGHTDND | PF2_HEAVYDND); + return g_plugin.getByte(HIDE_STATUS_ICON_KEY, 0) ? 0 : (PF2_ONLINE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_LIGHTDND | PF2_HEAVYDND); case PFLAGNUM_3: return 0; case PFLAGNUM_4: return PF4_NOCUSTOMAUTH | PF4_NOAUTHDENYREASON; case PFLAGNUM_5: - return PF2_INVISIBLE|PF2_SHORTAWAY|PF2_LONGAWAY|PF2_LIGHTDND|PF2_HEAVYDND|PF2_FREECHAT|PF2_OUTTOLUNCH|PF2_ONTHEPHONE; + return PF2_INVISIBLE | PF2_SHORTAWAY | PF2_LONGAWAY | PF2_LIGHTDND | PF2_HEAVYDND | PF2_FREECHAT | PF2_OUTTOLUNCH | PF2_ONTHEPHONE; case PFLAG_UNIQUEIDTEXT: return (INT_PTR)Translate("Site URL"); default: @@ -222,7 +221,7 @@ INT_PTR GetCaps(WPARAM wParam, LPARAM) INT_PTR GetName(WPARAM wParam, LPARAM lParam) { - mir_strncpy((char*) lParam, MODULENAME, wParam); + mir_strncpy((char*)lParam, MODULENAME, wParam); return 0; } @@ -244,10 +243,10 @@ INT_PTR SetStatus(WPARAM wParam, LPARAM) // broadcast the message bpStatus = wParam; - ProtoBroadcastAck(MODULENAME, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE) oldStatus, wParam); + ProtoBroadcastAck(MODULENAME, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, wParam); // Make sure no contact has offline status for any reason on first time run - if ( g_plugin.getByte("FirstTime", 100) == 100) { + if (g_plugin.getByte("FirstTime", 100) == 100) { for (auto &hContact : Contacts(MODULENAME)) g_plugin.setWord(hContact, "Status", ID_STATUS_ONLINE); @@ -328,7 +327,7 @@ INT_PTR BasicSearch(WPARAM, LPARAM lParam) /*****************************************************************************/ INT_PTR AddToList(WPARAM, LPARAM lParam) { - PROTOSEARCHRESULT *psr = (PROTOSEARCHRESULT *) lParam; + PROTOSEARCHRESULT *psr = (PROTOSEARCHRESULT *)lParam; DBVARIANT dbv; int sameurl = 0; int samename = 0; @@ -338,7 +337,7 @@ INT_PTR AddToList(WPARAM, LPARAM lParam) if (psr->nick.w == nullptr) { WErrorPopup((UINT_PTR)"ERROR", TranslateT("Please select site in Find/Add contacts...")); return 0; - } + } // if contact with the same ID was not found, add it if (psr->cbSize != sizeof(PROTOSEARCHRESULT)) return NULL; @@ -351,7 +350,7 @@ INT_PTR AddToList(WPARAM, LPARAM lParam) // remove the flag for not on list and hidden, thus make the // contact visible // and add them on the list - sameurl ++; + sameurl++; if (db_get_b(hContact, "CList", "NotOnList", 1)) { db_unset(hContact, "CList", "NotOnList"); db_unset(hContact, "CList", "Hidden"); @@ -415,10 +414,10 @@ INT_PTR AddToList(WPARAM, LPARAM lParam) if ((sameurl > 0) || (samename > 0)) // contact has the same url or name as another contact, add rand num to name { - srand((unsigned) time(0)); - + srand((unsigned)time(0)); + wchar_t ranStr[10]; - _itow((int) 10000 *rand() / (RAND_MAX + 1.0), ranStr, 10); + _itow((int)10000 * rand() / (RAND_MAX + 1.0), ranStr, 10); mir_wstrcat(Newnick, ranStr); } //end convert |