summaryrefslogtreecommitdiff
path: root/plugins/NoHistory/src
diff options
context:
space:
mode:
authorVadim Dashevskiy <watcherhd@gmail.com>2012-11-24 14:08:08 +0000
committerVadim Dashevskiy <watcherhd@gmail.com>2012-11-24 14:08:08 +0000
commit669813f9a07f0a8936a19f124aa6b5ae96840f8a (patch)
treedbb82dcf72291328be77ff0d46c34a90ea1c2a37 /plugins/NoHistory/src
parent67ea1476b00f5069633d585342d5b707d2bcb6a7 (diff)
NoHistory and NotesAndReminders added to full slns
git-svn-id: http://svn.miranda-ng.org/main/trunk@2462 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/NoHistory/src')
-rw-r--r--plugins/NoHistory/src/common.h43
-rw-r--r--plugins/NoHistory/src/dllmain.cpp375
-rw-r--r--plugins/NoHistory/src/icons.cpp49
-rw-r--r--plugins/NoHistory/src/icons.h9
-rw-r--r--plugins/NoHistory/src/options.cpp253
-rw-r--r--plugins/NoHistory/src/options.h9
-rw-r--r--plugins/NoHistory/src/private.h24
-rw-r--r--plugins/NoHistory/src/resource.h26
-rw-r--r--plugins/NoHistory/src/stdafx.cpp18
9 files changed, 806 insertions, 0 deletions
diff --git a/plugins/NoHistory/src/common.h b/plugins/NoHistory/src/common.h
new file mode 100644
index 0000000000..060be9624a
--- /dev/null
+++ b/plugins/NoHistory/src/common.h
@@ -0,0 +1,43 @@
+#define MIRANDA_VER 0x800
+
+#ifndef _COMMON_INC
+#define _COMMON_INC
+
+#define _WIN32_WINNT 0x0501
+#define _WIN32_IE 0x0500
+
+#include <stdio.h>
+
+#include <windows.h>
+#include <commctrl.h>
+
+#include <win2k.h>
+#include <newpluginapi.h>
+#include <m_system.h>
+#include <m_database.h>
+#include <m_clist.h>
+#include <m_clc.h>
+#include <m_langpack.h>
+#include <m_protocols.h>
+#include <m_options.h>
+#include <m_message.h>
+#include <m_icolib.h>
+
+#include <m_utils.h>
+
+#define MODULE "NoHistory"
+#define DBSETTING_REMOVE "RemoveHistory"
+
+extern HINSTANCE hInst;
+
+#ifndef MIID_NOHISTORY
+#define MIID_NOHISTORY {0xe9ba130e, 0x9927, 0x4469, { 0xb6, 0x19, 0x95, 0x61, 0xa8, 0xc0, 0x57, 0xa7}}
+#endif
+
+#endif
+
+
+void SrmmMenu_Load();
+void SrmmMenu_Unload();
+
+
diff --git a/plugins/NoHistory/src/dllmain.cpp b/plugins/NoHistory/src/dllmain.cpp
new file mode 100644
index 0000000000..2a76dc620a
--- /dev/null
+++ b/plugins/NoHistory/src/dllmain.cpp
@@ -0,0 +1,375 @@
+/* Replace "dll.h" with the name of your header */
+#include "common.h"
+#include "private.h"
+#include "resource.h"
+#include "icons.h"
+#include "options.h"
+
+#include <time.h>
+
+///////////////////////////////////////////////
+// Common Plugin Stuff
+///////////////////////////////////////////////
+HINSTANCE hInst;
+int hLangpack = 0;
+
+// add icon to srmm status icons
+static void SrmmMenu_UpdateIcon(HANDLE hContact);
+static int SrmmMenu_ProcessEvent(WPARAM wParam, LPARAM lParam);
+static int SrmmMenu_ProcessIconClick(WPARAM wParam, LPARAM lParam);
+
+
+HANDLE hEventDbEventAdded, hEventMenuPrebuild, hMenuToggle, hMenuClear, hServiceToggle, hServiceClear, hEventWindow, hEventIconPressed;
+
+CRITICAL_SECTION list_cs;
+
+#define MS_NOHISTORY_TOGGLE MODULE "/ToggleOnOff"
+#define MS_NOHISTORY_CLEAR MODULE "/Clear"
+
+#define DBSETTING_REMOVE "RemoveHistory"
+
+// a list of db events - we'll check them for the 'read' flag periodically and delete them whwen marked as read
+struct EventListNode {
+ HANDLE hContact, hDBEvent;
+ EventListNode *next;
+};
+
+EventListNode *event_list = 0;
+
+// plugin stuff
+PLUGININFOEX pluginInfo={
+ sizeof(PLUGININFOEX),
+ MODULE,
+ PLUGIN_MAKE_VERSION(VER_MAJOR, VER_MINOR, VER_RELEASE, VER_BUILD),
+ DESC_STRING,
+ "Scott Ellis, NightFox",
+ "mail@scottellis.com.au; nightfox@myied.org",
+ "© 2005 Scott Ellis; NightFox 2010",
+ "http://www.scottellis.com.au/",
+ UNICODE_AWARE, //not transient
+ { 0xb25e8c7b, 0x292b, 0x495a, { 0x9f, 0xb8, 0xa4, 0xc3, 0xd4, 0xee, 0xb0, 0x4b } } // {B25E8C7B-292B-495a-9FB8-A4C3D4EEB04B}
+};
+
+extern "C" BOOL APIENTRY DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved) {
+ hInst=hinstDLL;
+ return TRUE;
+}
+
+extern "C" __declspec (dllexport) PLUGININFOEX* MirandaPluginInfoEx(DWORD mirandaVersion) {
+ return &pluginInfo;
+}
+
+static const MUUID interfaces[] = {MIID_NOHISTORY, MIID_LAST};
+extern "C" __declspec(dllexport) const MUUID* MirandaPluginInterfaces(void) {
+ return interfaces;
+}
+
+
+
+void RemoveReadEvents(HANDLE hContact = 0) {
+ DBEVENTINFO info = {0};
+ info.cbSize = sizeof(info);
+ bool remove;
+
+ EnterCriticalSection(&list_cs);
+ EventListNode *node = event_list, *prev = 0;
+ while(node) {
+ remove = false;
+ if(hContact == 0 || hContact == node->hContact) {
+ info.cbBlob = 0;
+ if(!CallService(MS_DB_EVENT_GET, (WPARAM)node->hDBEvent, (LPARAM)&info)) {
+ if((info.flags & DBEF_READ) || (info.flags & DBEF_SENT)) // note: already checked event type when added to list
+ remove = true;
+ } else {
+ // could not get event info - maybe someone else deleted it - so remove list node
+ remove = true;
+ }
+ }
+
+ if(remove) {
+ if(DBGetContactSettingByte(node->hContact, MODULE, DBSETTING_REMOVE, 0)) // is history disabled for this contact?
+ CallService(MS_DB_EVENT_DELETE, (WPARAM)node->hContact, (LPARAM)node->hDBEvent);
+
+ // remove list node anyway
+ if(event_list == node) event_list = node->next;
+ if(prev) prev->next = node->next;
+
+ free(node);
+
+ if(prev) node = prev->next;
+ else node = event_list;
+ } else {
+ prev = node;
+ node = node->next;
+ }
+ }
+
+ LeaveCriticalSection(&list_cs);
+}
+
+void RemoveAllEvents(HANDLE hContact) {
+ HANDLE hDBEvent = (HANDLE)CallService(MS_DB_EVENT_FINDFIRST, (WPARAM)hContact, 0), hDBEventNext;
+ while(hDBEvent) {
+ hDBEventNext = (HANDLE)CallService(MS_DB_EVENT_FINDNEXT, (WPARAM)hDBEvent, 0);
+ CallService(MS_DB_EVENT_DELETE, (WPARAM)hContact, (LPARAM)hDBEvent);
+ hDBEvent = hDBEventNext;
+ }
+
+}
+
+void CALLBACK TimerProc(HWND hWnd, UINT uMsg, UINT idEvent, DWORD dwTime) {
+ RemoveReadEvents();
+}
+
+
+int OnDatabaseEventAdd(WPARAM wParam, LPARAM lParam) {
+ HANDLE hContact = (HANDLE)wParam, hDBEvent = (HANDLE)lParam;
+
+ // history not disabled for this contact
+ if(DBGetContactSettingByte(hContact, MODULE, DBSETTING_REMOVE, 0) == 0)
+ return 0;
+
+ DBEVENTINFO info = {0};
+ info.cbSize = sizeof(info);
+ if(!CallService(MS_DB_EVENT_GET, (WPARAM)hDBEvent, (LPARAM)&info)) {
+ if(info.eventType == EVENTTYPE_MESSAGE) {
+ EventListNode *node = (EventListNode *)malloc(sizeof(EventListNode));
+ node->hContact = hContact;
+ node->hDBEvent = hDBEvent;
+
+ EnterCriticalSection(&list_cs);
+ node->next = event_list;
+ event_list = node;
+ LeaveCriticalSection(&list_cs);
+ }
+ }
+
+ return 0;
+}
+
+
+INT_PTR ServiceClear(WPARAM wParam, LPARAM lParam) {
+ if(MessageBox(0, TranslateT("This operation will PERMANENTLY REMOVE all history for this contact.\nAre you sure you want to do this?"), TranslateT("Clear History"), MB_YESNO | MB_ICONWARNING) == IDYES) {
+ HANDLE hContact = (HANDLE)wParam;
+ RemoveAllEvents(hContact);
+ }
+
+ return 0;
+}
+
+int PrebuildContactMenu(WPARAM wParam, LPARAM lParam) {
+ HANDLE hContact = (HANDLE)wParam;
+
+ bool remove = (DBGetContactSettingByte(hContact, MODULE, DBSETTING_REMOVE, 0) != 0);
+ char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+ bool chat_room = (proto && DBGetContactSettingByte(hContact, proto, "ChatRoom", 0) != 0);
+
+ CLISTMENUITEM mi = {0};
+ mi.cbSize = sizeof(mi);
+
+ mi.flags = CMIM_FLAGS|CMIF_TCHAR;
+ if(chat_room) mi.flags |= CMIF_HIDDEN;
+ else {
+ mi.flags |= (CMIM_NAME | CMIM_ICON);
+ mi.ptszName = (remove ? LPGENT("Enable History") : LPGENT("Disable History"));
+ mi.hIcon = (remove ? hIconKeep : hIconRemove);
+ }
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuToggle, (LPARAM)&mi);
+
+ mi.flags = CMIM_FLAGS;
+ if(chat_room) mi.flags |= CMIF_HIDDEN;
+ else {
+ int event_count = (int)CallService(MS_DB_EVENT_GETCOUNT, (WPARAM)hContact, 0);
+ if(event_count <= 0) mi.flags |= CMIF_HIDDEN;
+ }
+ CallService(MS_CLIST_MODIFYMENUITEM, (WPARAM)hMenuClear, (LPARAM)&mi);
+
+ return 0;
+}
+
+INT_PTR ServiceToggle(WPARAM wParam, LPARAM lParam) {
+ HANDLE hContact = (HANDLE)wParam;
+
+ int remove = (DBGetContactSettingByte(hContact, MODULE, DBSETTING_REMOVE, 0) != 0);
+ remove = !remove;
+ DBWriteContactSettingByte(hContact, MODULE, DBSETTING_REMOVE, (remove ? 1 : 0));
+
+ StatusIconData sid = {0};
+ sid.cbSize = sizeof(sid);
+ sid.szModule = MODULE;
+
+
+ for (int i = 0; i < 2; ++i)
+ {
+ sid.dwId = i;
+ sid.flags = (i == remove) ? 0 : MBF_HIDDEN;
+ CallService(MS_MSG_MODIFYICON, (WPARAM)hContact, (LPARAM)&sid);
+ }
+/*
+ sid.dwId = 0;
+ sid.flags = (remove ? MBF_DISABLED : 0);
+ CallService(MS_MSG_MODIFYICON, (WPARAM)hContact, (LPARAM)&sid);
+*/
+ return 0;
+}
+
+int WindowEvent(WPARAM wParam, LPARAM lParam) {
+ MessageWindowEventData *mwd = (MessageWindowEventData *)lParam;
+ HANDLE hContact = mwd->hContact;
+ int remove = (DBGetContactSettingByte(hContact, MODULE, DBSETTING_REMOVE, 0) != 0);
+
+ if(mwd->uType == MSG_WINDOW_EVT_CLOSE) {
+ RemoveReadEvents(hContact);
+ return 0;
+ }
+
+ if(mwd->uType != MSG_WINDOW_EVT_OPEN) return 0;
+
+ if(!ServiceExists(MS_MSG_MODIFYICON)) return 0;
+
+ char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+ bool chat_room = (proto && DBGetContactSettingByte(hContact, proto, "ChatRoom", 0) != 0);
+
+
+
+ StatusIconData sid = {0};
+ sid.cbSize = sizeof(sid);
+ sid.szModule = MODULE;
+/*
+ sid.dwId = 0;
+ sid.flags = (chat_room ? MBF_HIDDEN : (remove ? MBF_DISABLED : 1));
+ CallService(MS_MSG_MODIFYICON, (WPARAM)hContact, (LPARAM)&sid);
+*/
+
+ for (int i = 0; i < 2; ++i)
+ {
+ sid.dwId = i;
+ sid.flags = (chat_room ? MBF_HIDDEN : (i == remove) ? 0 : MBF_HIDDEN);
+ CallService(MS_MSG_MODIFYICON, (WPARAM)hContact, (LPARAM)&sid);
+ }
+
+
+
+ return 0;
+}
+
+
+int IconPressed(WPARAM wParam, LPARAM lParam) {
+ HANDLE hContact = (HANDLE)wParam;
+ StatusIconClickData *sicd = (StatusIconClickData *)lParam;
+ if(sicd->cbSize < (int)sizeof(StatusIconClickData))
+ return 0;
+
+ if(sicd->flags & MBCF_RIGHTBUTTON) return 0; // ignore right-clicks
+ if(strcmp(sicd->szModule, MODULE) != 0) return 0; // not our event
+
+ char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+ bool chat_room = (proto && DBGetContactSettingByte(hContact, proto, "ChatRoom", 0) != 0);
+
+ if(!chat_room) ServiceToggle((WPARAM)hContact, 0);
+
+ return 0;
+}
+
+
+// add icon to srmm status icons
+void SrmmMenu_Load()
+{
+ if(ServiceExists(MS_MSG_ADDICON)) {
+ StatusIconData sid = {0};
+ sid.cbSize = sizeof(sid);
+ sid.szModule = MODULE;
+ sid.flags = 0;
+ sid.dwId = 0;
+// sid.hIcon = hIconKeep;
+// sid.hIconDisabled = hIconRemove;
+
+ sid.szTooltip = Translate("History Enabled");
+ sid.hIcon = sid.hIconDisabled = hIconKeep;
+
+ CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid);
+
+ sid.dwId = 1;
+ sid.szTooltip = Translate("History Disabled");
+ sid.hIcon = sid.hIconDisabled = hIconRemove;
+ CallService(MS_MSG_ADDICON, 0, (LPARAM)&sid);
+
+
+ // hook the window events so that we can can change the status of the icon
+ hEventWindow = HookEvent(ME_MSG_WINDOWEVENT, WindowEvent);
+ hEventIconPressed = HookEvent(ME_MSG_ICONPRESSED, IconPressed);
+ }
+
+
+}
+
+int ModulesLoaded(WPARAM wParam, LPARAM lParam) {
+ InitIcons();
+
+ // create contact menu item
+ CLISTMENUITEM mi = {0};
+ mi.cbSize = sizeof(mi);
+ mi.flags = CMIF_TCHAR;
+
+ mi.position = -300010;
+ mi.ptszName = LPGENT("Disable History");
+ mi.pszService = MS_NOHISTORY_TOGGLE;
+ mi.hIcon = hIconRemove;
+ hMenuToggle = Menu_AddMainMenuItem(&mi);
+
+ mi.position = -300005;
+ mi.ptszName = LPGENT("Clear History");
+ mi.pszService = MS_NOHISTORY_CLEAR;
+ mi.hIcon = hIconClear;
+ hMenuClear = Menu_AddMainMenuItem(&mi);
+
+ // add icon to srmm status icons
+ SrmmMenu_Load();
+
+ return 0;
+}
+
+
+HANDLE hModulesLoaded;
+extern "C" __declspec (dllexport) int Load() {
+ InitializeCriticalSection(&list_cs);
+ mir_getLP(&pluginInfo);
+
+ // Ensure that the common control DLL is loaded (for listview)
+ INITCOMMONCONTROLSEX icex;
+ icex.dwSize = sizeof(INITCOMMONCONTROLSEX);
+ icex.dwICC = ICC_LISTVIEW_CLASSES;
+ InitCommonControlsEx(&icex);
+
+ InitOptions();
+
+ hEventMenuPrebuild = HookEvent(ME_CLIST_PREBUILDCONTACTMENU, PrebuildContactMenu);
+ // hooked so we can track events added to the database
+ hEventDbEventAdded = HookEvent(ME_DB_EVENT_ADDED, OnDatabaseEventAdd);
+ // hook modules loaded
+ hModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
+
+ hServiceToggle = CreateServiceFunction(MS_NOHISTORY_TOGGLE, ServiceToggle);
+ hServiceClear = CreateServiceFunction(MS_NOHISTORY_CLEAR, ServiceClear);
+
+ return 0;
+}
+
+extern "C" __declspec (dllexport) int Unload(void) {
+ UnhookEvent(hEventWindow);
+ UnhookEvent(hEventIconPressed);
+
+ UnhookEvent(hModulesLoaded);
+ DeinitOptions();
+
+ UnhookEvent(hEventDbEventAdded);
+ UnhookEvent(hEventMenuPrebuild);
+ DestroyServiceFunction(hServiceToggle);
+ DestroyServiceFunction(hServiceClear);
+
+ RemoveReadEvents();
+ DeleteCriticalSection(&list_cs);
+
+ DeinitIcons();
+ return 0;
+}
diff --git a/plugins/NoHistory/src/icons.cpp b/plugins/NoHistory/src/icons.cpp
new file mode 100644
index 0000000000..6bfff6a424
--- /dev/null
+++ b/plugins/NoHistory/src/icons.cpp
@@ -0,0 +1,49 @@
+#include "common.h"
+#include "icons.h"
+#include "resource.h"
+
+HICON hIconRemove, hIconKeep, hIconClear;
+HANDLE hIcoLibIconsChanged = 0;
+
+int ReloadIcons(WPARAM wParam, LPARAM lParam) {
+ hIconRemove = Skin_GetIcon(MODULE "_remove");
+ hIconKeep = Skin_GetIcon(MODULE "_keep");
+ hIconClear = Skin_GetIcon(MODULE "_clear");
+
+ return 0;
+}
+
+void InitIcons() {
+ SKINICONDESC sid = {0};
+ sid.cbSize = sizeof(SKINICONDESC);
+
+ sid.ptszSection = _T(MODULE);
+ sid.flags = SIDF_ALL_TCHAR;
+
+ TCHAR path[MAX_PATH];
+ GetModuleFileName(hInst,path,MAX_PATH);
+
+#define AddIcon(x,y,z) \
+ sid.ptszDescription = x; \
+ sid.pszName = y; \
+ sid.ptszDefaultFile = path; \
+ sid.hDefaultIcon = (HICON)LoadImage(hInst, MAKEINTRESOURCE(z), IMAGE_ICON, 0, 0, 0); \
+ Skin_AddIcon(&sid); \
+ sid.iDefaultIndex++;
+
+ AddIcon(LPGENT("Disable"), MODULE "_remove", IDI_HREMOVE);
+ AddIcon(LPGENT("Enable"), MODULE "_keep", IDI_HKEEP);
+ AddIcon(LPGENT("Clear"), MODULE "_clear", IDI_HCLEAR);
+
+#undef AddIcon
+
+ ReloadIcons(0, 0);
+
+ hIcoLibIconsChanged = HookEvent(ME_SKIN2_ICONSCHANGED, ReloadIcons);
+
+}
+
+void DeinitIcons() {
+ if(hIcoLibIconsChanged)
+ UnhookEvent(hIcoLibIconsChanged);
+}
diff --git a/plugins/NoHistory/src/icons.h b/plugins/NoHistory/src/icons.h
new file mode 100644
index 0000000000..88fae4be67
--- /dev/null
+++ b/plugins/NoHistory/src/icons.h
@@ -0,0 +1,9 @@
+#ifndef _ICONS_INC
+#define _ICONS_INC
+
+extern HICON hIconRemove, hIconKeep, hIconClear;
+
+void InitIcons();
+void DeinitIcons();
+
+#endif
diff --git a/plugins/NoHistory/src/options.cpp b/plugins/NoHistory/src/options.cpp
new file mode 100644
index 0000000000..45b2c876eb
--- /dev/null
+++ b/plugins/NoHistory/src/options.cpp
@@ -0,0 +1,253 @@
+#include "common.h"
+#include "options.h"
+#include "resource.h"
+#include "icons.h"
+
+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);
+ //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(hChildItem) 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);
+ }
+ //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) iconOn=0;
+ if(iImage!=0xFF) childCount++;
+ hItem=(HANDLE)SendMessage(hwndList,CLM_GETNEXTITEM,CLGN_NEXTCONTACT,(LPARAM)hItem);
+ }
+ //set icons
+ SendMessage(hwndList,CLM_SETEXTRAIMAGE,(WPARAM)hParentItem,MAKELPARAM(0,childCount?(iconOn?1:0):0xFF));
+ if(groupChildCount) *groupChildCount+=childCount;
+}
+
+static void SetAllChildIcons(HWND hwndList,HANDLE hFirstItem,int iColumn,int iImage)
+{
+ HANDLE hItem;
+
+ 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(hChildItem) 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);
+ while(hItem) {
+ int iOldIcon=SendMessage(hwndList,CLM_GETEXTRAIMAGE,(WPARAM)hItem,iColumn);
+ if(iOldIcon!=0xFF && iOldIcon!=iImage) SendMessage(hwndList,CLM_SETEXTRAIMAGE,(WPARAM)hItem,MAKELPARAM(iColumn,iImage));
+ hItem=(HANDLE)SendMessage(hwndList,CLM_GETNEXTITEM,CLGN_NEXTCONTACT,(LPARAM)hItem);
+ }
+}
+
+
+static void ResetListOptions(HWND hwndList)
+{
+ SendMessage(hwndList,CLM_SETBKBITMAP,0,(LPARAM)(HBITMAP)NULL);
+ SendMessage(hwndList,CLM_SETBKCOLOR,GetSysColor(COLOR_WINDOW),0);
+ SendMessage(hwndList,CLM_SETGREYOUTFLAGS,0,0);
+ SendMessage(hwndList,CLM_SETLEFTMARGIN,2,0);
+ SendMessage(hwndList,CLM_SETINDENT,10,0);
+ for(int i=0;i<=FONTID_MAX;i++)
+ SendMessage(hwndList,CLM_SETTEXTCOLOR,i,GetSysColor(COLOR_WINDOWTEXT));
+ SetWindowLong(hwndList,GWL_STYLE,GetWindowLong(hwndList,GWL_STYLE)|CLS_SHOWHIDDEN);
+}
+
+static void SetAllContactIcons(HWND hwndList)
+{
+ HANDLE hContact = db_find_first();
+ do {
+ char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+ bool chat_room = (proto && DBGetContactSettingByte(hContact, proto, "ChatRoom", 0) != 0);
+
+ if(!chat_room) {
+ HANDLE hItem=(HANDLE)SendMessage(hwndList,CLM_FINDCONTACT,(WPARAM)hContact,0);
+ if(hItem) {
+ bool disabled = (DBGetContactSettingByte(hContact, MODULE, DBSETTING_REMOVE, 0) == 1);
+ SendMessage(hwndList,CLM_SETEXTRAIMAGE,(WPARAM)hItem,MAKELPARAM(0,disabled?1:0));
+ }
+ }
+ } while(hContact = db_find_next(hContact));
+}
+
+
+
+static INT_PTR CALLBACK DlgProcOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
+ static HANDLE hItemAll;
+
+ switch ( msg ) {
+ case WM_INITDIALOG:
+ TranslateDialogDefault( hwndDlg );
+ { HIMAGELIST hIml;
+ hIml=ImageList_Create(GetSystemMetrics(SM_CXSMICON),GetSystemMetrics(SM_CYSMICON),(IsWinVerXPPlus()?ILC_COLOR32:ILC_COLOR16)|ILC_MASK,2,2);
+ ImageList_AddIcon(hIml,hIconKeep);
+ ImageList_AddIcon(hIml,hIconRemove);
+ SendDlgItemMessage(hwndDlg,IDC_LIST,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);
+ }
+
+ ResetListOptions(GetDlgItem(hwndDlg,IDC_LIST));
+ SendDlgItemMessage(hwndDlg,IDC_LIST,CLM_SETEXTRACOLUMNS,1,0);
+
+ { CLCINFOITEM cii={0};
+ cii.cbSize=sizeof(cii);
+ cii.flags=CLCIIF_GROUPFONT;
+ cii.pszText=TranslateT("** All contacts **");
+ hItemAll=(HANDLE)SendDlgItemMessage(hwndDlg,IDC_LIST,CLM_ADDINFOITEM,0,(LPARAM)&cii);
+ }
+
+ SetAllContactIcons(GetDlgItem(hwndDlg,IDC_LIST));
+ SetListGroupIcons(GetDlgItem(hwndDlg,IDC_LIST),(HANDLE)SendDlgItemMessage(hwndDlg,IDC_LIST,CLM_GETNEXTITEM,CLGN_ROOT,0),hItemAll,NULL);
+
+ SendDlgItemMessage(hwndDlg, IDC_SPN_TIMEOUT, UDM_SETRANGE, 0, (LPARAM)MAKELONG(60 * 60, 1));
+
+ return FALSE;
+ case WM_SETFOCUS:
+ SetFocus(GetDlgItem(hwndDlg,IDC_LIST));
+ break;
+ case WM_COMMAND:
+ if ( HIWORD( wParam ) == EN_CHANGE && ( HWND )lParam == GetFocus())
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+ case WM_NOTIFY:
+ switch(((LPNMHDR)lParam)->idFrom) {
+ case IDC_LIST:
+ switch (((LPNMHDR)lParam)->code)
+ {
+ case CLN_NEWCONTACT:
+ case CLN_LISTREBUILT:
+ SetAllContactIcons(GetDlgItem(hwndDlg,IDC_LIST));
+ //fall through
+ case CLN_CONTACTMOVED:
+ SetListGroupIcons(GetDlgItem(hwndDlg,IDC_LIST),(HANDLE)SendDlgItemMessage(hwndDlg,IDC_LIST,CLM_GETNEXTITEM,CLGN_ROOT,0),hItemAll,NULL);
+ break;
+ case CLN_OPTIONSCHANGED:
+ ResetListOptions(GetDlgItem(hwndDlg,IDC_LIST));
+ break;
+ case NM_CLICK:
+ {
+ NMCLISTCONTROL *nm=(NMCLISTCONTROL*)lParam;
+ DWORD hitFlags;
+
+ // Make sure we have an extra column
+ if (nm->iColumn == -1)
+ break;
+
+ // Find clicked item
+ HANDLE hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_HITTEST, (WPARAM)&hitFlags, MAKELPARAM(nm->pt.x,nm->pt.y));
+ // Nothing was clicked
+ if (hItem == NULL) break;
+ // It was not a visbility icon
+ if (!(hitFlags & CLCHT_ONITEMEXTRA)) break;
+
+ // Get image in clicked column (0=none, 1=visible, 2=invisible)
+ int iImage = SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(nm->iColumn, 0));
+ if (iImage == 0)
+ iImage=nm->iColumn + 1;
+ else
+ if (iImage == 1)
+ iImage = 0;
+
+ // Get item type (contact, group, etc...)
+ int itemType = SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETITEMTYPE, (WPARAM)hItem, 0);
+
+ // Update list, making sure that the options are mutually exclusive
+ if (itemType == CLCIT_CONTACT) { // A contact
+ SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_SETEXTRAIMAGE, (WPARAM)hItem, MAKELPARAM(nm->iColumn, iImage));
+ }
+ else if (itemType == CLCIT_INFO) { // All Contacts
+ SetAllChildIcons(GetDlgItem(hwndDlg, IDC_LIST), hItem, nm->iColumn, iImage);
+ }
+ else if (itemType == CLCIT_GROUP) { // A group
+ hItem = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETNEXTITEM, CLGN_CHILD, (LPARAM)hItem);
+ if (hItem) {
+ SetAllChildIcons(GetDlgItem(hwndDlg, IDC_LIST), hItem, nm->iColumn, iImage);
+ }
+ }
+ // Update the all/none icons
+ SetListGroupIcons(GetDlgItem(hwndDlg, IDC_LIST), (HANDLE)SendDlgItemMessage(hwndDlg, IDC_LIST, CLM_GETNEXTITEM, CLGN_ROOT, 0), hItemAll, NULL);
+
+ // Activate Apply button
+ SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0);
+ break;
+ }
+ }
+ break;
+ case 0:
+ switch (((LPNMHDR)lParam)->code)
+ {
+ case PSN_APPLY:
+ {
+ HANDLE hContact = db_find_first();
+ do {
+ char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+ bool chat_room = (proto && DBGetContactSettingByte(hContact, proto, "ChatRoom", 0) != 0);
+
+ if(!chat_room) {
+ HANDLE hItem=(HANDLE)SendDlgItemMessage(hwndDlg,IDC_LIST,CLM_FINDCONTACT,(WPARAM)hContact,0);
+ if(hItem) {
+ int iImage=SendDlgItemMessage(hwndDlg,IDC_LIST,CLM_GETEXTRAIMAGE,(WPARAM)hItem,MAKELPARAM(0,0));
+ DBWriteContactSettingByte(hContact, MODULE, DBSETTING_REMOVE, iImage==1?1:0);
+ }
+ }
+ } while(hContact = db_find_next(hContact));
+
+ return TRUE;
+ }
+ }
+ break;
+ }
+ break;
+ case WM_DESTROY:
+ { HIMAGELIST hIml=(HIMAGELIST)SendDlgItemMessage(hwndDlg,IDC_LIST,CLM_GETEXTRAIMAGELIST,0,0);
+ ImageList_Destroy(hIml);
+ }
+ break;
+ }
+
+ return 0;
+}
+
+int OptInit(WPARAM wParam, LPARAM lParam) {
+ OPTIONSDIALOGPAGE odp = { 0 };
+ odp.cbSize = sizeof(odp);
+ odp.flags = ODPF_BOLDGROUPS|ODPF_TCHAR;
+ odp.position = -790000000;
+ odp.hInstance = hInst;
+
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT);
+ odp.ptszTitle = LPGENT("No History");
+ odp.ptszGroup = LPGENT("History");
+ odp.ptszTab = LPGENT("Logging");
+ odp.pfnDlgProc = DlgProcOpts;
+ Options_AddPage(wParam,&odp);
+
+ return 0;
+}
+
+HANDLE hEventOptInit;
+void InitOptions() {
+ hEventOptInit = HookEvent(ME_OPT_INITIALISE, OptInit);
+}
+
+void DeinitOptions() {
+ UnhookEvent(hEventOptInit);
+}
diff --git a/plugins/NoHistory/src/options.h b/plugins/NoHistory/src/options.h
new file mode 100644
index 0000000000..f9825ce47c
--- /dev/null
+++ b/plugins/NoHistory/src/options.h
@@ -0,0 +1,9 @@
+#ifndef _OPTIONS_INC
+#define _OPTIONS_INC
+
+extern DWORD event_timeout;
+
+void InitOptions();
+void DeinitOptions();
+
+#endif
diff --git a/plugins/NoHistory/src/private.h b/plugins/NoHistory/src/private.h
new file mode 100644
index 0000000000..535dd34c5f
--- /dev/null
+++ b/plugins/NoHistory/src/private.h
@@ -0,0 +1,24 @@
+#ifndef _PRIVATE_H
+#define _PRIVATE_H
+
+/* VERSION DEFINITIONS */
+#define VER_MAJOR 0
+#define VER_MINOR 2
+#define VER_RELEASE 3
+#define VER_BUILD 0
+
+#define __STRINGIZE(x) #x
+#define VER_STRING __STRINGIZE( VER_MAJOR.VER_MINOR.VER_RELEASE.VER_BUILD )
+
+#define DESC_STRING "Prevent miranda from storing any history"
+#define COMPANY_NAME ""
+#define FILE_VERSION VER_STRING
+#define FILE_DESCRIPTION DESC_STRING
+#define INTERNAL_NAME ""
+#define LEGAL_COPYRIGHT "© Scott Ellis 2005; NightFox 2010"
+#define LEGAL_TRADEMARKS ""
+#define ORIGINAL_FILENAME "no_history.dll"
+#define PRODUCT_NAME DESC_STRING
+#define PRODUCT_VERSION VER_STRING
+
+#endif /*OTR_PRIVATE_H*/
diff --git a/plugins/NoHistory/src/resource.h b/plugins/NoHistory/src/resource.h
new file mode 100644
index 0000000000..5640d91b59
--- /dev/null
+++ b/plugins/NoHistory/src/resource.h
@@ -0,0 +1,26 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by NoHistory.rc
+//
+#define IDI_HKEEP 100
+#define IDI_HREMOVE 101
+#define IDI_HCLEAR 102
+#define IDD_OPT 103
+#define IDC_LIST 1000
+#define IDC_PIC_KEEP 1001
+#define IDC_PIC_REMOVE 1002
+#define IDC_BUTTON1 1003
+#define IDC_ED_TIMEOUT 1004
+#define IDC_SPIN1 1005
+#define IDC_SPN_TIMEOUT 1005
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 104
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1006
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/plugins/NoHistory/src/stdafx.cpp b/plugins/NoHistory/src/stdafx.cpp
new file mode 100644
index 0000000000..83f7fcf281
--- /dev/null
+++ b/plugins/NoHistory/src/stdafx.cpp
@@ -0,0 +1,18 @@
+/*
+Copyright (C) 2012 Miranda NG team (http://miranda-ng.org)
+
+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 version 2
+of the License.
+
+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. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "Common.h" \ No newline at end of file