summaryrefslogtreecommitdiff
path: root/plugins/NoHistory/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-11-13 23:02:22 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-11-13 23:02:22 +0300
commit70ac0a879897a5100308f70d667267e5962060d4 (patch)
treeab9f670f8f2d4abfa21796dac0b808919a4b8e9f /plugins/NoHistory/src
parent72fc1744f87ea75f455be6084069a109b1f7c310 (diff)
NoHistory -> g_plugin
Diffstat (limited to 'plugins/NoHistory/src')
-rw-r--r--plugins/NoHistory/src/dllmain.cpp12
-rw-r--r--plugins/NoHistory/src/options.cpp112
2 files changed, 62 insertions, 62 deletions
diff --git a/plugins/NoHistory/src/dllmain.cpp b/plugins/NoHistory/src/dllmain.cpp
index 5ed96397cf..f26ddc02e6 100644
--- a/plugins/NoHistory/src/dllmain.cpp
+++ b/plugins/NoHistory/src/dllmain.cpp
@@ -68,7 +68,7 @@ void RemoveReadEvents(MCONTACT hContact = 0)
}
if (remove) {
- if (db_get_b(node->hContact, MODULENAME, DBSETTING_REMOVE, 0)) // is history disabled for this contact?
+ if (g_plugin.getByte(node->hContact, DBSETTING_REMOVE)) // is history disabled for this contact?
db_event_delete(node->hContact, node->hDBEvent);
// remove list node anyway
@@ -105,7 +105,7 @@ void CALLBACK TimerProc(HWND, UINT, UINT_PTR, DWORD)
int OnDatabaseEventAdd(WPARAM hContact, LPARAM hDBEvent)
{
// history not disabled for this contact
- if (db_get_b(hContact, MODULENAME, DBSETTING_REMOVE, 0) == 0)
+ if (g_plugin.getByte(hContact, DBSETTING_REMOVE) == 0)
return 0;
DBEVENTINFO info = {};
@@ -134,7 +134,7 @@ INT_PTR ServiceClear(WPARAM hContact, LPARAM)
int PrebuildContactMenu(WPARAM hContact, LPARAM)
{
- bool remove = db_get_b(hContact, MODULENAME, DBSETTING_REMOVE, 0) != 0;
+ bool remove = g_plugin.getByte(hContact, DBSETTING_REMOVE) != 0;
char *proto = GetContactProto(hContact);
bool chat_room = (proto && db_get_b(hContact, proto, "ChatRoom", 0) != 0);
@@ -153,9 +153,9 @@ int PrebuildContactMenu(WPARAM hContact, LPARAM)
INT_PTR ServiceToggle(WPARAM hContact, LPARAM)
{
- int remove = db_get_b(hContact, MODULENAME, DBSETTING_REMOVE, 0) != 0;
+ int remove = g_plugin.getByte(hContact, DBSETTING_REMOVE) != 0;
remove = !remove;
- db_set_b(hContact, MODULENAME, DBSETTING_REMOVE, remove != 0);
+ g_plugin.setByte(hContact, DBSETTING_REMOVE, remove != 0);
StatusIconData sid = {};
sid.szModule = MODULENAME;
@@ -181,7 +181,7 @@ int WindowEvent(WPARAM, LPARAM lParam)
case MSG_WINDOW_EVT_OPEN:
char *proto = GetContactProto(hContact);
bool chat_room = (proto && db_get_b(hContact, proto, "ChatRoom", 0) != 0);
- int remove = db_get_b(hContact, MODULENAME, DBSETTING_REMOVE, 0) != 0;
+ int remove = g_plugin.getByte(hContact, DBSETTING_REMOVE) != 0;
StatusIconData sid = {};
sid.szModule = MODULENAME;
diff --git a/plugins/NoHistory/src/options.cpp b/plugins/NoHistory/src/options.cpp
index 6c05f824ee..c7e2a35027 100644
--- a/plugins/NoHistory/src/options.cpp
+++ b/plugins/NoHistory/src/options.cpp
@@ -1,78 +1,78 @@
#include "stdafx.h"
-static void SetListGroupIcons(HWND hwndList,HANDLE hFirstItem,HANDLE hParentItem,int *groupChildCount)
+static void SetListGroupIcons(HWND hwndList, HANDLE hFirstItem, HANDLE hParentItem, int *groupChildCount)
{
int iconOn = 1;
int childCount = 0;
int iImage;
HANDLE hItem;
- int typeOfFirst = SendMessage(hwndList,CLM_GETITEMTYPE,(WPARAM)hFirstItem,0);
+ int typeOfFirst = SendMessage(hwndList, CLM_GETITEMTYPE, (WPARAM)hFirstItem, 0);
//check groups
if (typeOfFirst == CLCIT_GROUP)
hItem = hFirstItem;
else
- hItem = (HANDLE)SendMessage(hwndList,CLM_GETNEXTITEM,CLGN_NEXTGROUP,(LPARAM)hFirstItem);
- while(hItem) {
- HANDLE hChildItem = (HANDLE)SendMessage(hwndList,CLM_GETNEXTITEM,CLGN_CHILD,(LPARAM)hItem);
+ hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hFirstItem);
+ while (hItem) {
+ HANDLE hChildItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem);
if (hChildItem)
- SetListGroupIcons(hwndList,hChildItem,hItem,&childCount);
- if (iconOn && SendMessage(hwndList,CLM_GETEXTRAIMAGE,(WPARAM)hItem,0) == 0)
+ SetListGroupIcons(hwndList, hChildItem, hItem, &childCount);
+ if (iconOn && SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, 0) == 0)
iconOn = 0;
- hItem = (HANDLE)SendMessage(hwndList,CLM_GETNEXTITEM,CLGN_NEXTGROUP,(LPARAM)hItem);
+ hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hItem);
}
//check contacts
if (typeOfFirst == CLCIT_CONTACT)
hItem = hFirstItem;
else
- hItem = (HANDLE)SendMessage(hwndList,CLM_GETNEXTITEM,CLGN_NEXTCONTACT,(LPARAM)hFirstItem);
- while(hItem) {
- iImage = SendMessage(hwndList,CLM_GETEXTRAIMAGE,(WPARAM)hItem,0);
- if (iconOn && iImage==0)
+ hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hFirstItem);
+ while (hItem) {
+ iImage = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, 0);
+ if (iconOn && iImage == 0)
iconOn = 0;
if (iImage != EMPTY_EXTRA_ICON)
childCount++;
- hItem = (HANDLE)SendMessage(hwndList,CLM_GETNEXTITEM,CLGN_NEXTCONTACT,(LPARAM)hItem);
+ hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hItem);
}
//set icons
- SendMessage(hwndList,CLM_SETEXTRAIMAGE,(WPARAM)hParentItem,MAKELPARAM(0, childCount ? (iconOn ? 1 : 0) : EMPTY_EXTRA_ICON));
+ SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hParentItem, MAKELPARAM(0, childCount ? (iconOn ? 1 : 0) : EMPTY_EXTRA_ICON));
if (groupChildCount)
*groupChildCount += childCount;
}
-static void SetAllChildIcons(HWND hwndList,HANDLE hFirstItem,int iColumn,int iImage)
+static void SetAllChildIcons(HWND hwndList, HANDLE hFirstItem, int iColumn, int iImage)
{
HANDLE hItem;
- int typeOfFirst=SendMessage(hwndList,CLM_GETITEMTYPE,(WPARAM)hFirstItem,0);
+ int typeOfFirst = SendMessage(hwndList, CLM_GETITEMTYPE, (WPARAM)hFirstItem, 0);
//check groups
- if (typeOfFirst==CLCIT_GROUP) hItem=hFirstItem;
- else hItem=(HANDLE)SendMessage(hwndList,CLM_GETNEXTITEM,CLGN_NEXTGROUP,(LPARAM)hFirstItem);
- while(hItem) {
- HANDLE hChildItem = (HANDLE)SendMessage(hwndList,CLM_GETNEXTITEM,CLGN_CHILD,(LPARAM)hItem);
+ if (typeOfFirst == CLCIT_GROUP) hItem = hFirstItem;
+ else hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hFirstItem);
+ while (hItem) {
+ HANDLE hChildItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem);
if (hChildItem)
- SetAllChildIcons(hwndList,hChildItem,iColumn,iImage);
- hItem = (HANDLE)SendMessage(hwndList,CLM_GETNEXTITEM,CLGN_NEXTGROUP,(LPARAM)hItem);
+ SetAllChildIcons(hwndList, hChildItem, iColumn, iImage);
+ hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTGROUP, (LPARAM)hItem);
}
//check contacts
if (typeOfFirst == CLCIT_CONTACT)
hItem = hFirstItem;
else
- hItem = (HANDLE)SendMessage(hwndList,CLM_GETNEXTITEM,CLGN_NEXTCONTACT,(LPARAM)hFirstItem);
+ hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hFirstItem);
- while(hItem) {
- int iOldIcon = SendMessage(hwndList,CLM_GETEXTRAIMAGE,(WPARAM)hItem,iColumn);
+ while (hItem) {
+ int iOldIcon = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, iColumn);
if (iOldIcon != EMPTY_EXTRA_ICON && iOldIcon != iImage)
- SendMessage(hwndList,CLM_SETEXTRAIMAGE,(WPARAM)hItem,MAKELPARAM(iColumn,iImage));
- hItem = (HANDLE)SendMessage(hwndList,CLM_GETNEXTITEM,CLGN_NEXTCONTACT,(LPARAM)hItem);
+ SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(iColumn, iImage));
+ hItem = (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_NEXTCONTACT, (LPARAM)hItem);
}
}
static void ResetListOptions(HWND hwndList)
{
- SetWindowLongPtr(hwndList,GWL_STYLE,GetWindowLongPtr(hwndList,GWL_STYLE)|CLS_SHOWHIDDEN);
+ SetWindowLongPtr(hwndList, GWL_STYLE, GetWindowLongPtr(hwndList, GWL_STYLE) | CLS_SHOWHIDDEN);
}
static void SetAllContactIcons(HWND hwndList)
@@ -82,31 +82,31 @@ static void SetAllContactIcons(HWND hwndList)
bool chat_room = (proto && db_get_b(hContact, proto, "ChatRoom", 0) != 0);
if (!chat_room) {
- HANDLE hItem=(HANDLE)SendMessage(hwndList,CLM_FINDCONTACT,hContact,0);
+ HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, hContact, 0);
if (hItem) {
- bool disabled = (db_get_b(hContact, MODULENAME, DBSETTING_REMOVE, 0) == 1);
- SendMessage(hwndList,CLM_SETEXTRAIMAGE,(WPARAM)hItem,MAKELPARAM(0,disabled?1:0));
+ bool disabled = (g_plugin.getByte(hContact, DBSETTING_REMOVE) == 1);
+ SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(0, disabled ? 1 : 0));
}
}
}
}
-
+
static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
static HANDLE hItemAll;
static HWND hwndList;
- switch ( msg ) {
+ switch (msg) {
case WM_INITDIALOG:
- TranslateDialogDefault( hwndDlg );
+ TranslateDialogDefault(hwndDlg);
hwndList = GetDlgItem(hwndDlg, IDC_LIST);
{
HIMAGELIST hIml = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), ILC_COLOR32 | ILC_MASK, 2, 2);
ImageList_AddIcon(hIml, hIconKeep);
ImageList_AddIcon(hIml, hIconRemove);
SendMessage(hwndList, CLM_SETEXTRAIMAGELIST, 0, (LPARAM)hIml);
- SendDlgItemMessage(hwndDlg, IDC_PIC_KEEP, STM_SETICON,(WPARAM)hIconKeep, 0);
- SendDlgItemMessage(hwndDlg, IDC_PIC_REMOVE, STM_SETICON,(WPARAM)hIconRemove, 0);
+ SendDlgItemMessage(hwndDlg, IDC_PIC_KEEP, STM_SETICON, (WPARAM)hIconKeep, 0);
+ SendDlgItemMessage(hwndDlg, IDC_PIC_REMOVE, STM_SETICON, (WPARAM)hIconRemove, 0);
}
ResetListOptions(hwndList);
SendMessage(hwndList, CLM_SETEXTRACOLUMNS, 1, 0);
@@ -114,11 +114,11 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
CLCINFOITEM cii = { sizeof(cii) };
cii.flags = CLCIIF_GROUPFONT;
cii.pszText = TranslateT("** All contacts **");
- hItemAll = (HANDLE)SendMessage(hwndList,CLM_ADDINFOITEM, 0, (LPARAM)&cii);
+ hItemAll = (HANDLE)SendMessage(hwndList, CLM_ADDINFOITEM, 0, (LPARAM)&cii);
}
SetAllContactIcons(hwndList);
- SetListGroupIcons(hwndList,(HANDLE)SendMessage(hwndList,CLM_GETNEXTITEM,CLGN_ROOT,0),hItemAll,nullptr);
+ SetListGroupIcons(hwndList, (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_ROOT, 0), hItemAll, nullptr);
SendDlgItemMessage(hwndDlg, IDC_SPN_TIMEOUT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(60 * 60, 1));
return FALSE;
@@ -128,12 +128,12 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
break;
case WM_COMMAND:
- if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus())
+ if (HIWORD(wParam) == EN_CHANGE && (HWND)lParam == GetFocus())
SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
break;
case WM_NOTIFY:
- switch(((LPNMHDR)lParam)->idFrom) {
+ switch (((LPNMHDR)lParam)->idFrom) {
case IDC_LIST:
switch (((LPNMHDR)lParam)->code) {
case CLN_NEWCONTACT:
@@ -141,7 +141,7 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
SetAllContactIcons(hwndList);
//fall through
case CLN_CONTACTMOVED:
- SetListGroupIcons(hwndList,(HANDLE)SendMessage(hwndList,CLM_GETNEXTITEM,CLGN_ROOT,0),hItemAll,nullptr);
+ SetListGroupIcons(hwndList, (HANDLE)SendMessage(hwndList, CLM_GETNEXTITEM, CLGN_ROOT, 0), hItemAll, nullptr);
break;
case CLN_OPTIONSCHANGED:
@@ -150,13 +150,13 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
case NM_CLICK:
// Make sure we have an extra column
- NMCLISTCONTROL *nm=(NMCLISTCONTROL*)lParam;
+ NMCLISTCONTROL *nm = (NMCLISTCONTROL*)lParam;
if (nm->iColumn == -1)
break;
// Find clicked item
DWORD hitFlags;
- HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_HITTEST, (WPARAM)&hitFlags, MAKELPARAM(nm->pt.x,nm->pt.y));
+ HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_HITTEST, (WPARAM)&hitFlags, MAKELPARAM(nm->pt.x, nm->pt.y));
if (hItem == nullptr || !(hitFlags & CLCHT_ONITEMEXTRA))
break;
@@ -168,7 +168,7 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
iImage = 0;
// Update list, making sure that the options are mutually exclusive
- switch ( SendMessage(hwndList, CLM_GETITEMTYPE, (WPARAM)hItem, 0)) {
+ switch (SendMessage(hwndList, CLM_GETITEMTYPE, (WPARAM)hItem, 0)) {
case CLCIT_CONTACT:
SendMessage(hwndList, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(nm->iColumn, iImage));
break;
@@ -195,11 +195,11 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
char *proto = GetContactProto(hContact);
bool chat_room = (proto && db_get_b(hContact, proto, "ChatRoom", 0) != 0);
- if (!chat_room) {
- HANDLE hItem = (HANDLE)SendMessage(hwndList,CLM_FINDCONTACT,hContact,0);
+ if (!chat_room) {
+ HANDLE hItem = (HANDLE)SendMessage(hwndList, CLM_FINDCONTACT, hContact, 0);
if (hItem) {
- int iImage = SendMessage(hwndList,CLM_GETEXTRAIMAGE,(WPARAM)hItem,MAKELPARAM(0,0));
- db_set_b(hContact, MODULENAME, DBSETTING_REMOVE, iImage==1?1:0);
+ int iImage = SendMessage(hwndList, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(0, 0));
+ g_plugin.setByte(hContact, DBSETTING_REMOVE, iImage == 1);
}
}
}
@@ -209,7 +209,7 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
break;
case WM_DESTROY:
- ImageList_Destroy((HIMAGELIST)SendMessage(hwndList,CLM_GETEXTRAIMAGELIST,0,0));
+ ImageList_Destroy((HIMAGELIST)SendMessage(hwndList, CLM_GETEXTRAIMAGELIST, 0, 0));
break;
}
@@ -219,13 +219,13 @@ static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
int OptInit(WPARAM wParam, LPARAM)
{
OPTIONSDIALOGPAGE odp = {};
- odp.flags = ODPF_BOLDGROUPS|ODPF_UNICODE;
- odp.position = -790000000;
- odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT);
- odp.szTitle.w = LPGENW("No History");
- odp.szGroup.w = LPGENW("History");
- odp.szTab.w = LPGENW("Logging");
- odp.pfnDlgProc = DlgProcOpts;
+ odp.flags = ODPF_BOLDGROUPS | ODPF_UNICODE;
+ odp.position = -790000000;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT);
+ odp.szTitle.w = LPGENW("No History");
+ odp.szGroup.w = LPGENW("History");
+ odp.szTab.w = LPGENW("Logging");
+ odp.pfnDlgProc = DlgProcOpts;
g_plugin.addOptions(wParam, &odp);
return 0;
}