summaryrefslogtreecommitdiff
path: root/menuitems.c
diff options
context:
space:
mode:
authorGluzskiy Alexandr <sss123next@list.ru>2010-04-05 19:30:17 +0300
committerGluzskiy Alexandr <sss123next@list.ru>2010-04-05 19:30:17 +0300
commitd7730685516d6ed6fc278a6ea74f7a5cf12e0042 (patch)
tree41a381fbe4051ed4b9041f5596913b6c174cf9be /menuitems.c
parent7fd9fe181150f166a098eaf4e006f878c28cb770 (diff)
dos2unixspamfilter
Diffstat (limited to 'menuitems.c')
-rw-r--r--menuitems.c270
1 files changed, 135 insertions, 135 deletions
diff --git a/menuitems.c b/menuitems.c
index ff0412e..9bb5745 100644
--- a/menuitems.c
+++ b/menuitems.c
@@ -1,136 +1,136 @@
-/*
-
-"Spam Filter"-Plugin for Miranda IM
-
-Copyright 2003-2006 Heiko Herkenrath
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program ("SpamFilter-License.txt"); if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-
-// -- Includes
-#include "common.h"
-
-// -- Variables: Events/Hooks
-HANDLE hHookPreBuildContactMenu;
-HANDLE hHookIconsChanged;
-
-
-// -----------------------------------------
-
-
-// -- Contact Menu Items --
-
-void SetContactMenuItem_Mark(BOOL bShowItem)
-{
- static HANDLE hContactMenuItemMark = NULL;
- CLISTMENUITEM cmi;
-
- ZeroMemory(&cmi, sizeof(cmi));
- cmi.cbSize = sizeof(cmi);
- cmi.flags = CMIF_NOTONLIST;
- if (!bShowItem) cmi.flags |= CMIF_HIDDEN;
- cmi.hIcon = SkinGetIcon(DB_ICON_SPAMMANUALLY_SETTING, IDI_DEFAULT, FALSE);
-
- if (hContactMenuItemMark)
- {
- cmi.flags |= CMIM_FLAGS|CMIM_ICON;
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hContactMenuItemMark, (LPARAM)&cmi);
-
- } else {
-
- cmi.pszName = Translate("&Mark as spammer");
- cmi.position = -2050000001; // "Add user to contact list"/"Add permanently to list" is -2050000000
- cmi.pszService = MS_SPAMFILTER_CONTACT_SHOWSETASSPAMMERDIALOG;
-
- hContactMenuItemMark = (HANDLE)CallService(MS_CLIST_ADDCONTACTMENUITEM, 0, (LPARAM)&cmi);
- }
-}
-
-
-void SetContactMenuItem_Unmark(BOOL bShowItem)
-{
- static HANDLE hContactMenuItemUnmark = NULL;
- CLISTMENUITEM cmi;
-
- ZeroMemory(&cmi, sizeof(cmi));
- cmi.cbSize = sizeof(cmi);
- cmi.flags = CMIF_NOTOFFLIST;
- if (!bShowItem) cmi.flags |= CMIF_HIDDEN;
- cmi.hIcon = SkinGetIcon(DB_ICON_SPAMMANUALLY_SETTING, IDI_DEFAULT, FALSE);
-
- if (hContactMenuItemUnmark)
- {
- cmi.flags |= CMIM_FLAGS|CMIM_ICON;
- CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hContactMenuItemUnmark, (LPARAM)&cmi);
-
- } else {
-
- cmi.pszName = Translate("&Unmark spammer");
- cmi.position = -2050000001; // "Add user to contact list"/"Add permanently to list" is -2050000000
- cmi.pszService = MS_SPAMFILTER_CONTACT_UNSETSPAMMER;
-
- hContactMenuItemUnmark = (HANDLE)CallService(MS_CLIST_ADDCONTACTMENUITEM, 0, (LPARAM)&cmi);
- }
-}
-
-
-static int IconsChanged(WPARAM wParam, LPARAM lParam)
-{
- // Update menu item
- SetContactMenuItem_Mark(TRUE);
- SetContactMenuItem_Unmark(FALSE);
- return 0;
-}
-
-
-static int PreBuildContactMenu(WPARAM wParam, LPARAM lParam)
-{
- HANDLE hContact = (HANDLE)wParam;
- char* pszProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
-
- if (hContact && pszProto)
- if (!DBGetContactSettingByte(hContact, pszProto, "ChatRoom", 0))
- {
- BOOL bNotOnList = DBGetContactSettingByte(hContact, "CList", "NotOnList", 0);
- BOOL bIsSpammer = DBGetContactSettingByte((HANDLE)wParam, DB_MODULE_NAME, DB_SETTING_ISSPAMMER, (BYTE)FALSE);
-
- SetContactMenuItem_Mark(bNotOnList && !bIsSpammer);
- SetContactMenuItem_Unmark(bIsSpammer && !IsWindow(hwndSpammersInfo));
- }
-
- return 0;
-}
-
-
-// -----------------------------------------
-
-
-void InitMenuItems(void)
-{
- if (ServiceExists(MS_SKIN2_GETICON))
- hHookIconsChanged = HookEvent(ME_SKIN2_ICONSCHANGED, IconsChanged);
-
- hHookPreBuildContactMenu = HookEvent(ME_CLIST_PREBUILDCONTACTMENU, PreBuildContactMenu);
-
- SetContactMenuItem_Mark(TRUE);
- SetContactMenuItem_Unmark(FALSE);
-}
-
-void UninitMenuItems(void)
-{
- if (hHookPreBuildContactMenu) UnhookEvent(hHookPreBuildContactMenu);
- if (hHookIconsChanged) UnhookEvent(hHookIconsChanged);
+/*
+
+"Spam Filter"-Plugin for Miranda IM
+
+Copyright 2003-2006 Heiko Herkenrath
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program ("SpamFilter-License.txt"); if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+
+// -- Includes
+#include "common.h"
+
+// -- Variables: Events/Hooks
+HANDLE hHookPreBuildContactMenu;
+HANDLE hHookIconsChanged;
+
+
+// -----------------------------------------
+
+
+// -- Contact Menu Items --
+
+void SetContactMenuItem_Mark(BOOL bShowItem)
+{
+ static HANDLE hContactMenuItemMark = NULL;
+ CLISTMENUITEM cmi;
+
+ ZeroMemory(&cmi, sizeof(cmi));
+ cmi.cbSize = sizeof(cmi);
+ cmi.flags = CMIF_NOTONLIST;
+ if (!bShowItem) cmi.flags |= CMIF_HIDDEN;
+ cmi.hIcon = SkinGetIcon(DB_ICON_SPAMMANUALLY_SETTING, IDI_DEFAULT, FALSE);
+
+ if (hContactMenuItemMark)
+ {
+ cmi.flags |= CMIM_FLAGS|CMIM_ICON;
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hContactMenuItemMark, (LPARAM)&cmi);
+
+ } else {
+
+ cmi.pszName = Translate("&Mark as spammer");
+ cmi.position = -2050000001; // "Add user to contact list"/"Add permanently to list" is -2050000000
+ cmi.pszService = MS_SPAMFILTER_CONTACT_SHOWSETASSPAMMERDIALOG;
+
+ hContactMenuItemMark = (HANDLE)CallService(MS_CLIST_ADDCONTACTMENUITEM, 0, (LPARAM)&cmi);
+ }
+}
+
+
+void SetContactMenuItem_Unmark(BOOL bShowItem)
+{
+ static HANDLE hContactMenuItemUnmark = NULL;
+ CLISTMENUITEM cmi;
+
+ ZeroMemory(&cmi, sizeof(cmi));
+ cmi.cbSize = sizeof(cmi);
+ cmi.flags = CMIF_NOTOFFLIST;
+ if (!bShowItem) cmi.flags |= CMIF_HIDDEN;
+ cmi.hIcon = SkinGetIcon(DB_ICON_SPAMMANUALLY_SETTING, IDI_DEFAULT, FALSE);
+
+ if (hContactMenuItemUnmark)
+ {
+ cmi.flags |= CMIM_FLAGS|CMIM_ICON;
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hContactMenuItemUnmark, (LPARAM)&cmi);
+
+ } else {
+
+ cmi.pszName = Translate("&Unmark spammer");
+ cmi.position = -2050000001; // "Add user to contact list"/"Add permanently to list" is -2050000000
+ cmi.pszService = MS_SPAMFILTER_CONTACT_UNSETSPAMMER;
+
+ hContactMenuItemUnmark = (HANDLE)CallService(MS_CLIST_ADDCONTACTMENUITEM, 0, (LPARAM)&cmi);
+ }
+}
+
+
+static int IconsChanged(WPARAM wParam, LPARAM lParam)
+{
+ // Update menu item
+ SetContactMenuItem_Mark(TRUE);
+ SetContactMenuItem_Unmark(FALSE);
+ return 0;
+}
+
+
+static int PreBuildContactMenu(WPARAM wParam, LPARAM lParam)
+{
+ HANDLE hContact = (HANDLE)wParam;
+ char* pszProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+
+ if (hContact && pszProto)
+ if (!DBGetContactSettingByte(hContact, pszProto, "ChatRoom", 0))
+ {
+ BOOL bNotOnList = DBGetContactSettingByte(hContact, "CList", "NotOnList", 0);
+ BOOL bIsSpammer = DBGetContactSettingByte((HANDLE)wParam, DB_MODULE_NAME, DB_SETTING_ISSPAMMER, (BYTE)FALSE);
+
+ SetContactMenuItem_Mark(bNotOnList && !bIsSpammer);
+ SetContactMenuItem_Unmark(bIsSpammer && !IsWindow(hwndSpammersInfo));
+ }
+
+ return 0;
+}
+
+
+// -----------------------------------------
+
+
+void InitMenuItems(void)
+{
+ if (ServiceExists(MS_SKIN2_GETICON))
+ hHookIconsChanged = HookEvent(ME_SKIN2_ICONSCHANGED, IconsChanged);
+
+ hHookPreBuildContactMenu = HookEvent(ME_CLIST_PREBUILDCONTACTMENU, PreBuildContactMenu);
+
+ SetContactMenuItem_Mark(TRUE);
+ SetContactMenuItem_Unmark(FALSE);
+}
+
+void UninitMenuItems(void)
+{
+ if (hHookPreBuildContactMenu) UnhookEvent(hHookPreBuildContactMenu);
+ if (hHookIconsChanged) UnhookEvent(hHookIconsChanged);
} \ No newline at end of file