summaryrefslogtreecommitdiff
path: root/plugins/Non-IM Contact
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-08-16 23:08:55 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-08-16 23:08:55 +0000
commit0c060267ccea726d5c2c2fd1e45d1f16965fb01e (patch)
treeef15e5533dbda23f63e423056b9d746e5d643ae3 /plugins/Non-IM Contact
parentaf58213e6005cbf4b9ce8be2ad66eb6eae3df4a9 (diff)
code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@14975 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Non-IM Contact')
-rw-r--r--plugins/Non-IM Contact/src/dialog.cpp26
-rw-r--r--plugins/Non-IM Contact/src/files.cpp34
-rw-r--r--plugins/Non-IM Contact/src/main.cpp13
-rw-r--r--plugins/Non-IM Contact/src/stdafx.h2
4 files changed, 41 insertions, 34 deletions
diff --git a/plugins/Non-IM Contact/src/dialog.cpp b/plugins/Non-IM Contact/src/dialog.cpp
index 5690b5a2f9..c5fdf36770 100644
--- a/plugins/Non-IM Contact/src/dialog.cpp
+++ b/plugins/Non-IM Contact/src/dialog.cpp
@@ -17,9 +17,10 @@ filename(0) <- will display the filename of the 0th file\r\nfile(0)wholeline(
INT_PTR CALLBACK DlgProcNimcOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
+ TCHAR tmp[5];
+
switch (msg) {
case WM_INITDIALOG:
- TCHAR tmp[5];
TranslateDialogDefault(hwnd);
CheckDlgButton(hwnd, IDC_AWAYISNOTONLINE, db_get_b(NULL, MODNAME, "AwayAsStatus", 0) ? BST_CHECKED : BST_UNCHECKED);
if (db_get_w(NULL, MODNAME, "Timer", 1)) {
@@ -57,7 +58,6 @@ INT_PTR CALLBACK DlgProcNimcOpts(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPar
case 0:
switch (((LPNMHDR)lParam)->code) {
case PSN_APPLY:
- TCHAR tmp[5];
db_set_b(NULL, MODNAME, "AwayAsStatus", (BYTE)IsDlgButtonChecked(hwnd, IDC_AWAYISNOTONLINE));
if (BST_UNCHECKED == IsDlgButtonChecked(hwnd, IDC_DISABLETIMER) && GetWindowTextLength(GetDlgItem(hwnd, IDC_TIMER_INT))) {
GetDlgItemText(hwnd, IDC_TIMER_INT, tmp, _countof(tmp));
@@ -123,7 +123,7 @@ INT_PTR CALLBACK TestWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM)
case WM_COMMAND:
switch (LOWORD(wParam)) {
case IDC_HELPMSG:
- CreateDialog(hInst, MAKEINTRESOURCE(IDD_HELP), 0, HelpWindowDlgProc);
+ CreateDialog(g_hInst, MAKEINTRESOURCE(IDD_HELP), 0, HelpWindowDlgProc);
break;
case IDCANCEL:
@@ -205,13 +205,13 @@ INT_PTR CALLBACK TestWindowDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM)
INT_PTR testStringReplacer(WPARAM, LPARAM)
{
- CreateDialog(hInst, MAKEINTRESOURCE(IDD_TEST_LINE), 0, TestWindowDlgProc);
+ CreateDialog(g_hInst, MAKEINTRESOURCE(IDD_TEST_LINE), 0, TestWindowDlgProc);
return 0;
}
INT_PTR LoadFilesDlg(WPARAM, LPARAM)
{
- CreateDialog(hInst, MAKEINTRESOURCE(IDD_ADD_FILE), 0, DlgProcFiles);
+ CreateDialog(g_hInst, MAKEINTRESOURCE(IDD_ADD_FILE), 0, DlgProcFiles);
return 0;
}
@@ -233,7 +233,7 @@ static int CALLBACK PropSheetProc(HWND, UINT uMsg, LPARAM lParam)
return 0;
}
-void DoPropertySheet(MCONTACT hContact, HINSTANCE hInst)
+void DoPropertySheet(MCONTACT hContact)
{
char title[256], nick[256];
PROPSHEETPAGEA psp[4] = { 0 };
@@ -241,7 +241,7 @@ void DoPropertySheet(MCONTACT hContact, HINSTANCE hInst)
/* contact info */
psp[0].dwSize = sizeof(PROPSHEETPAGE);
psp[0].dwFlags = PSP_USEICONID | PSP_USETITLE;
- psp[0].hInstance = hInst;
+ psp[0].hInstance = g_hInst;
psp[0].pszTemplate = MAKEINTRESOURCEA(IDD_CONTACT_INFO);
psp[0].pszIcon = NULL;
psp[0].pfnDlgProc = DlgProcContactInfo;
@@ -252,7 +252,7 @@ void DoPropertySheet(MCONTACT hContact, HINSTANCE hInst)
/* other settings */
psp[1].dwSize = sizeof(PROPSHEETPAGE);
psp[1].dwFlags = PSP_USEICONID | PSP_USETITLE;
- psp[1].hInstance = hInst;
+ psp[1].hInstance = g_hInst;
psp[1].pszTemplate = MAKEINTRESOURCEA(IDD_OTHER_STUFF);
psp[1].pszIcon = NULL;
psp[1].pfnDlgProc = DlgProcOtherStuff;
@@ -263,7 +263,7 @@ void DoPropertySheet(MCONTACT hContact, HINSTANCE hInst)
/* copy contact */
psp[2].dwSize = sizeof(PROPSHEETPAGE);
psp[2].dwFlags = PSP_USEICONID | PSP_USETITLE;
- psp[2].hInstance = hInst;
+ psp[2].hInstance = g_hInst;
psp[2].pszTemplate = MAKEINTRESOURCEA(IDD_CONTACT_COPYEXPORT);
psp[2].pszIcon = NULL;
psp[2].pfnDlgProc = DlgProcCopy;
@@ -274,7 +274,7 @@ void DoPropertySheet(MCONTACT hContact, HINSTANCE hInst)
/* files */
psp[3].dwSize = sizeof(PROPSHEETPAGE);
psp[3].dwFlags = PSP_USEICONID | PSP_USETITLE;
- psp[3].hInstance = hInst;
+ psp[3].hInstance = g_hInst;
psp[3].pszTemplate = MAKEINTRESOURCEA(IDD_ADD_FILE);
psp[3].pszIcon = NULL;
psp[3].pfnDlgProc = DlgProcFiles;
@@ -285,7 +285,7 @@ void DoPropertySheet(MCONTACT hContact, HINSTANCE hInst)
/* propery sheet header.. dont touch !!!! */
PROPSHEETHEADERA psh = { sizeof(psh) };
psh.dwFlags = PSH_USEICONID | PSH_PROPSHEETPAGE | PSH_USECALLBACK;
- psh.hInstance = hInst;
+ psh.hInstance = g_hInst;
psh.pszIcon = MAKEINTRESOURCEA(IDI_MAIN);
db_get_static(hContact, MODNAME, "Nick", nick, _countof(nick));
mir_snprintf(title, _countof(title), Translate("Edit Non-IM Contact \"%s\""), nick);
@@ -305,7 +305,7 @@ INT_PTR addContact(WPARAM, LPARAM)
Proto_AddToContact(hContact, MODNAME);
CallService(MS_IGNORE_IGNORE, hContact, IGNOREEVENT_USERONLINE);
db_set_ts(hContact, MODNAME, "Nick", TranslateT("New Non-IM Contact"));
- DoPropertySheet(hContact, hInst);
+ DoPropertySheet(hContact);
if (!db_get_static(hContact, MODNAME, "Name", tmp, _countof(tmp)))
CallService(MS_DB_CONTACT_DELETE, hContact, 0);
replaceAllStrings(hContact);
@@ -322,7 +322,7 @@ INT_PTR editContact(WPARAM wParam, LPARAM)
CallService(MS_IGNORE_IGNORE, hContact, IGNOREEVENT_USERONLINE);
db_set_s(hContact, MODNAME, "Nick", Translate("New Non-IM Contact"));
}
- DoPropertySheet(hContact, hInst);
+ DoPropertySheet(hContact);
if (!db_get_static(hContact, MODNAME, "Name", tmp, _countof(tmp)))
CallService(MS_DB_CONTACT_DELETE, hContact, 0);
replaceAllStrings(hContact);
diff --git a/plugins/Non-IM Contact/src/files.cpp b/plugins/Non-IM Contact/src/files.cpp
index 0ba3631be1..c97369d641 100644
--- a/plugins/Non-IM Contact/src/files.cpp
+++ b/plugins/Non-IM Contact/src/files.cpp
@@ -102,12 +102,15 @@ int savehtml(char* outFile)
void readFile(HWND hwnd)
{
int lineNumber, fileLength = 0;
- char temp[MAX_STRING_LENGTH], szFileName[512], temp1[MAX_STRING_LENGTH], fn[8];
+ char temp[MAX_STRING_LENGTH], szFileName[512], temp1[MAX_STRING_LENGTH];
int fileNumber = SendDlgItemMessage(hwnd, IDC_FILE_LIST, CB_GETCURSEL, 0, 0);
- mir_snprintf(fn, "fn%d", fileNumber);
- if (!db_get_static(NULL, MODNAME, fn, szFileName, _countof(szFileName))) {
- msg(Translate("File couldn't be opened"), fn);
- return;
+ {
+ char fn[10];
+ mir_snprintf(fn, "fn%d", fileNumber);
+ if (!db_get_static(NULL, MODNAME, fn, szFileName, _countof(szFileName))) {
+ msg(Translate("File couldn't be opened"), fn);
+ return;
+ }
}
if (!strncmp("http://", szFileName, mir_strlen("http://")) || !strncmp("https://", szFileName, mir_strlen("https://")))
@@ -141,11 +144,14 @@ void readFile(HWND hwnd)
INT_PTR CALLBACK DlgProcFiles(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
+ char tmp[MAX_PATH], fn[MAX_PATH];
+
switch (msg) {
case WM_RELOADWINDOW:
- char fn[MAX_PATH], string[MAX_STRING_LENGTH], tmp[MAX_STRING_LENGTH];
- reloadFiles(GetDlgItem(hwnd, IDC_FILE_LIST));
{
+ char string[MAX_STRING_LENGTH];
+ reloadFiles(GetDlgItem(hwnd, IDC_FILE_LIST));
+
int i = SendDlgItemMessage(hwnd, IDC_FILE_LIST, CB_GETCURSEL, 0, 0);
mir_snprintf(fn, "fn%d", i);
SendDlgItemMessage(hwnd, IDC_FILE_CONTENTS, LB_RESETCONTENT, 0, 0);
@@ -170,7 +176,7 @@ INT_PTR CALLBACK DlgProcFiles(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
switch (LOWORD(wParam)) {
case IDC_ADD_URL:
if (GetWindowTextLength(GetDlgItem(hwnd, IDC_URL))) {
- char text[512], url[512], fn[10] = "fn0", szFileName[MAX_PATH], temp[512];
+ char text[512], url[512], szFileName[MAX_PATH], temp[512];
int i, timer;
GetDlgItemTextA(hwnd, IDC_URL, text, _countof(text));
mir_strcpy(url, text);
@@ -202,9 +208,10 @@ INT_PTR CALLBACK DlgProcFiles(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
if (HIWORD(wParam) == EN_CHANGE)
SendMessage(GetParent(hwnd), PSM_CHANGED, 0, 0);
break;
+
case IDC_ADD_FILE:
int i, index;
- char file[MAX_PATH], fn[6];
+ char file[MAX_PATH];
for (i = 0;; i++) {
mir_snprintf(fn, "fn%d", i);
if (!db_get_static(NULL, MODNAME, fn, file, _countof(file)))
@@ -222,9 +229,8 @@ INT_PTR CALLBACK DlgProcFiles(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
break;
case IDC_DEL_FILE:
- char fn1[4], tmp[256];
+ index = SendDlgItemMessage(hwnd, IDC_FILE_LIST, CB_GETCURSEL, 0, 0), i = (int)SendDlgItemMessage(hwnd, IDC_FILE_LIST, CB_GETITEMDATA, index, 0);
{
- int index = SendDlgItemMessage(hwnd, IDC_FILE_LIST, CB_GETCURSEL, 0, 0), i = (int)SendDlgItemMessage(hwnd, IDC_FILE_LIST, CB_GETITEMDATA, index, 0);
int count = SendDlgItemMessage(hwnd, IDC_FILE_LIST, CB_GETCOUNT, 0, 0) - 1;
if (index == count) {
mir_snprintf(fn, "fn%d", index);
@@ -239,6 +245,7 @@ INT_PTR CALLBACK DlgProcFiles(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
}
else {
mir_snprintf(fn, "fn%d", i);
+ char fn1[4];
while (db_get_static(NULL, MODNAME, fn, tmp, _countof(tmp))) {
mir_snprintf(fn1, "fn%d", i - 1);
db_set_s(NULL, MODNAME, fn1, tmp);
@@ -254,8 +261,7 @@ INT_PTR CALLBACK DlgProcFiles(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
case IDC_FILE_LIST:
if (HIWORD(wParam) == CBN_SELCHANGE) {
- int index = SendDlgItemMessage(hwnd, IDC_FILE_LIST, CB_GETCURSEL, 0, 0);
- char fn[20], tmp[MAX_PATH];
+ index = SendDlgItemMessage(hwnd, IDC_FILE_LIST, CB_GETCURSEL, 0, 0);
SetDlgItemTextA(hwnd, IDC_FN, _itoa(index, fn, 10));
mir_snprintf(fn, "fn%d", index);
if (db_get_static(NULL, MODNAME, fn, tmp, _countof(tmp))) {
@@ -285,7 +291,7 @@ INT_PTR CALLBACK DlgProcFiles(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
case PSN_APPLY:
int i = SendDlgItemMessage(hwnd, IDC_FILE_LIST, CB_GETCURSEL, 0, 0);
int timer;
- char fn[MAX_PATH], string[1000];
+ char string[1000];
mir_snprintf(fn, "fn%d", i);
if (GetWindowTextLength(GetDlgItem(hwnd, IDC_WWW_TIMER))) {
TCHAR text[5];
diff --git a/plugins/Non-IM Contact/src/main.cpp b/plugins/Non-IM Contact/src/main.cpp
index 7c431bb8e3..15c251fb5b 100644
--- a/plugins/Non-IM Contact/src/main.cpp
+++ b/plugins/Non-IM Contact/src/main.cpp
@@ -7,7 +7,7 @@
#include "Version.h"
CLIST_INTERFACE *pcli;
-HINSTANCE hInst;
+HINSTANCE g_hInst;
int hLangpack;
PLUGININFOEX pluginInfoEx = {
@@ -27,7 +27,7 @@ PLUGININFOEX pluginInfoEx = {
INT_PTR doubleClick(WPARAM wParam, LPARAM)
{
char program[MAX_PATH], params[MAX_PATH];
- int shellEXEerror = 0;
+ INT_PTR shellEXEerror = 0;
char* proto = GetContactProto(wParam);
if (proto && !mir_strcmp(proto, MODNAME)) {
if (GetKeyState(VK_CONTROL) & 0x8000) // ctrl is pressed
@@ -37,7 +37,8 @@ INT_PTR doubleClick(WPARAM wParam, LPARAM)
mir_strcpy(params, "");
if (strstr(program, "http://") || strstr(program, "https://"))
Utils_OpenUrl(program);
- else shellEXEerror = (int)ShellExecuteA(NULL, NULL, program, params, NULL, SW_SHOW); //ignore the warning, its M$'s backwards compatabilty screwup :)
+ else
+ shellEXEerror = (INT_PTR)ShellExecuteA(NULL, NULL, program, params, NULL, SW_SHOW); //ignore the warning, its M$'s backwards compatabilty screwup :)
if (shellEXEerror == ERROR_FILE_NOT_FOUND || shellEXEerror == ERROR_PATH_NOT_FOUND)
Utils_OpenUrl(program);
}
@@ -62,7 +63,7 @@ int LCStatus = ID_STATUS_OFFLINE;
int NimcOptInit(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = { 0 };
- odp.hInstance = hInst;
+ odp.hInstance = g_hInst;
odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPTIONS);
odp.pszGroup = LPGEN("Plugins");
odp.pszTitle = LPGEN("Non-IM Contacts");
@@ -91,7 +92,7 @@ extern "C" __declspec(dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD)
BOOL WINAPI DllMain(HINSTANCE hinst, DWORD, LPVOID)
{
- hInst = hinst;
+ g_hInst = hinst;
return TRUE;
}
@@ -118,7 +119,7 @@ extern "C" __declspec(dllexport) int Load()
mir_getLP(&pluginInfoEx);
mir_getCLI();
- Icon_Register(hInst, LPGEN("Non-IM Contact"), icoList, _countof(icoList));
+ Icon_Register(g_hInst, LPGEN("Non-IM Contact"), icoList, _countof(icoList));
HookEvent(ME_CLIST_DOUBLECLICKED, (MIRANDAHOOK)doubleClick);
HookEvent(ME_OPT_INITIALISE, NimcOptInit);
diff --git a/plugins/Non-IM Contact/src/stdafx.h b/plugins/Non-IM Contact/src/stdafx.h
index 099240c3cf..c6494d2f46 100644
--- a/plugins/Non-IM Contact/src/stdafx.h
+++ b/plugins/Non-IM Contact/src/stdafx.h
@@ -69,7 +69,7 @@ struct DLGTEMPLATEEX
// Defines
//=======================================================
//General
-extern HINSTANCE hInst;
+extern HINSTANCE g_hInst;
extern int LCStatus;
extern IconItem icoList[];