summaryrefslogtreecommitdiff
path: root/plugins/WebView/src
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/WebView/src')
-rw-r--r--plugins/WebView/src/main.cpp2
-rw-r--r--plugins/WebView/src/webview.h1
-rw-r--r--plugins/WebView/src/webview_alerts.cpp20
-rw-r--r--plugins/WebView/src/webview_cleanup.cpp20
-rw-r--r--plugins/WebView/src/webview_datawnd.cpp347
-rw-r--r--plugins/WebView/src/webview_getdata.cpp107
-rw-r--r--plugins/WebView/src/webview_opts.cpp83
-rw-r--r--plugins/WebView/src/webview_services.cpp10
8 files changed, 201 insertions, 389 deletions
diff --git a/plugins/WebView/src/main.cpp b/plugins/WebView/src/main.cpp
index 2678c19031..91b00dba30 100644
--- a/plugins/WebView/src/main.cpp
+++ b/plugins/WebView/src/main.cpp
@@ -153,7 +153,7 @@ extern "C" int __declspec(dllexport) Load()
mir_getLP(&pluginInfoEx);
mir_getCLI();
- strncpy_s(optionsname, MODULENAME, sizeof(optionsname));
+ strncpy_s(optionsname, MODULENAME, SIZEOF(optionsname));
optionsname[0] = toupper(optionsname[0]);
HookEvent(ME_CLIST_DOUBLECLICKED, Doubleclick);
diff --git a/plugins/WebView/src/webview.h b/plugins/WebView/src/webview.h
index 0e5dd41f3d..8fdfbaa806 100644
--- a/plugins/WebView/src/webview.h
+++ b/plugins/WebView/src/webview.h
@@ -155,6 +155,7 @@ void SavewinSettings(void);
void ValidatePosition(HWND hwndDlg);
int ModulesLoaded(WPARAM wParam, LPARAM lParam);
void ChangeMenuItem3();
+TCHAR* FixButtonText(TCHAR *url, size_t len);
int ContactMenuItemUpdateData (WPARAM wParam, LPARAM lParam);
int Doubleclick(WPARAM wParam, LPARAM lParam);
diff --git a/plugins/WebView/src/webview_alerts.cpp b/plugins/WebView/src/webview_alerts.cpp
index 141a3c3251..f06fbc0e5f 100644
--- a/plugins/WebView/src/webview_alerts.cpp
+++ b/plugins/WebView/src/webview_alerts.cpp
@@ -209,7 +209,7 @@ int OSDAlert(WPARAM wParam, LPARAM lParam)
else lstrcpyA(contactname, MODULENAME);
char *displaytext = (char*)lParam;
- mir_snprintf(newdisplaytext, sizeof(newdisplaytext), "%s: %s", contactname, Translate(displaytext));
+ mir_snprintf(newdisplaytext, SIZEOF(newdisplaytext), "%s: %s", contactname, Translate(displaytext));
if (ServiceExists("OSD/Announce"))
CallService("OSD/Announce", (WPARAM) newdisplaytext, 0);
@@ -260,7 +260,7 @@ void SaveToFile(HANDLE hContact, char *truncated)
char url[300]; url[0] = '\0';
DBVARIANT dbv;
db_get_s(hContact, MODULENAME, URL_KEY, &dbv);
- _snprintf(url, sizeof(url), "%s", dbv.pszVal);
+ mir_snprintf(url, SIZEOF(url), "%s", dbv.pszVal);
db_free(&dbv);
db_get_s(hContact, MODULENAME, FILE_KEY, &dbv);
@@ -276,10 +276,10 @@ void SaveToFile(HANDLE hContact, char *truncated)
time_t ftime = time(NULL);
struct tm *nTime = localtime(&ftime);
- mir_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);
- mir_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);
@@ -314,7 +314,7 @@ int ProcessAlerts(HANDLE hContact, char *truncated, char *tstr, char *contactnam
ZeroMemory(&tempraw, sizeof(tempraw));
ZeroMemory(&raw, sizeof(raw));
- strncpy(tempraw, truncated, sizeof(tempraw));
+ strncpy(tempraw, truncated, SIZEOF(tempraw));
ZeroMemory(&alertstring, sizeof(alertstring));
ZeroMemory(&Alerttempstring, sizeof(Alerttempstring));
@@ -393,7 +393,7 @@ int ProcessAlerts(HANDLE hContact, char *truncated, char *tstr, char *contactnam
if (eventIndex == 0) { // string present
if ( !db_get_s(hContact, MODULENAME, ALERT_STRING_KEY, &tdbv)) {
- strncpy(alertstring, tdbv.pszVal, sizeof(alertstring));
+ strncpy(alertstring, tdbv.pszVal, SIZEOF(alertstring));
db_free(&tdbv);
if ((strstr(tempraw, alertstring)) != 0) { // // ENDALERT EVENT:CHECK FOR STRING
@@ -469,7 +469,7 @@ int ProcessAlerts(HANDLE hContact, char *truncated, char *tstr, char *contactnam
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));
+ GetModuleFileName(hInst, cachepath, SIZEOF(cachepath));
TCHAR *cacheend = _tcsrchr(cachepath, '\\');
cacheend++;
*cacheend = '\0';
@@ -563,11 +563,11 @@ int ProcessAlerts(HANDLE hContact, char *truncated, char *tstr, char *contactnam
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);
+ mir_snprintf(Alerttempstring, SIZEOF(Alerttempstring), "%s", tdbv.pszVal);
db_free(&tdbv);
db_get_s(hContact, MODULENAME, ALRT_E_STRING_KEY, &tdbv);
- mir_snprintf(Alerttempstring2, sizeof(Alerttempstring2), "%s", tdbv.pszVal);
+ mir_snprintf(Alerttempstring2, SIZEOF(Alerttempstring2), "%s", tdbv.pszVal);
db_free(&tdbv);
// putting data into string
@@ -848,7 +848,7 @@ void ReadFromFile(HANDLE hContact)
char contactname[100];
db_get_s(hContact, "CList", "MyHandle", &dbv);
- mir_snprintf(contactname, sizeof(contactname), "%s", dbv.pszVal);
+ mir_snprintf(contactname, SIZEOF(contactname), "%s", dbv.pszVal);
db_free(&dbv);
db_get_s(hContact, MODULENAME, CACHE_FILE_KEY, &dbv);
diff --git a/plugins/WebView/src/webview_cleanup.cpp b/plugins/WebView/src/webview_cleanup.cpp
index b1fbc3912e..bf34ef46d5 100644
--- a/plugins/WebView/src/webview_cleanup.cpp
+++ b/plugins/WebView/src/webview_cleanup.cpp
@@ -371,7 +371,7 @@ void CodetoSymbol(char *truncated)
static char *stringfrompos;
for (int n = 0; n < AMOUNT3; n++) {
- while (1) { // loop forever
+ while (true) { // loop forever
Sleep(1); // avoid 100% CPU
if ( strstr(truncated, CharacterCodes[n]) != 0) { // does character code exist?
@@ -411,7 +411,7 @@ void EraseBlock(char *truncated)
// ///////////////////////////
- while (1) {
+ while (true) {
Sleep(1); // avoid 100% CPU
// /get start and end of block
@@ -451,7 +451,7 @@ void EraseBlock(char *truncated)
positionEnd = 0;
// 2//
- while (1) {
+ while (true) {
Sleep(1); // avoid 100% CPU
// /get start and end of block
@@ -499,7 +499,7 @@ void EraseBlock(char *truncated)
// ////
// 3//
- while (1)
+ while (true)
{
Sleep(1); // avoid 100% CPU
// /get start and end of block
@@ -547,7 +547,7 @@ void EraseBlock(char *truncated)
// 4//
- while (1) {
+ while (true) {
Sleep(1); // avoid 100% CPU
// /get start and end of block
if (strstr(tempraw, "{") != 0) // does tag exist?
@@ -600,7 +600,7 @@ void EraseSymbols(char *truncated)
strncpy(tempraw, truncated, MAXSIZE1);
// //////
- while (1) {
+ while (true) {
Sleep(1); // avoid 100% CPU
/**/
@@ -609,7 +609,7 @@ void EraseSymbols(char *truncated)
stringfrompos = strstr(tempraw, "&#");
position = stringfrompos - tempraw;
- while (1) {
+ while (true) {
tempraw[position + counter] = ' ';
counter++;
if (counter > 20)
@@ -642,7 +642,7 @@ void NumSymbols(char *truncated)
if (truncated)
strncpy(tempraw, truncated, MAXSIZE1);
- while (1) {
+ while (true) {
Sleep(1); // avoid 100% CPU
counter = 0;
@@ -651,7 +651,7 @@ void NumSymbols(char *truncated)
stringfrompos = strstr(tempraw, "&#");
position = stringfrompos - tempraw;
- while (1) {
+ while (true) {
if (counter > 1)
symbol[counter - 2] = tempraw[position + counter];
@@ -788,7 +788,7 @@ void Removewhitespace(char *truncated)
void Filter(char *truncated)
{
char tempraw[MAXSIZE1];
- strncpy(tempraw, truncated, sizeof(tempraw));
+ strncpy(tempraw, truncated, SIZEOF(tempraw));
for (int counter = 0; counter < lstrlenA(tempraw); counter++)
if ((tempraw[counter] == '\n') || (tempraw[counter] == '\r') || (tempraw[counter] == '\t'))
diff --git a/plugins/WebView/src/webview_datawnd.cpp b/plugins/WebView/src/webview_datawnd.cpp
index 78e8364711..cf7ec325ea 100644
--- a/plugins/WebView/src/webview_datawnd.cpp
+++ b/plugins/WebView/src/webview_datawnd.cpp
@@ -58,13 +58,13 @@ INT_PTR CALLBACK DlgProcFind(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara
char *tempbuffer = (char*)malloc(len + 2);
GetWindowTextA(GetDlgItem(ParentHwnd, IDC_DATA), tempbuffer, len);
- strncpy(buff, tempbuffer, sizeof(buff));
+ strncpy(buff, tempbuffer, SIZEOF(buff));
free(tempbuffer);
Filter(buff);
CharUpperBuffA(buff, lstrlenA(buff));
- GetDlgItemTextA(hwndDlg, IDC_FINDWHAT, NewSearchstr, sizeof(NewSearchstr));
+ GetDlgItemTextA(hwndDlg, IDC_FINDWHAT, NewSearchstr, SIZEOF(NewSearchstr));
CharUpperBuffA(NewSearchstr, lstrlenA(NewSearchstr));
OLDstartposition = startposition;
@@ -116,11 +116,40 @@ INT_PTR CALLBACK DlgProcFind(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPara
}
/*****************************************************************************/
+
+static TCHAR tszSizeString[] = _T("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
+
+static HANDLE FindContactByUrl(HWND hwndDlg)
+{
+ HANDLE res = NULL;
+ TCHAR urltext[300], titlebartxt[300];
+ int contactcount = 0;
+
+ GetDlgItemText(hwndDlg, IDC_OPEN_URL, urltext, SIZEOF(urltext));
+ GetWindowText(hwndDlg, titlebartxt, SIZEOF(titlebartxt));
+
+ for (HANDLE hContact = db_find_first(MODULENAME); hContact != NULL; hContact = db_find_next(hContact, MODULENAME)) {
+ ptrT db1( db_get_tsa(hContact, MODULENAME, URL_KEY));
+ ptrT db2( db_get_tsa(hContact, MODULENAME, PRESERVE_NAME_KEY));
+
+ if ( !lstrcmp(urltext, db1) && !lstrcmp(titlebartxt, db2)) {
+ 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);
+ return NULL;
+ }
+ res = hContact;
+ }
+ }
+ return res;
+}
+
INT_PTR CALLBACK DlgProcDisplayData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
- DBVARIANT dbv, dbv2;
+ DBVARIANT dbv;
RECT rc;
- char url[300];
+ TCHAR url[300];
+ HANDLE hContact;
switch (msg) {
case WM_INITDIALOG:
@@ -132,60 +161,18 @@ INT_PTR CALLBACK DlgProcDisplayData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
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;
- }
+ if ( !db_get_ts(hContact2, MODULENAME, URL_KEY, &dbv)) {
+ _tcsncpy_s(url, SIZEOF(url), dbv.ptszVal, _TRUNCATE);
+ db_free(&dbv);
}
-
- SetDlgItemTextA(hwndDlg, IDC_OPEN_URL, newbuttontext);
+ SetDlgItemText(hwndDlg, IDC_OPEN_URL, FixButtonText(url, SIZEOF(url)));
char preservename[100];
- db_get_s(hContact2, MODULENAME, PRESERVE_NAME_KEY, &dbv);
- mir_snprintf(preservename, sizeof(preservename), "%s", dbv.pszVal);
- db_free(&dbv);
+ if ( !db_get_s(hContact2, MODULENAME, PRESERVE_NAME_KEY, &dbv)) {
+ strncpy_s(preservename, SIZEOF(preservename), dbv.pszVal, _TRUNCATE);
+ db_free(&dbv);
+ }
+ else preservename[0] = 0;
SetWindowTextA(hwndDlg, preservename);
SendMessage(hwndDlg, WM_SETICON, ICON_SMALL, (LPARAM) LoadIcon(hInst, MAKEINTRESOURCE(IDI_SITE)));
@@ -242,21 +229,16 @@ INT_PTR CALLBACK DlgProcDisplayData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
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);
- }
+ HDC hdc = GetDC(GetDlgItem(hwndDlg, IDC_STATUSBAR));
+ SelectObject(hdc, (HFONT) SendDlgItemMessage(hwndDlg, IDC_STATUSBAR, WM_GETFONT, 0, 0));
+ SIZE textSize;
+ GetTextExtentPoint32(hdc, tszSizeString, SIZEOF(tszSizeString), &textSize);
+ int partWidth[2] = { textSize.cx, -1 };
+ ReleaseDC(GetDlgItem(hwndDlg, IDC_STATUSBAR), hdc);
+
+ SendDlgItemMessage(hwndDlg, IDC_STATUSBAR, SB_SETPARTS, SIZEOF(partWidth), (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");
@@ -355,108 +337,27 @@ INT_PTR CALLBACK DlgProcDisplayData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
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);
+ GetDlgItemText(hwndDlg, IDC_OPEN_URL, url, SIZEOF(url));
+ CallService(MS_UTILS_OPENURL, OUF_TCHAR, (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);
- }
+ if (hContact = FindContactByUrl(hwndDlg)) {
+ EnableWindow(GetDlgItem(hwndDlg, IDC_UPDATE_BUTTON), 0);
+ UpdateMenuCommand(wParam, lParam, hContact);
}
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);
- }
- }
+ if (hContact = FindContactByUrl(hwndDlg))
+ db_set_b(hContact, MODULENAME, STOP_KEY, 1);
break;
case IDC_STICK_BUTTON:
+ if (hContact = FindContactByUrl(hwndDlg))
+ OnTopMenuCommand(wParam, lParam, hContact);
{
- 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)) {
@@ -470,7 +371,6 @@ INT_PTR CALLBACK DlgProcDisplayData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
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;
@@ -483,76 +383,22 @@ INT_PTR CALLBACK DlgProcDisplayData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
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);
- }
+ if (hContact = FindContactByUrl(hwndDlg)) {
+ 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);
}
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);
- }
+ if (hContact = FindContactByUrl(hwndDlg)) {
+ HWND 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);
}
break;
@@ -565,46 +411,19 @@ INT_PTR CALLBACK DlgProcDisplayData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
break;
case WM_CLOSE:
- {
- char urltext[300];
- char titlebartxt[300];
- int contactcount = 0;
+ if (Yposition == -32000)
+ Yposition = 100;
- if (Yposition == -32000)
- Yposition = 100;
+ if (Xposition == -32000)
+ Xposition = 100;
- if (Xposition == -32000)
- Xposition = 100;
+ SavewinSettings();
- SavewinSettings();
+ if (hContact = FindContactByUrl(hwndDlg))
+ Utils_SaveWindowPosition(hwndDlg, hContact, MODULENAME, "WV");
- /**/
- //
- 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);
- }
+ if (hwndDlg != NULL)
+ DestroyWindow(hwndDlg);
return 0;
case WM_DESTROY:
@@ -613,9 +432,7 @@ INT_PTR CALLBACK DlgProcDisplayData(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
case WM_SIZE:
{
- UTILRESIZEDIALOG urd = {0};
-
- urd.cbSize = sizeof(urd);
+ UTILRESIZEDIALOG urd = { sizeof(urd) };
urd.hInstance = hInst;
urd.hwndDlg = hwndDlg;
urd.lParam = 0;
diff --git a/plugins/WebView/src/webview_getdata.cpp b/plugins/WebView/src/webview_getdata.cpp
index 068065d04a..601f2b686f 100644
--- a/plugins/WebView/src/webview_getdata.cpp
+++ b/plugins/WebView/src/webview_getdata.cpp
@@ -32,9 +32,6 @@ 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;
@@ -47,7 +44,6 @@ void GetData(HANDLE hContact)
unsigned long downloadsize = 0;
int AmountWspcRem = 0;
static char contactname[100];
- char statustext[200];
int TherewasAlert = 0;
int PosButnClick = 0;
char tstr[128];
@@ -75,41 +71,47 @@ void GetData(HANDLE hContact)
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);
+ if ( !db_get_s(hContact, "CList", "MyHandle", &dbv)) {
+ db_set_s(hContact, MODULENAME, PRESERVE_NAME_KEY, dbv.pszVal);
+ db_free(&dbv);
+ }
+ }
+
+ if ( !db_get_s(hContact, MODULENAME, PRESERVE_NAME_KEY, &dbv)) {
+ strncpy_s(contactname, SIZEOF(contactname), dbv.pszVal, _TRUNCATE);
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);
+ if ( !db_get_s(hContact, MODULENAME, START_STRING_KEY, &dbv)) {
+ strncpy_s(tempstring, SIZEOF(tempstring), dbv.pszVal, _TRUNCATE);
+ db_free(&dbv);
+ }
- db_get_s(hContact, MODULENAME, END_STRING_KEY, &dbv);
- _snprintf(tempstring2, sizeof(tempstring2), "%s", dbv.pszVal);
- db_free(&dbv);
+ if ( !db_get_s(hContact, MODULENAME, END_STRING_KEY, &dbv)) {
+ strncpy_s(tempstring2, SIZEOF(tempstring2), dbv.pszVal, _TRUNCATE);
+ db_free(&dbv);
+ }
- db_get_s(hContact, MODULENAME, URL_KEY, &dbv);
- _snprintf(url, sizeof(url), "%s", dbv.pszVal);
- db_free(&dbv);
+ if ( !db_get_s(hContact, MODULENAME, URL_KEY, &dbv)) {
+ strncpy_s(url, SIZEOF(url), dbv.pszVal, _TRUNCATE);
+ db_free(&dbv);
+ }
if (strlen(url) < 3)
WErrorPopup(hContact, TranslateT("URL not supplied"));
- nlhr.cbSize = sizeof(nlhr);
+ NETLIBHTTPREQUEST nlhr = { sizeof(nlhr) };
nlhr.requestType = REQUEST_GET;
nlhr.flags = NLHRF_DUMPASTEXT;
nlhr.szUrl = url;
nlhr.headersCount = 2;
+ NETLIBHTTPHEADER headers[2];
headers[0].szName = "User-Agent";
headers[0].szValue = "Mozilla/4.0 (compatible; MSIE 6.0; Win32)";
@@ -130,14 +132,10 @@ void GetData(HANDLE hContact)
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_ts(hContact, "CList", "StatusMsg", TranslateT("Updating..."));
db_set_w(hContact, MODULENAME, "Status", ID_STATUS_DND); // download
- nlhrReply = (NETLIBHTTPREQUEST *) CallService(MS_NETLIB_HTTPTRANSACTION, (WPARAM) hNetlibUser, (LPARAM) & nlhr);
+ NETLIBHTTPREQUEST *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);
@@ -167,12 +165,10 @@ void GetData(HANDLE hContact)
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);
+ TCHAR *statusText = TranslateT("The server is down or lagging.");
+ SetDlgItemText(hwndDlg, IDC_STATUSBAR, statusText);
+ WErrorPopup(hContact, statusText);
+ db_set_ts(hContact, "CList", "StatusMsg", statusText);
}
if (!(nlhrReply))
@@ -301,14 +297,13 @@ void GetData(HANDLE hContact)
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);
+ mir_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);
+ mir_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);
+ else {
+ db_get_ts(hContact, "CList", "MyHandle", &dbv);
ZeroMemory(&temptime, sizeof(temptime));
ZeroMemory(&tstr, sizeof(tstr));
ftime = time(NULL);
@@ -320,29 +315,22 @@ void GetData(HANDLE hContact)
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);
+ db_set_ts(hContact, MODULENAME, PRESERVE_NAME_KEY, dbv.ptszVal);
if (db_get_b(hContact, MODULENAME, CONTACT_PREFIX_KEY, 1) == 1)
- _snprintf(tstr, sizeof(tstr), "%s %s", temptime, dbv.pszVal);
+ mir_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);
+ mir_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")));
+ mir_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")));
+ mir_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);
-
+ mir_snprintf(timestring, SIZEOF(timestring), "%s%s%s%s", timeprefix, temptime1, timeat, temptime2);
} // end download success
if (DownloadSuccess) {
@@ -356,16 +344,17 @@ void GetData(HANDLE hContact)
eventIndex = db_get_b(hContact, MODULENAME, EVNT_INDEX_KEY, 0);
if (eventIndex == 2) {
- strncpy(buff, truncated, sizeof(buff));
+ 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);
+ if ( !db_get_s(hContact, MODULENAME, ALRT_S_STRING_KEY, &dbv)) {
+ strncpy_s(Alerttempstring, SIZEOF(Alerttempstring), dbv.pszVal, _TRUNCATE);
+ db_free(&dbv);
+ }
+ if ( !db_get_s(hContact, MODULENAME, ALRT_E_STRING_KEY, &dbv)) {
+ strncpy_s(Alerttempstring2, SIZEOF(Alerttempstring2), dbv.pszVal, _TRUNCATE);
+ db_free(&dbv);
+ }
// putting data into string
if (((strstr(buff, Alerttempstring)) != 0) && ((strstr(buff, Alerttempstring2)) != 0)) {
@@ -461,7 +450,7 @@ LBL_Stop: TCHAR *statusText = TranslateT("Processing data stopped by user.");
if ((truncated[strlen(truncated) - 1] == truncated[strlen(truncated) - 2]) && (truncated[strlen(truncated) - 2] == truncated[strlen(truncated) - 3])) {
int counterx = 0;
- while (1) {
+ while (true) {
counterx++;
if (truncated[strlen(truncated) - counterx] != truncated[strlen(truncated) - 1]) {
truncated[(strlen(truncated) - counterx) + 2] = '\0';
diff --git a/plugins/WebView/src/webview_opts.cpp b/plugins/WebView/src/webview_opts.cpp
index ba9ed25852..760e776e68 100644
--- a/plugins/WebView/src/webview_opts.cpp
+++ b/plugins/WebView/src/webview_opts.cpp
@@ -46,6 +46,45 @@ void strdel(TCHAR *parBuffer, int len )
p[ -len ] = '\0';
}
+TCHAR* FixButtonText(TCHAR *url, size_t len)
+{
+ 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;
+ }
+ }
+
+ _tcsncpy_s(url, len, newbuttontext, _TRUNCATE);
+ return url;
+}
+
/*****************************************************************************/
static int CALLBACK EnumFontScriptsProc(ENUMLOGFONTEX * lpelfe, NEWTEXTMETRICEX * lpntme, int FontType, LPARAM lParam)
{
@@ -422,7 +461,7 @@ INT_PTR CALLBACK DlgProcAlertOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
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.nMaxFile = SIZEOF(szFileName);
ofn.nMaxFileTitle = MAX_PATH;
ofn.lpstrDefExt = _T("txt");
if (!GetSaveFileName(&ofn))
@@ -727,10 +766,10 @@ INT_PTR CALLBACK DlgProcAlertOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l
GetDlgItemText(hwndDlg, IDC_ALERT_STRING, buf, SIZEOF(buf));
db_set_ts(hContact, MODULENAME, ALERT_STRING_KEY, buf);
- GetDlgItemText(hwndDlg, IDC_START2, buf, sizeof(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));
+ 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));
@@ -1004,40 +1043,7 @@ INT_PTR CALLBACK DlgProcContactOpt(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
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);
+ SetDlgItemText(ParentHwnd, IDC_OPEN_URL, FixButtonText(url, SIZEOF(url)));
SetWindowText(ParentHwnd, str);
EnableWindow(GetDlgItem(hwndDlg, IDC_OPT_APPLY), 0);
@@ -1170,7 +1176,7 @@ INT_PTR CALLBACK DlgProcOpt(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
HDC hdc = GetDC(hwndDlg);
lf.lfCharSet = DEFAULT_CHARSET;
- GetDlgItemText(hwndDlg, IDC_TYPEFACE, lf.lfFaceName, sizeof(lf.lfFaceName));
+ 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);
@@ -1314,4 +1320,3 @@ INT_PTR CALLBACK DlgProcOpt(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPara
return 0;
}
-/********************/
diff --git a/plugins/WebView/src/webview_services.cpp b/plugins/WebView/src/webview_services.cpp
index 274b539352..78c4749b71 100644
--- a/plugins/WebView/src/webview_services.cpp
+++ b/plugins/WebView/src/webview_services.cpp
@@ -144,7 +144,7 @@ INT_PTR OpenCacheDir(WPARAM wParam, LPARAM lParam)
{
//GET NAME FOR CACHE
TCHAR cachepath[MAX_PATH], cachedirectorypath[MAX_PATH];
- GetModuleFileName(hInst, cachepath, sizeof(cachepath));
+ GetModuleFileName(hInst, cachepath, SIZEOF(cachepath));
TCHAR *cacheend = _tcsrchr(cachepath, '\\');
cacheend++;
*cacheend = '\0';
@@ -172,7 +172,7 @@ INT_PTR PingWebsiteMenuCommand(WPARAM wParam, LPARAM lParam)
return 0;
TCHAR Cnick[200], *Oldnick;
- _tcsncpy(Cnick, url, sizeof(Cnick));
+ _tcsncpy(Cnick, url, SIZEOF(Cnick));
if ((Oldnick = _tcsstr(Cnick, _T("://"))) != 0)
Oldnick += 3;
else
@@ -338,12 +338,9 @@ INT_PTR AddToList(WPARAM wParam, LPARAM lParam)
{
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)) {
@@ -382,8 +379,11 @@ INT_PTR AddToList(WPARAM wParam, LPARAM lParam)
db_set_b(hContact, MODULENAME, RWSPACE_KEY, 1);
//Convert url into a name for contact
+ TCHAR Cnick[255];
if (psr->nick != NULL)
_tcsncpy(Cnick, psr->nick, SIZEOF(Cnick));
+ else
+ Cnick[0] = 0;
TCHAR *Oldnick = _tcsstr(Cnick, _T("://"));
if (Oldnick != 0)