summaryrefslogtreecommitdiff
path: root/plugins/IEHistory/src
diff options
context:
space:
mode:
authorRené Schümann <white06tiger@gmail.com>2014-08-21 11:42:10 +0000
committerRené Schümann <white06tiger@gmail.com>2014-08-21 11:42:10 +0000
commitd33b48c34e2ce98bd5a73698006be3859a7dfbc4 (patch)
treec5e9afdeb15904a2894a781ba4c2014c6d46dc91 /plugins/IEHistory/src
parent9c029aeeab59bc44edf3fd2daf9fe83d71c2fb46 (diff)
IEHistory:
prepared file structure (project file coming with NG compatibility update) git-svn-id: http://svn.miranda-ng.org/main/trunk@10252 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/IEHistory/src')
-rw-r--r--plugins/IEHistory/src/IEHistory.cpp131
-rw-r--r--plugins/IEHistory/src/commonheaders.h84
-rw-r--r--plugins/IEHistory/src/dlgHandlers.cpp798
-rw-r--r--plugins/IEHistory/src/dlgHandlers.h50
-rw-r--r--plugins/IEHistory/src/events.cpp88
-rw-r--r--plugins/IEHistory/src/events.h35
-rw-r--r--plugins/IEHistory/src/mirandaMem.cpp42
-rw-r--r--plugins/IEHistory/src/mirandaMem.h33
-rw-r--r--plugins/IEHistory/src/resource.h45
-rw-r--r--plugins/IEHistory/src/services.cpp62
-rw-r--r--plugins/IEHistory/src/services.h32
-rw-r--r--plugins/IEHistory/src/stdafx.cpp25
-rw-r--r--plugins/IEHistory/src/stdafx.h47
-rw-r--r--plugins/IEHistory/src/utils.cpp330
-rw-r--r--plugins/IEHistory/src/utils.h97
-rw-r--r--plugins/IEHistory/src/version.h53
16 files changed, 1952 insertions, 0 deletions
diff --git a/plugins/IEHistory/src/IEHistory.cpp b/plugins/IEHistory/src/IEHistory.cpp
new file mode 100644
index 0000000000..33e892992f
--- /dev/null
+++ b/plugins/IEHistory/src/IEHistory.cpp
@@ -0,0 +1,131 @@
+/*
+IEView history viewer plugin for Miranda IM
+
+Copyright © 2005-2006 Cristian Libotean
+
+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; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "stdafx.h"
+
+#include "commonheaders.h"
+#include "services.h"
+
+char ModuleName[] = "IEHistory";
+HICON hIcon;
+HINSTANCE hInstance;
+HANDLE hOpenWindowsList = NULL;
+
+PLUGINLINK *pluginLink;
+
+HMODULE hUxTheme = 0;
+BOOL (WINAPI *MyEnableThemeDialogTexture)(HANDLE, DWORD) = NULL;
+
+#ifdef _UNICODE
+#define IEHISTORY_PLUGININFO_SUFFIX " (Unicode)"
+#else
+#define IEHISTORY_PLUGININFO_SUFFIX ""
+#endif
+
+PLUGININFOEX pluginInfo = {
+ sizeof(PLUGININFOEX),
+ __PLUGIN_DISPLAY_NAME,
+ VERSION,
+ __DESC,
+ __AUTHOR,
+ __AUTHOREMAIL,
+ __COPYRIGHT,
+ __AUTHORWEB,
+ UNICODE_AWARE,
+ DEFMOD_UIHISTORY,
+#ifdef _UNICODE
+ {0x2f093b88, 0xf389, 0x44f1, {0x9e, 0x2a, 0x37, 0xc2, 0x91, 0x94, 0x20, 0x3a}} //{2f093b88-f389-44f1-9e2a-37c29194203a}
+#else
+ {0x2f997250, 0xbc2f, 0x46f0, {0xa3, 0x3e, 0x65, 0xf0, 0x62, 0x83, 0xbe, 0x5d}} //{2f997250-bc2f-46f0-a33e-65f06283be5d}
+#endif
+};
+
+OLD_MIRANDAPLUGININFO_SUPPORT;
+
+extern "C" __declspec(dllexport) PLUGININFOEX *MirandaPluginInfoEx(DWORD mirandaVersion)
+{
+ Log("%s", "Entering function " __FUNCTION__);
+ Log("%s", "Leaving function " __FUNCTION__);
+ return &pluginInfo;
+}
+
+static const MUUID interfaces[] = {MIID_UIHISTORY, MIID_LAST};
+
+extern "C" __declspec(dllexport) const MUUID *MirandaPluginInterfaces()
+{
+ return interfaces;
+}
+
+#include <commctrl.h>
+
+extern "C" int __declspec(dllexport) Load(PLUGINLINK *link)
+{
+ INITCOMMONCONTROLSEX icex;
+
+ icex.dwSize = sizeof(icex);
+ icex.dwICC = ICC_DATE_CLASSES;
+
+ InitCommonControlsEx(&icex);
+
+ if((hUxTheme = LoadLibraryA("uxtheme.dll")) != 0)
+ {
+ MyEnableThemeDialogTexture = (BOOL (WINAPI *)(HANDLE, DWORD))GetProcAddress(hUxTheme, "EnableThemeDialogTexture");
+ }
+
+ Log("%s", "Entering function " __FUNCTION__);
+ pluginLink = link;
+ //all initialization here
+ hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_HISTORYICON));
+ InitializeMirandaMemFunctions();
+
+ Log("%s", "Creating service functions ...");
+ InitServices();
+
+ Log("%s", "Hooking events ...");
+ HookEvents();
+ Log("%s", "Leaving function " __FUNCTION__);
+ return 0;
+}
+
+extern "C" int __declspec(dllexport) Unload()
+{
+ Log("%s", "Entering function " __FUNCTION__);
+ Log("%s", "Unhooking events ...");
+
+ Log("%s", "Destroying service functions ...");
+ DestroyServices();
+
+ Log("%s", "Closing all open windows ...");
+ WindowList_Broadcast(hOpenWindowsList, WM_CLOSE, 0, 0);
+
+ Log("%s", "Leaving function " __FUNCTION__);
+ return 0;
+}
+
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+ hInstance = hinstDLL;
+ if (fdwReason == DLL_PROCESS_ATTACH)
+ {
+ DisableThreadLibraryCalls(hinstDLL);
+ LogInit();
+ }
+ return TRUE;
+}
diff --git a/plugins/IEHistory/src/commonheaders.h b/plugins/IEHistory/src/commonheaders.h
new file mode 100644
index 0000000000..e687a27f02
--- /dev/null
+++ b/plugins/IEHistory/src/commonheaders.h
@@ -0,0 +1,84 @@
+/*
+IEView history viewer plugin for Miranda IM
+
+Copyright © 2005-2006 Cristian Libotean
+
+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; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef M_COMMON_HEADERS_H
+#define M_COMMON_HEADERS_H
+
+
+#define EVENTTYPE_STATUS 25368 //tabsrmm status events
+
+#include "stdafx.h"
+#include <malloc.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <uxtheme.h>
+
+#include "resource.h"
+#include "version.h"
+
+#include "utils.h"
+#include "mirandaMem.h"
+#include "events.h"
+#include "dlgHandlers.h"
+
+#include "../../../include/newpluginapi.h"
+#include "../../../include/m_database.h"
+#include "../../../include/m_utils.h"
+#include "../../../include/m_system.h"
+#include "../../../include/m_skin.h"
+#include "../../../include/m_options.h"
+#include "../../../include/m_clist.h"
+#include "../../../include/m_langpack.h"
+#include "../../../include/m_history.h"
+#include "../../../include/m_contacts.h"
+//#include "../../../include/m_utils.h"
+#include "../../../include/m_popup.h"
+#include "../../../include/m_ieview.h"
+#include "../../../include/m_updater.h"
+
+
+extern HICON hIcon; //history icon
+extern char ModuleName[];
+extern HINSTANCE hInstance; //dll instance
+extern HANDLE hOpenWindowsList;
+
+extern PLUGININFOEX pluginInfo;
+
+extern BOOL (WINAPI *MyEnableThemeDialogTexture)(HANDLE, DWORD);
+
+#define OLD_MIRANDAPLUGININFO_SUPPORT PLUGININFO oldPluginInfo = { \
+ sizeof(PLUGININFO), \
+ pluginInfo.shortName, \
+ pluginInfo.version, \
+ pluginInfo.description, \
+ pluginInfo.author, \
+ pluginInfo.authorEmail, \
+ pluginInfo.copyright, \
+ pluginInfo.homepage, \
+ pluginInfo.flags, \
+ pluginInfo.replacesDefaultModule \
+}; \
+\
+extern "C" __declspec(dllexport) PLUGININFO *MirandaPluginInfo(DWORD mirandaVersion) \
+{ \
+ return &oldPluginInfo; \
+}
+
+#endif \ No newline at end of file
diff --git a/plugins/IEHistory/src/dlgHandlers.cpp b/plugins/IEHistory/src/dlgHandlers.cpp
new file mode 100644
index 0000000000..a9d4734abe
--- /dev/null
+++ b/plugins/IEHistory/src/dlgHandlers.cpp
@@ -0,0 +1,798 @@
+/*
+IEView history viewer plugin for Miranda IM
+
+Copyright © 2005-2006 Cristian Libotean
+
+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; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "dlgHandlers.h"
+#include "math.h"
+#include <commctrl.h>
+
+#define GAP_SIZE 2
+#define MIN_HISTORY_WIDTH 350
+#define MIN_HISTORY_HEIGHT 100
+
+struct WorkerThreadData{
+ HWND hWnd;
+ HistoryWindowData *data;
+ IEVIEWEVENT ieEvent;
+};
+
+int LoadName(HWND hWnd);
+int CalcIEViewPos(IEVIEWWINDOW *ieWnd, HWND hMainWindow);
+int LoadIEView(HWND hWnd);
+int MoveIEView(HWND hWnd);
+int DestroyIEView(HWND hWnd);
+int LoadEvents(HWND hWnd);
+int LoadPage(HWND hWnd, HANDLE hFirstEvent, long index, long shiftCount, long readCount, int direction);
+int LoadNext(HWND hWnd);
+int LoadPrev(HWND hWnd);
+int ScrollToBottom(HWND hWnd);
+
+void RefreshButtonStates(HWND hWnd);
+
+HANDLE GetNeededEvent(HANDLE hLastFirstEvent, int index, int direction);
+
+int CalcIEViewPos(IEVIEWWINDOW *ieWnd, HWND hMainWindow)
+{
+ RECT rect;
+ GetWindowRect(GetDlgItem(hMainWindow, IDC_IEVIEW_PLACEHOLDER), &rect);
+ ScreenToClient(hMainWindow, &rect);
+
+ ieWnd->x = rect.left + GAP_SIZE;
+ ieWnd->y = rect.top + GAP_SIZE;
+ ieWnd->cx = rect.right - rect.left - (2 * GAP_SIZE);
+ ieWnd->cy = rect.bottom - rect.top - (2 * GAP_SIZE);
+ return 0;
+}
+
+int LoadName(HWND hWnd)
+{
+ HistoryWindowData *data = (HistoryWindowData *) GetWindowLong(hWnd, DWL_USER);
+ HANDLE hEvent = (HANDLE) CallService(MS_DB_EVENT_FINDFIRST, (WPARAM) data->hContact, 0);
+ DBEVENTINFO event = {0};
+ event.cbSize = sizeof(event);
+ CallService(MS_DB_EVENT_GET, (WPARAM) hEvent, (LPARAM) &event); //to get the protocol
+ TCHAR *szOther = GetContactName(data->hContact, event.szModule);
+ TCHAR buffer[1024];
+ _sntprintf(buffer, 1024, _T("%s: IEHistory"), szOther);
+ SetWindowText(hWnd, buffer);
+ free(szOther);
+ return 0;
+}
+
+int LoadIEView(HWND hWnd)
+{
+ IEVIEWWINDOW ieWnd = {0};
+ ieWnd.cbSize = sizeof(ieWnd);
+ ieWnd.iType = IEW_CREATE;
+ ieWnd.dwMode = IEWM_HISTORY;
+ ieWnd.dwFlags = 0;
+ ieWnd.parent = hWnd;
+ CalcIEViewPos(&ieWnd, hWnd);
+
+ CallService(MS_IEVIEW_WINDOW, 0, (LPARAM) &ieWnd);
+ HistoryWindowData *data = (HistoryWindowData *) GetWindowLong(hWnd, DWL_USER);
+ data->hIEView = ieWnd.hwnd;
+ SetWindowPos(GetDlgItem(hWnd, IDC_IEVIEW_PLACEHOLDER), HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
+ //ShowWindow(GetDlgItem(hWnd, IDC_IEVIEW_PLACEHOLDER), SW_HIDE);
+ return 0;
+}
+
+int MoveIeView(HWND hWnd)
+{
+ HistoryWindowData *data = (HistoryWindowData *) GetWindowLong(hWnd, DWL_USER);
+ if (data)
+ {
+ IEVIEWWINDOW ieWnd = {0};
+ ieWnd.cbSize = sizeof(ieWnd);
+ ieWnd.parent = hWnd;
+ ieWnd.hwnd = data->hIEView;
+ ieWnd.iType = IEW_SETPOS;
+ CalcIEViewPos(&ieWnd, hWnd);
+ CallService(MS_IEVIEW_WINDOW, 0, (LPARAM) &ieWnd);
+ }
+ return 0;
+}
+
+int DestroyIEView(HWND hWnd)
+{
+ HistoryWindowData *data = (HistoryWindowData *) GetWindowLong(hWnd, DWL_USER);
+ IEVIEWWINDOW ieWnd = {0};
+ ieWnd.cbSize = sizeof(ieWnd);
+ ieWnd.parent = hWnd;
+ ieWnd.hwnd = data->hIEView;
+ ieWnd.iType = IEW_DESTROY;
+ CallService(MS_IEVIEW_WINDOW, 0, (LPARAM) &ieWnd);
+ return 0;
+}
+
+void FillIEViewInfo(IEVIEWEVENTDATA *fillData, DBEVENTINFO dbInfo, PBYTE blob)
+{
+ switch (dbInfo.eventType)
+ {
+ case EVENTTYPE_MESSAGE:
+ fillData->iType = IEED_EVENT_MESSAGE;
+ break;
+ case EVENTTYPE_STATUS:
+ fillData->iType = IEED_EVENT_STATUSCHANGE;
+ break;
+ case EVENTTYPE_FILE:
+ fillData->iType = IEED_EVENT_FILE;
+ break;
+ case EVENTTYPE_URL:
+ fillData->iType = IEED_EVENT_URL;
+ break;
+ }
+ fillData->pszNick = "<nick here>";
+ fillData->bIsMe = (dbInfo.flags & DBEF_SENT);
+ fillData->dwFlags = (dbInfo.flags & DBEF_SENT) ? IEEDF_SENT : 0;
+ fillData->time = dbInfo.timestamp;
+ unsigned int len = strlen((char *) blob) + 1;
+ PBYTE pos;
+
+ fillData->pszText = (char *) blob;
+// fillData.pszText2 = (char *) blob;
+ if (len < dbInfo.cbBlob)
+ {
+ pos = blob + len;
+ fillData->pszTextW = (wchar_t *) pos;
+// fillData->pszText2W = (wchar_t *) pos;
+ fillData->dwFlags |= IEEDF_UNICODE_TEXT;
+ }
+}
+
+DWORD WINAPI WorkerThread(LPVOID lpvData)
+{
+ Log("%s", "Inside worker thread ...");
+ WorkerThreadData *data = (WorkerThreadData *) lpvData;
+ EnableWindow(GetDlgItem(data->hWnd, IDC_CLOSE), FALSE);
+ const int LOAD_COUNT = 10;
+ int count = 0;
+ int target = data->ieEvent.count;
+ int cLoad = LOAD_COUNT;
+ int i;
+ IEVIEWEVENT ieEvent = {0};
+ IEVIEWEVENTDATA ieData[LOAD_COUNT] = {0};
+ PBYTE messages[LOAD_COUNT] = {0};
+ HANDLE dbEvent = data->ieEvent.hDbEventFirst;
+ for (i = 0; i < LOAD_COUNT; i++)
+ {
+ ieData[i].cbSize = sizeof(IEVIEWEVENTDATA); //set the cbsize here, no need to do it every time
+ ieData[i].next = &ieData[i + 1]; //it's a vector, so v[i]'s next element is v[i + 1]
+ }
+ ieData[LOAD_COUNT - 1].next = NULL;
+ ieEvent = data->ieEvent;
+ ieEvent.iType = IEE_LOG_MEM_EVENTS;
+ ieEvent.eventData = ieData;
+ DBEVENTINFO dbInfo = {0};
+ dbInfo.cbSize = sizeof(DBEVENTINFO);
+ PBYTE buffer = NULL;
+ int newSize, oldSize = 0;
+ while (count < target)
+ {
+ cLoad = (count + LOAD_COUNT > target) ? target - count : LOAD_COUNT;
+ ieEvent.count = -1;
+
+ for (i = 0; i < cLoad; i++)
+ {
+ newSize = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM) dbEvent, 0);
+ if (newSize > oldSize)
+ {
+ buffer = (PBYTE) realloc(buffer, newSize);
+ dbInfo.pBlob = buffer;
+ oldSize = newSize;
+ }
+ messages[i] = (PBYTE) realloc(messages[i], newSize);
+ dbInfo.cbBlob = newSize;
+ if (!CallService(MS_DB_EVENT_GET, (WPARAM) dbEvent, (LPARAM) &dbInfo))
+ {
+ memmove(messages[i], dbInfo.pBlob, newSize);
+ FillIEViewInfo(&ieData[i], dbInfo, messages[i]);
+ }
+ //FillIEViewEventData(&ieData[i], dbEvent);
+ dbEvent = (HANDLE) CallService(MS_DB_EVENT_FINDNEXT, (WPARAM) dbEvent, 0);
+ }
+ ieData[cLoad - 1].next = NULL; //cLoad < LOAD_COUNT will only happen once, at the end
+ CallService(MS_IEVIEW_EVENT, 0, (LPARAM) &ieEvent);
+ count += cLoad;
+ }
+ for (i = 0; i < LOAD_COUNT; i++)
+ {
+ free(messages[i]);
+ }
+ free(buffer);
+ EnableWindow(GetDlgItem(data->hWnd, IDC_CLOSE), TRUE);
+ free(data);
+ //RefreshButtonStates(data->hWnd);
+ Log("%s", "WorkerThread finished ... returning");
+ return 0;
+}
+
+int DoLoadEvents(HWND hWnd, HistoryWindowData *data, IEVIEWEVENT ieEvent)
+{
+ ieEvent.iType = IEE_CLEAR_LOG;
+ CallService(MS_IEVIEW_EVENT, 0, (LPARAM) &ieEvent);
+ if (data->loadMethod == LOAD_IN_BACKGROUND)
+ {
+ WorkerThreadData *threadData = (WorkerThreadData *) malloc(sizeof(WorkerThreadData));
+ threadData->data = data;
+ threadData->hWnd = hWnd;
+ threadData->ieEvent = ieEvent;
+ WorkerThread(threadData);
+ /*
+ DWORD threadID;
+ HANDLE thread = CreateThread(NULL, 0, WorkerThread, threadData, 0, &threadID);
+ if (!thread)
+ {
+ MessageBox(hWnd, TranslateT("An error occured while trying to create the worker thread (%m)"), TranslateT("Error"), MB_OK | MB_ICONERROR);
+ } */
+ }
+ else{
+ ieEvent.iType = IEE_LOG_DB_EVENTS;
+ CallService(MS_IEVIEW_EVENT, 0, (LPARAM) &ieEvent);
+ ScrollToBottom(hWnd);
+
+ TCHAR buffer[256];
+ _itot(data->index + 1, buffer, 10);
+ SendDlgItemMessage(hWnd, IDC_STATUSBAR, SB_SETTEXT, 0 | SBT_POPOUT, (LPARAM) buffer);
+ _itot(data->index + ieEvent.count, buffer, 10);
+ SendDlgItemMessage(hWnd, IDC_STATUSBAR, SB_SETTEXT, 1 | SBT_POPOUT, (LPARAM) buffer);
+ _itot(data->count, buffer, 10);
+ SendDlgItemMessage(hWnd, IDC_STATUSBAR, SB_SETTEXT, 3 | SBT_POPOUT, (LPARAM) buffer);
+ RefreshButtonStates(hWnd);
+ }
+ return 0;
+}
+
+int LoadEvents(HWND hWnd)
+{
+ HistoryWindowData *data = (HistoryWindowData *) GetWindowLong(hWnd, DWL_USER);
+ int count = CallService(MS_DB_EVENT_GETCOUNT, (WPARAM) data->hContact, 0);
+ int bLastFirst = DBGetContactSettingByte(NULL, ModuleName, "ShowLastPageFirst", 0);
+ int bRTL = DBGetContactSettingByte(NULL, ModuleName, "EnableRTL", 0);
+ bRTL = DBGetContactSettingByte(data->hContact, "Tab_SRMsg", "RTL", bRTL);
+ data->bEnableRTL = bRTL;
+ data->count = count;
+ if (data->itemsPerPage > count)
+ {
+ data->itemsPerPage = count;
+ }
+ IEVIEWEVENT ieEvent = {0};
+ ieEvent.cbSize = sizeof(ieEvent);
+ ieEvent.hwnd = data->hIEView;
+ ieEvent.hContact = data->hContact;
+ ieEvent.count = (data->itemsPerPage <= 0) ? count : data->itemsPerPage;
+
+ HANDLE hFirstEvent = (HANDLE) CallService(MS_DB_EVENT_FINDFIRST, (WPARAM) data->hContact, 0);
+ int index = 0;
+ if ((data->itemsPerPage > 0) && (bLastFirst))
+ {
+ index = data->count - data->itemsPerPage;
+ hFirstEvent = GetNeededEvent(hFirstEvent, index, DIRECTION_FORWARD);
+ }
+ data->index = index;
+ data->hLastFirstEvent = hFirstEvent;
+ ieEvent.hDbEventFirst = hFirstEvent;
+ if (data->bEnableRTL)
+ {
+ ieEvent.dwFlags |= IEEF_RTL;
+ }
+ DoLoadEvents(hWnd, data, ieEvent);
+ return 0;
+}
+
+int LoadPage(HWND hWnd, HANDLE hFirstEvent, long index, long shiftCount, long readCount, int direction)
+{
+ HistoryWindowData *data = (HistoryWindowData *) GetWindowLong(hWnd, DWL_USER);
+ int count = shiftCount;
+ int newIndex = index;
+ IEVIEWEVENT ieEvent = {0};
+ ieEvent.cbSize = sizeof(ieEvent);
+ ieEvent.hwnd = data->hIEView;
+ ieEvent.hContact = data->hContact;
+
+ if (direction == DIRECTION_BACK)
+ {
+ newIndex -= shiftCount;
+ if (newIndex < 0)
+ {
+ newIndex = 0;
+ count = index;
+ }
+ }
+ else{
+ newIndex += shiftCount;
+ if (newIndex + readCount > data->count)
+ {
+ count = data->count - newIndex;
+ newIndex = data->count - readCount;
+ }
+ }
+ data->index = newIndex;
+ HANDLE hEvent = GetNeededEvent(hFirstEvent, count, direction);
+ data->hLastFirstEvent = hEvent;
+ ieEvent.hDbEventFirst = hEvent;
+ ieEvent.count = readCount;
+ if (data->bEnableRTL)
+ {
+ ieEvent.dwFlags |= IEEF_RTL;
+ }
+ DoLoadEvents(hWnd, data, ieEvent);
+ return 0;
+}
+
+int LoadPrev(HWND hWnd)
+{
+ HistoryWindowData *data = (HistoryWindowData *) GetWindowLong(hWnd, DWL_USER);
+ LoadPage(hWnd, data->hLastFirstEvent, data->index, data->itemsPerPage, data->itemsPerPage, DIRECTION_BACK);
+ int finish = data->index <= 0;
+ return finish;
+}
+
+int LoadNext(HWND hWnd)
+{
+ HistoryWindowData *data = (HistoryWindowData *) GetWindowLong(hWnd, DWL_USER);
+ LoadPage(hWnd, data->hLastFirstEvent, data->index, data->itemsPerPage, data->itemsPerPage, DIRECTION_FORWARD);
+ int finish = data->index + data->itemsPerPage >= data->count;
+ return finish;
+}
+
+int ScrollToBottom(HWND hWnd)
+{
+ HistoryWindowData *data = (HistoryWindowData *) GetWindowLong(hWnd, DWL_USER);
+ IEVIEWWINDOW ieWnd = {0};
+ ieWnd.cbSize = sizeof(ieWnd);
+ ieWnd.iType = IEW_SCROLLBOTTOM;
+ ieWnd.hwnd = data->hIEView;
+ ieWnd.parent = hWnd;
+ CallService(MS_IEVIEW_WINDOW, 0, (LPARAM) &ieWnd);
+ return 0;
+}
+
+void AddAnchorWindowToDeferList(HDWP &hdWnds, HWND window, RECT *rParent, WINDOWPOS *wndPos, int anchors)
+{
+ RECT rChild = AnchorCalcPos(window, rParent, wndPos, anchors);
+ hdWnds = DeferWindowPos(hdWnds, window, HWND_NOTOPMOST, rChild.left, rChild.top, rChild.right - rChild.left, rChild.bottom - rChild.top, SWP_NOZORDER);
+}
+
+void RefreshButtonStates(HWND hWnd)
+{
+ HistoryWindowData *data = (HistoryWindowData *) GetWindowLong(hWnd, DWL_USER);
+ int bPrev = data->index > 0;
+ int bNext = data->index + data->itemsPerPage < data->count;
+ EnableWindow(GetDlgItem(hWnd, IDC_PREV), bPrev);
+ EnableWindow(GetDlgItem(hWnd, IDC_NEXT), bNext);
+}
+
+
+
+BOOL CALLBACK HistoryDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ {
+ Log("Inside WM_INITDIALOG ...");
+ TranslateDialogDefault(hWnd);
+ SendMessage(hWnd, WM_SETICON, ICON_BIG, (LPARAM) hIcon);
+ //SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
+ int bRTL = DBGetContactSettingByte(NULL, ModuleName, "EnableRTL", 0);
+ if (bRTL)
+ {
+ SetWindowLong(hWnd, GWL_EXSTYLE, WS_EX_RTLREADING);
+ }
+ //InitCommonControls();
+ HWND hStatusBar = CreateWindow(STATUSCLASSNAME, //class
+ _T("-"), //title
+ WS_CHILD | WS_VISIBLE | SBARS_TOOLTIPS | SBARS_SIZEGRIP, //style
+ 0, 0, //x, y
+ 0, 0, //width, height
+ hWnd, //parent
+ (HMENU) IDC_STATUSBAR, //menu
+ hInstance, //instance
+ NULL); //lpParam
+ int x;
+ int widths[] = {x = 50, x += 50, x += 150, -1};
+ int count = sizeof(widths) / sizeof(widths[0]);
+ SendMessage(hStatusBar, SB_SETPARTS, count, (LPARAM) widths);
+ //SendMessage(hStatusBar, SB_SETTIPTEXT, 1, (LPARAM) TranslateT("First event shown in page"));
+ //SendMessage(hStatusBar, SB_SETTIPTEXT, 2, (LPARAM) TranslateT("Last event shown in page"));
+ SendMessage(hStatusBar, SB_SETTEXT, 2 | SBT_POPOUT, (LPARAM) TranslateT("Out of a total of"));
+ return TRUE;
+ break;
+ }
+ case WM_SHOWWINDOW:
+ {
+ Log("Inside WM_SHOWWINDOW ...");
+ LoadName(hWnd);
+ LoadIEView(hWnd);
+ LoadEvents(hWnd);
+
+ HistoryWindowData *data = (HistoryWindowData *) GetWindowLong(hWnd, DWL_USER);
+ bool bAll = (data->itemsPerPage <= 0) || (data->itemsPerPage >= data->count);
+ int bLastFirst = DBGetContactSettingByte(NULL, ModuleName, "ShowLastPageFirst", 0);
+ if (!bLastFirst)
+ {
+ EnableWindow(GetDlgItem(hWnd, IDC_PREV), FALSE);
+ EnableWindow(GetDlgItem(hWnd, IDC_NEXT), !bAll);
+ }
+ else{
+ EnableWindow(GetDlgItem(hWnd, IDC_PREV), !bAll);
+ EnableWindow(GetDlgItem(hWnd, IDC_NEXT), FALSE);
+ }
+ //ShowWindow(GetDlgItem(hWnd, IDC_PAGE_NUMBER), !bAll);
+ EnableWindow(GetDlgItem(hWnd, IDC_SEARCH), !bAll);
+
+ break;
+ }
+ case WM_DESTROY:
+ {
+ HistoryWindowData *data = (HistoryWindowData *) GetWindowLong(hWnd, DWL_USER);
+ DestroyIEView(hWnd);
+ free(data);
+ WindowList_Remove(hOpenWindowsList, hWnd);
+ break;
+ }
+ case WM_CLOSE:
+ {
+ if (IsWindowEnabled(GetDlgItem(hWnd, IDC_CLOSE)))
+ {
+ DestroyWindow(hWnd);
+ }
+ else{
+ MessageBox(hWnd, TranslateT("You can't close the window now, wait for all events to load."), TranslateT("Error"), MB_OK | MB_ICONERROR);
+ }
+ break;
+ }
+ case WM_WINDOWPOSCHANGING:
+ {
+ HDWP hdWnds = BeginDeferWindowPos(6);
+ RECT rParent;
+ HWND hStatusBar = GetDlgItem(hWnd, IDC_STATUSBAR);
+ WINDOWPOS *wndPos = (WINDOWPOS *) lParam;
+ GetWindowRect(hWnd, &rParent);
+
+ //hdWnds = DeferWindowPos(hdWnds, hStatusBar, HWND_NOTOPMOST, wndPos->x, wndPos->y + wndPos->cy - statusHeight, statusWidth, statusHeight, SWP_NOZORDER);
+ SendMessage(hStatusBar, WM_SIZE, 0, 0);
+ if (wndPos->cx < MIN_HISTORY_WIDTH)
+ {
+ wndPos->cx = MIN_HISTORY_WIDTH;
+ }
+ if (wndPos->cy < MIN_HISTORY_HEIGHT)
+ {
+ wndPos->cy = MIN_HISTORY_HEIGHT;
+ }
+ //MoveWindow(hStatusBar, wndPos->x, wndPos->y + wndPos->cy - statusHeight - 2, statusWidth - 2, statusHeight, TRUE);
+ AddAnchorWindowToDeferList(hdWnds, GetDlgItem(hWnd, IDC_STATUSBAR), &rParent, wndPos, ANCHOR_BOTTOM);
+ AddAnchorWindowToDeferList(hdWnds, GetDlgItem(hWnd, IDC_CLOSE), &rParent, wndPos, ANCHOR_RIGHT | ANCHOR_BOTTOM);
+ AddAnchorWindowToDeferList(hdWnds, GetDlgItem(hWnd, IDC_IEVIEW_PLACEHOLDER), &rParent, wndPos, ANCHOR_ALL);
+ AddAnchorWindowToDeferList(hdWnds, GetDlgItem(hWnd, IDC_PREV), &rParent, wndPos, ANCHOR_LEFT | ANCHOR_BOTTOM);
+ AddAnchorWindowToDeferList(hdWnds, GetDlgItem(hWnd, IDC_NEXT), &rParent, wndPos, ANCHOR_LEFT | ANCHOR_BOTTOM);
+ //AddAnchorWindowToDeferList(hdWnds, GetDlgItem(hWnd, IDC_PAGE_NUMBER), &rParent, wndPos, ANCHOR_LEFT | ANCHOR_BOTTOM);
+ AddAnchorWindowToDeferList(hdWnds, GetDlgItem(hWnd, IDC_SEARCH), &rParent, wndPos, ANCHOR_RIGHT | ANCHOR_BOTTOM);
+
+ EndDeferWindowPos(hdWnds);
+ MoveIeView(hWnd);
+ break;
+ }
+ case WM_COMMAND:
+ {
+ switch (LOWORD(wParam))
+ {
+ case IDC_CLOSE:
+ {
+ SendMessage(hWnd, WM_CLOSE, 0, 0);
+ break;
+ }
+ case IDC_PREV:
+ {
+ int finished = LoadPrev(hWnd);
+ //EnableWindow(GetDlgItem(hWnd, IDC_PREV), !finished);
+ //EnableWindow(GetDlgItem(hWnd, IDC_NEXT), TRUE);
+ break;
+ }
+ case IDC_NEXT:
+ {
+ int finished = LoadNext(hWnd);
+ //EnableWindow(GetDlgItem(hWnd, IDC_NEXT), !finished);
+ //EnableWindow(GetDlgItem(hWnd, IDC_PREV), TRUE);
+ break;
+ }
+ case IDC_SEARCH:
+ {
+ HWND hSearch = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_SEARCH), hWnd, SearchDlgProc);
+ if (hSearch == NULL)
+ {
+ char buffer[1024];
+ sprintf(buffer, "Error #%d", GetLastError());
+ MessageBoxA(0, buffer, "Error", MB_OK);
+ }
+ HistoryWindowData *data = (HistoryWindowData *) GetWindowLong(hWnd, DWL_USER);
+ SearchWindowData *searchData = (SearchWindowData *) malloc(sizeof(SearchWindowData));
+ searchData->hContact = data->hContact;
+ searchData->hHistoryWindow = hWnd;
+ searchData->hLastFoundEvent = NULL;
+ searchData->index = 0;
+ SetWindowLong(hSearch, DWL_USER, (LONG) searchData);
+ ShowWindow(hSearch, SW_SHOW);
+ //sprintf(buffer, "Error #%d", GetLastError());
+ //MessageBoxA(0, buffer, "Error", MB_OK);
+ break;
+ }
+ }
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+ return 0;
+}
+
+#include "prsht.h" //PSN_APPLY
+
+BOOL CALLBACK OptionsDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ {
+ TranslateDialogDefault(hWnd);
+ int count = DBGetContactSettingDword(NULL, ModuleName, "EventsToLoad", 0);
+ EnableWindow(GetDlgItem(hWnd, IDC_EVENTS_COUNT), count > 0);
+ EnableWindow(GetDlgItem(hWnd, IDC_SHOW_LAST_FIRST), count > 0);
+
+ CheckDlgButton(hWnd, IDC_LOAD_ALL, count <= 0);
+ CheckDlgButton(hWnd, IDC_LOAD_NUMBER, count > 0);
+ CheckDlgButton(hWnd, IDC_ENABLE_RTL, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "EnableRTL", 0));
+ CheckDlgButton(hWnd, IDC_SHOW_LAST_FIRST, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "ShowLastPageFirst", 0));
+ CheckDlgButton(hWnd, IDC_LOAD_BACKGROUND, (BOOL) DBGetContactSettingByte(NULL, ModuleName, "UseWorkerThread", 0));
+ TCHAR buffer[1024];
+ _itot(count, buffer, 10);
+ SetWindowText(GetDlgItem(hWnd, IDC_EVENTS_COUNT), buffer);
+
+ break;
+ }
+ case WM_COMMAND:
+ {
+ switch (LOWORD(wParam))
+ {
+ case IDC_LOAD_ALL:
+ {
+ EnableWindow(GetDlgItem(hWnd, IDC_EVENTS_COUNT), FALSE);
+ EnableWindow(GetDlgItem(hWnd, IDC_SHOW_LAST_FIRST), FALSE);
+ SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0);
+ break;
+ }
+ case IDC_LOAD_NUMBER:
+ {
+ EnableWindow(GetDlgItem(hWnd, IDC_EVENTS_COUNT), TRUE);
+ EnableWindow(GetDlgItem(hWnd, IDC_SHOW_LAST_FIRST), TRUE);
+ SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0);
+ break;
+ }
+ case IDC_ENABLE_RTL:
+ case IDC_SHOW_LAST_FIRST:
+ case IDC_EVENTS_COUNT:
+ case IDC_LOAD_BACKGROUND:
+ {
+ SendMessage(GetParent(hWnd), PSM_CHANGED, 0, 0);
+ break;
+ }
+ }
+ break;
+ }
+ case WM_NOTIFY:
+ {
+ switch(((LPNMHDR)lParam)->idFrom)
+ {
+ case 0:
+ {
+ switch (((LPNMHDR)lParam)->code)
+ {
+ case PSN_APPLY:
+ {
+ long count;
+ if (IsDlgButtonChecked(hWnd, IDC_LOAD_ALL))
+ {
+ count = 0;
+ }
+ else{
+ TCHAR buffer[1024];
+ GetWindowText(GetDlgItem(hWnd, IDC_EVENTS_COUNT), buffer, sizeof(buffer));
+ count = _tstol(buffer);
+ count = (count < 0) ? 0 : count;
+ }
+ DBWriteContactSettingByte(NULL, ModuleName, "ShowLastPageFirst", IsDlgButtonChecked(hWnd, IDC_SHOW_LAST_FIRST));
+ DBWriteContactSettingByte(NULL, ModuleName, "EnableRTL", IsDlgButtonChecked(hWnd, IDC_ENABLE_RTL));
+ DBWriteContactSettingByte(NULL, ModuleName, "UseWorkerThread", IsDlgButtonChecked(hWnd, IDC_LOAD_BACKGROUND));
+ DBWriteContactSettingDword(NULL, ModuleName, "EventsToLoad", count);
+
+ break;
+ }
+ }
+ break;
+ }
+ }
+ break;
+ }
+ default:
+ {
+ break;
+ }
+ }
+ return 0;
+}
+
+
+#include "commctrl.h" //tab control
+
+BOOL CALLBACK SearchDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch (msg)
+ {
+ case WM_INITDIALOG:
+ {
+ if (MyEnableThemeDialogTexture)
+ {
+ MyEnableThemeDialogTexture((HWND) hWnd, ETDT_ENABLETAB);
+ }
+ TranslateDialogDefault(hWnd);
+ TCITEM tabItem = {0};
+ tabItem.pszText = TranslateT("Text search");
+ tabItem.mask = TCIF_TEXT;
+ //MessageBoxA(0, "Before TCM_INSERTITEM 1", "Error", MB_OK);
+ SendMessage(GetDlgItem(hWnd, IDC_TABS), TCM_INSERTITEM, 0, (LPARAM) &tabItem);
+ tabItem.pszText = TranslateT("Time search");
+ //MessageBoxA(0, "Before TCM_INSERTITEM 2", "Error", MB_OK);
+ SendMessage(GetDlgItem(hWnd, IDC_TABS), TCM_INSERTITEM, 1, (LPARAM) &tabItem);
+ //SendMessage(GetDlgItem(hWnd, IDC_SEARCH_TIME), DTM_SETFORMAT, 0, (LPARAM) "HH:mm");
+ //MessageBoxA(0, "Before CheckDlgButton", "Error", MB_OK);
+ CheckDlgButton(hWnd, IDC_DIRECTION_DOWN, TRUE);
+ return TRUE;
+ break;
+ }
+ case WM_SHOWWINDOW:
+ {
+ SetFocus(GetDlgItem(hWnd, IDC_SEARCH_TEXT));
+ break;
+ }
+ case WM_DESTROY:
+ {
+ SearchWindowData *data = (SearchWindowData *) GetWindowLong(hWnd, DWL_USER);
+ free(data);
+ //DestroyWindow(hWnd);
+ break;
+ }
+ case WM_CLOSE:
+ {
+ DestroyWindow(hWnd);
+ break;
+ }
+ case WM_NOTIFY:
+ {
+ switch (((LPNMHDR) lParam)->idFrom)
+ {
+ case IDC_SEARCH_DATE:
+ case IDC_SEARCH_TIME:
+ {
+ SearchWindowData *data = (SearchWindowData *) GetWindowLong(hWnd, DWL_USER);
+ data->hLastFoundEvent = NULL; //start from top if changes occur
+ break;
+ }
+ case IDC_TABS:
+ {
+ switch (((LPNMHDR) lParam)->code)
+ {
+ case TCN_SELCHANGE:
+ {
+ int tab = SendMessage(GetDlgItem(hWnd, IDC_TABS), TCM_GETCURSEL, 0, 0);
+ ShowWindow(GetDlgItem(hWnd, IDC_SEARCH_DATE), (tab == 1) ? SW_SHOW : SW_HIDE);
+ ShowWindow(GetDlgItem(hWnd, IDC_SEARCH_TIME), (tab == 1) ? SW_SHOW : SW_HIDE);
+ ShowWindow(GetDlgItem(hWnd, IDC_SEARCH_TEXT), (tab == 0) ? SW_SHOW : SW_HIDE);
+ SendMessage(GetDlgItem(hWnd, IDC_SEARCH_TEXT_STATIC), WM_SETTEXT, 0, (LPARAM) ((tab == 0) ? _T("Text :") : _T("Time :")));
+ break;
+ }
+ }
+ break;
+ }
+ }
+ break;
+ }
+ case WM_COMMAND:
+ {
+ switch (LOWORD(wParam))
+ {
+ case IDC_SEARCH_TEXT:
+ {
+ switch (HIWORD(wParam))
+ {
+ case EN_CHANGE:
+ {
+ SearchWindowData *data = (SearchWindowData *) GetWindowLong(hWnd, DWL_USER);
+ data->hLastFoundEvent = NULL; //start from top if changes occur
+ break;
+ }
+ }
+ break;
+ }
+ case IDCANCEL:
+ {
+ SendMessage(hWnd, WM_CLOSE, 0, 0);
+ break;
+ }
+ case IDC_FIND_NEXT:
+ {
+ SearchWindowData *data = (SearchWindowData *) GetWindowLong(hWnd, DWL_USER);
+ const HistoryWindowData *histData = (HistoryWindowData *) GetWindowLong(data->hHistoryWindow, DWL_USER);
+ int direction = IsDlgButtonChecked(hWnd, IDC_DIRECTION_UP) ? DIRECTION_BACK : DIRECTION_FORWARD;
+ int tab = SendMessage(GetDlgItem(hWnd, IDC_TABS), TCM_GETCURSEL, 0, 0);
+ int type = (tab == 0) ? SEARCH_TEXT : SEARCH_TIME;
+ SearchResult searchResult;
+ if (data->hLastFoundEvent == NULL)
+ {
+ data->index = (direction == DIRECTION_FORWARD) ? 0 : histData->count;
+ }
+ else{
+ data->hLastFoundEvent = GetNeededEvent(data->hLastFoundEvent, 1, direction);
+ }
+
+ if (type == SEARCH_TEXT) //text search
+ {
+ TCHAR text[2048]; //TODO buffer overrun
+ SendMessage(GetDlgItem(hWnd, IDC_SEARCH_TEXT), WM_GETTEXT, 2048, (LPARAM) text);
+ searchResult = SearchHistory(data->hContact, data->hLastFoundEvent, text, direction, type);
+ }
+ else{//time search
+ TimeSearchData tsData = {0};
+ SYSTEMTIME date = {0}, time = {0};
+ int res = SendMessage(GetDlgItem(hWnd, IDC_SEARCH_DATE), DTM_GETSYSTEMTIME, 0, (LPARAM) &date);
+ tsData.flags = (res == GDT_VALID) ? TSDF_DATE_SET : 0;
+ res = SendMessage(GetDlgItem(hWnd, IDC_SEARCH_TIME), DTM_GETSYSTEMTIME, 0, (LPARAM) &time);
+ if (res == GDT_VALID)
+ {
+ tsData.flags |= TSDF_TIME_SET;
+ date.wHour = time.wHour;
+ date.wMinute = time.wMinute;
+ date.wSecond = time.wSecond;
+ date.wMilliseconds = time.wMilliseconds;
+ }
+ tsData.time = date;
+ searchResult = SearchHistory(data->hContact, data->hLastFoundEvent, &tsData, direction, type);
+ }
+ if (searchResult.hEvent)
+ {
+ //char buffer[1024];
+ //sprintf(buffer, "Found it: index = %ld hEvent = %p", searchResult.index, searchResult.hEvent);
+ //MessageBox(0, buffer, "Yupppi", 0);
+ data->index += (direction == DIRECTION_BACK) ? -searchResult.index : searchResult.index;
+ LoadPage(data->hHistoryWindow, searchResult.hEvent, data->index, histData->itemsPerPage / 2, histData->itemsPerPage, DIRECTION_BACK);
+ }
+ else{
+ MessageBox(0, TranslateT("Search finished. No more entries ..."), TranslateT("Information"), MB_OK | MB_ICONINFORMATION);
+ }
+ data->hLastFoundEvent = searchResult.hEvent;
+ break;
+ }
+ }
+ break;
+ }
+ }
+ return 0;
+} \ No newline at end of file
diff --git a/plugins/IEHistory/src/dlgHandlers.h b/plugins/IEHistory/src/dlgHandlers.h
new file mode 100644
index 0000000000..343b208c6e
--- /dev/null
+++ b/plugins/IEHistory/src/dlgHandlers.h
@@ -0,0 +1,50 @@
+/*
+IEView history viewer plugin for Miranda IM
+
+Copyright © 2005-2006 Cristian Libotean
+
+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; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef M_HISTORY_DLG_HANDLERS_H
+#define M_HISTORY_DLG_HANDLERS_H
+
+#include "commonheaders.h"
+
+#define LOAD_IN_BACKGROUND 0x00000001
+
+struct HistoryWindowData{
+ HANDLE hContact;
+ long count;
+ long index;
+ short loadMethod;
+ int itemsPerPage;
+ int bEnableRTL;
+ HWND hIEView;
+ HANDLE hLastFirstEvent;
+};
+
+struct SearchWindowData{
+ long index;
+ HANDLE hContact;
+ HWND hHistoryWindow;
+ HANDLE hLastFoundEvent;
+};
+
+BOOL CALLBACK HistoryDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
+BOOL CALLBACK OptionsDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
+BOOL CALLBACK SearchDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
+
+#endif //M_HISTORY_DLG_HANDLERS_H \ No newline at end of file
diff --git a/plugins/IEHistory/src/events.cpp b/plugins/IEHistory/src/events.cpp
new file mode 100644
index 0000000000..90b36b1b63
--- /dev/null
+++ b/plugins/IEHistory/src/events.cpp
@@ -0,0 +1,88 @@
+/*
+IEView history viewer plugin for Miranda IM
+
+Copyright © 2005-2006 Cristian Libotean
+
+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; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "events.h"
+
+HANDLE hModulesLoaded;
+HANDLE hOptionsInitialize;
+
+int HookEvents()
+{
+ hModulesLoaded = HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
+ hOptionsInitialize = HookEvent(ME_OPT_INITIALISE, OnOptionsInitialize);
+ return 0;
+}
+
+int UnhookEvents()
+{
+ UnhookEvent(hModulesLoaded);
+ UnhookEvent(hOptionsInitialize);
+ return 0;
+}
+
+int OnModulesLoaded(WPARAM wParam, LPARAM lParam)
+{
+ Log("%s", "Entering function " __FUNCTION__);
+ CLISTMENUITEM menuItem = {0};
+ menuItem.cbSize = sizeof(CLISTMENUITEM);
+ menuItem.flags = 0;
+ menuItem.pszContactOwner = NULL; //all contacts
+ menuItem.hIcon = hIcon;
+
+ menuItem.position = 1000090000;
+
+ menuItem.pszName = Translate("View contact's history");
+ menuItem.pszService = MS_HISTORY_SHOWCONTACTHISTORY;
+
+ Log("%s", "Adding first menu (view contact's history)");
+ CallService(MS_CLIST_ADDCONTACTMENUITEM, 0, (WPARAM) &menuItem);
+
+ menuItem.ptszName = TranslateT("View system history");
+ //CallService(MS_CLIST_ADDMAINMENUITEM, 0, (WPARAM) &menuItem);
+ //PLUGININFO pInfo = pluginInfo;
+ //pInfo.shortName = "IEView History Viewer";
+ Log("%s", "Adding plugin to updater list");
+ CallService(MS_UPDATE_REGISTERFL, (WPARAM) 2553, (LPARAM) &pluginInfo);
+ Log("%s", "Creating the open windows list");
+ hOpenWindowsList = (HANDLE) CallService(MS_UTILS_ALLOCWINDOWLIST, 0, 0);
+
+ Log("%s", "Leaving function " __FUNCTION__);
+ return 0;
+}
+
+int OnOptionsInitialize(WPARAM wParam, LPARAM lParam)
+{
+ Log("%s", "Entering function " __FUNCTION__);
+ OPTIONSDIALOGPAGE odp = { 0 };
+
+ odp.cbSize = sizeof(odp);
+ odp.position = 100000000;
+ odp.hInstance = hInstance;
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_HISTORY);
+ odp.pszTitle = Translate("IEHistory");
+ odp.pszGroup = Translate("Message Sessions");
+ odp.groupPosition = 910000000;
+ odp.flags=ODPF_BOLDGROUPS;
+ odp.pfnDlgProc = OptionsDlgProc;
+ CallService(MS_OPT_ADDPAGE, wParam, (LPARAM)&odp);
+
+ return 0;
+ Log("%s", "Leaving function " __FUNCTION__);
+} \ No newline at end of file
diff --git a/plugins/IEHistory/src/events.h b/plugins/IEHistory/src/events.h
new file mode 100644
index 0000000000..b19b14fced
--- /dev/null
+++ b/plugins/IEHistory/src/events.h
@@ -0,0 +1,35 @@
+/*
+IEView history viewer plugin for Miranda IM
+
+Copyright © 2005-2006 Cristian Libotean
+
+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; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef M_HISTORY_HOOKED_EVENTS_H
+#define M_HISTORY_HOOKED_EVENTS_H
+
+#include "commonheaders.h"
+
+extern HANDLE hModulesLoaded;
+extern HANDLE hOptionsInitialize;
+
+int HookEvents();
+int UnhookEvents();
+
+int OnModulesLoaded(WPARAM wParam, LPARAM lParam);
+int OnOptionsInitialize(WPARAM wParam, LPARAM lParam);
+
+#endif //M_HISTORY_HOOKED_EVENTS_H \ No newline at end of file
diff --git a/plugins/IEHistory/src/mirandaMem.cpp b/plugins/IEHistory/src/mirandaMem.cpp
new file mode 100644
index 0000000000..8ef20cb2e1
--- /dev/null
+++ b/plugins/IEHistory/src/mirandaMem.cpp
@@ -0,0 +1,42 @@
+/*
+IEView history viewer plugin for Miranda IM
+
+Copyright © 2005-2006 Cristian Libotean
+
+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; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "mirandaMem.h"
+
+void *(*MirandaMalloc)(size_t size) = NULL;
+void *(*MirandaRealloc)(void *data, size_t newSize) = NULL;
+void (*MirandaFree) (void *data) = NULL;
+
+void InitializeMirandaMemFunctions()
+{
+ MM_INTERFACE mmi = {0};
+ mmi.cbSize = sizeof(MM_INTERFACE);
+ CallService(MS_SYSTEM_GET_MMI, 0, (LPARAM) &mmi);
+ MirandaMalloc = mmi.mmi_malloc;
+ MirandaRealloc = mmi.mmi_realloc;
+ MirandaFree = mmi.mmi_free;
+}
+
+void DestroyMirandaMemFunctions()
+{
+ MirandaMalloc = NULL;
+ MirandaRealloc = NULL;
+ MirandaFree = NULL;
+} \ No newline at end of file
diff --git a/plugins/IEHistory/src/mirandaMem.h b/plugins/IEHistory/src/mirandaMem.h
new file mode 100644
index 0000000000..7428278000
--- /dev/null
+++ b/plugins/IEHistory/src/mirandaMem.h
@@ -0,0 +1,33 @@
+/*
+IEView history viewer plugin for Miranda IM
+
+Copyright © 2005 Cristian Libotean
+
+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; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef M_FOLDERS_MIRANDA_MEM_H
+#define M_FOLDERS_MIRANDA_MEM_H
+
+#include "commonheaders.h"
+
+extern void *(*MirandaMalloc)(size_t size);
+extern void *(*MirandaRealloc)(void *data, size_t newSize);
+extern void (*MirandaFree) (void *data);
+
+void InitializeMirandaMemFunctions();
+void DestroyMirandaMemFunctions();
+
+#endif \ No newline at end of file
diff --git a/plugins/IEHistory/src/resource.h b/plugins/IEHistory/src/resource.h
new file mode 100644
index 0000000000..b240d149db
--- /dev/null
+++ b/plugins/IEHistory/src/resource.h
@@ -0,0 +1,45 @@
+//{{NO_DEPENDENCIES}}
+// Microsoft Visual C++ generated include file.
+// Used by IEHistory.rc
+//
+#define IDD_HISTORY 101
+#define IDI_HISTORYICON 102
+#define IDD_OPT_HISTORY 103
+#define IDD_SEARCH 104
+#define IDC_CLOSE 1001
+#define IDC_IEVIEW_PLACEHOLDER 1010
+#define IDC_EVENTSNO_GROUPBOX 1011
+#define IDC_LOAD_ALL 1012
+#define IDC_LOAD_NUMBER 1013
+#define IDC_EVENTS_COUNT 1014
+#define IDC_LOAD_NUMBER_STATIC 1015
+#define IDC_PREV 1016
+#define IDC_NEXT 1017
+#define IDC_PAGE_NUMBER 1018
+#define IDC_STATUSBAR 1019
+#define IDC_SHOW_LAST_FIRST 1021
+#define IDC_MISC_GROUPBOX 1022
+#define IDC_ENABLE_RTL 1023
+#define IDC_FIND_NEXT 1024
+#define IDC_TABS 1025
+#define IDC_SEARCH 1026
+#define IDC_SEARCH_TEXT_STATIC 1027
+#define IDC_SEARCH_TEXT 1028
+#define IDC_DIRECTION_GROUPBOX 1032
+#define IDC_DIRECTION_UP 1033
+#define IDC_DIRECTION_DOWN 1034
+#define IDC_SEARCH_DATE 1035
+#define IDC_SEARCH_TIME 1038
+#define IDC_WORKER_THREAD 1039
+#define IDC_LOAD_BACKGROUND 1039
+
+// Next default values for new objects
+//
+#ifdef APSTUDIO_INVOKED
+#ifndef APSTUDIO_READONLY_SYMBOLS
+#define _APS_NEXT_RESOURCE_VALUE 105
+#define _APS_NEXT_COMMAND_VALUE 40001
+#define _APS_NEXT_CONTROL_VALUE 1040
+#define _APS_NEXT_SYMED_VALUE 101
+#endif
+#endif
diff --git a/plugins/IEHistory/src/services.cpp b/plugins/IEHistory/src/services.cpp
new file mode 100644
index 0000000000..5683eecda8
--- /dev/null
+++ b/plugins/IEHistory/src/services.cpp
@@ -0,0 +1,62 @@
+/*
+IEView history viewer plugin for Miranda IM
+
+Copyright © 2005-2006 Cristian Libotean
+
+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; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "services.h"
+
+HANDLE hShowHistory;
+
+int InitServices()
+{
+ hShowHistory = CreateServiceFunction(MS_HISTORY_SHOWCONTACTHISTORY, ShowContactHistoryService);
+ return 0;
+}
+
+int DestroyServices()
+{
+ DestroyServiceFunction(hShowHistory);
+ return 0;
+}
+
+int ShowContactHistoryService(WPARAM wParam, LPARAM lParam)
+{
+ Log("%s", "Entering function " __FUNCTION__);
+ HWND historyDlg;
+ HWND parent = NULL;
+ historyDlg = WindowList_Find(hOpenWindowsList, (HANDLE) wParam);
+ if (historyDlg == NULL)
+ {
+ int count = DBGetContactSettingDword(NULL, ModuleName, "EventsToLoad", 0);
+ int loadInBackground = DBGetContactSettingByte(NULL, ModuleName, "UseWorkerThread", 0);
+ HistoryWindowData *data;
+ data = (HistoryWindowData *) malloc(sizeof(HistoryWindowData));
+ data->hContact = (HANDLE) wParam;
+ data->hIEView = NULL;
+ data->itemsPerPage = count;
+ data->index = 0;
+ data->count = 0;
+ data->loadMethod = (loadInBackground) ? LOAD_IN_BACKGROUND : 0;
+ historyDlg = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_HISTORY), parent, HistoryDlgProc);
+ SetWindowLong(historyDlg, DWL_USER, (LONG) data);
+
+ WindowList_Add(hOpenWindowsList, historyDlg, (HANDLE) wParam);
+ }
+ ShowWindow(historyDlg, SW_SHOW);
+ return 0;
+} \ No newline at end of file
diff --git a/plugins/IEHistory/src/services.h b/plugins/IEHistory/src/services.h
new file mode 100644
index 0000000000..40e680a04e
--- /dev/null
+++ b/plugins/IEHistory/src/services.h
@@ -0,0 +1,32 @@
+/*
+IEView history viewer plugin for Miranda IM
+
+Copyright © 2005-2006 Cristian Libotean
+
+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; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef M_IEHISTORY_PROVIDED_SERVICES_H
+#define M_IEHISTORY_PROVIDED_SERVICES_H
+
+#include "commonheaders.h"
+#include "dlgHandlers.h"
+
+int InitServices();
+int DestroyServices();
+
+int ShowContactHistoryService(WPARAM wParam, LPARAM lParam);
+
+#endif //M_IEHISTORY_PROVIDED_SERVICES_H \ No newline at end of file
diff --git a/plugins/IEHistory/src/stdafx.cpp b/plugins/IEHistory/src/stdafx.cpp
new file mode 100644
index 0000000000..2731c2b8c3
--- /dev/null
+++ b/plugins/IEHistory/src/stdafx.cpp
@@ -0,0 +1,25 @@
+/*
+IEView history viewer plugin for Miranda IM
+
+Copyright © 2005-2006 Cristian Libotean
+
+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; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+
+#include "stdafx.h"
+
+// TODO: reference any additional headers you need in STDAFX.H
+// and not in this file
diff --git a/plugins/IEHistory/src/stdafx.h b/plugins/IEHistory/src/stdafx.h
new file mode 100644
index 0000000000..fe90144550
--- /dev/null
+++ b/plugins/IEHistory/src/stdafx.h
@@ -0,0 +1,47 @@
+/*
+IEView history viewer plugin for Miranda IM
+
+Copyright © 2005-2006 Cristian Libotean
+
+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; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#pragma once
+
+// Modify the following defines if you have to target a platform prior to the ones specified below.
+// Refer to MSDN for the latest info on corresponding values for different platforms.
+#ifndef WINVER // Allow use of features specific to Windows XP or later.
+#define WINVER 0x0501 // Change this to the appropriate value to target other versions of Windows.
+#endif
+
+#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later.
+#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows.
+#endif
+
+#ifndef _WIN32_WINDOWS // Allow use of features specific to Windows 98 or later.
+#define _WIN32_WINDOWS 0x0410 // Change this to the appropriate value to target Windows Me or later.
+#endif
+
+#ifndef _WIN32_IE // Allow use of features specific to IE 6.0 or later.
+#define _WIN32_IE 0x0600 // Change this to the appropriate value to target other versions of IE.
+#endif
+
+#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
+// Windows Header Files:
+#include <windows.h>
+
+
+
+// TODO: reference additional headers your program requires here
diff --git a/plugins/IEHistory/src/utils.cpp b/plugins/IEHistory/src/utils.cpp
new file mode 100644
index 0000000000..91577e698f
--- /dev/null
+++ b/plugins/IEHistory/src/utils.cpp
@@ -0,0 +1,330 @@
+/*
+IEView history viewer plugin for Miranda IM
+
+Copyright © 2005-2006 Cristian Libotean
+
+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; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#include "commonheaders.h"
+
+int LogInit()
+{
+#ifdef _DEBUG
+ FILE *fout = fopen("IEHistory.log", "wt");
+ fclose(fout);
+#endif
+ return 0;
+}
+
+int Log(char *format, ...)
+{
+#ifdef _DEBUG
+ char str[4096];
+ va_list vararg;
+ int tBytes;
+ FILE *fout = fopen("IEHistory.log", "at");
+ if (!fout)
+ {
+// MessageBox(0, "can't open file", NULL, MB_OK);
+ }
+
+ va_start(vararg, format);
+
+ tBytes = _vsnprintf(str, sizeof(str), format, vararg);
+ if (tBytes > 0)
+ {
+ str[tBytes] = 0;
+ }
+
+ va_end(vararg);
+ if (str[strlen(str) - 1] != '\n')
+ {
+ strcat(str, "\n");
+ }
+ fputs(str, fout);
+ fclose(fout);
+#endif
+ return 0;
+
+}
+
+
+
+int Info(char *title, char *format, ...)
+{
+ char str[4096];
+ va_list vararg;
+ int tBytes;
+ va_start(vararg, format);
+ tBytes = _snprintf(str, sizeof(str), format, vararg);
+ if (tBytes > 0)
+ {
+ str[tBytes] = 0;
+ }
+ va_end(vararg);
+ return MessageBoxA(0, str, title, MB_OK | MB_ICONINFORMATION);
+}
+
+/*
+returns the name of a contact
+*/
+
+#pragma warning (disable: 4312)
+TCHAR *GetContactName(HANDLE hContact, char *szProto)
+{
+ CONTACTINFO ctInfo;
+ int ret;
+
+ ZeroMemory((void *) &ctInfo, sizeof(ctInfo));
+ ctInfo.cbSize = sizeof(ctInfo);
+ ctInfo.szProto = szProto;
+ ctInfo.dwFlag = CNF_DISPLAY;
+#ifdef _UNICODE
+ ctInfo.dwFlag += CNF_UNICODE;
+#endif
+ ctInfo.hContact = hContact;
+ //_debug_message("retrieving contact name for %d", hContact);
+ ret = CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM) &ctInfo);
+ //_debug_message(" contact name %s", ctInfo.pszVal);
+ TCHAR *buffer;
+ if (!ret)
+ {
+ buffer = _tcsdup(ctInfo.pszVal);
+ }
+ else{
+ return NULL;
+ }
+ MirandaFree(ctInfo.pszVal);
+ if (!ret)
+ {
+ return buffer;
+ }
+ else{
+ return NULL;
+ }
+ return buffer;
+}
+#pragma warning (default: 4312)
+
+/*
+Moves a control with regard to certain anchors (like delphi, c#, ...)
+Somebody please improve on this code ...
+*/
+
+void ScreenToClient(HWND hWnd, LPRECT rect)
+{
+ POINT pt;
+ int cx = rect->right - rect->left;
+ int cy = rect->bottom - rect->top;
+ pt.x = rect->left;
+ pt.y = rect->top;
+ ScreenToClient(hWnd, &pt);
+ rect->left = pt.x;
+ rect->top = pt.y;
+ rect->right = pt.x + cx;
+ rect->bottom = pt.y + cy;
+}
+
+void AnchorMoveWindow(HWND window, const WINDOWPOS *parentPos, int anchors)
+{
+ RECT rParent;
+ RECT rChild;
+
+ if (parentPos->flags & SWP_NOSIZE)
+ {
+ return;
+ }
+ GetWindowRect(parentPos->hwnd, &rParent);
+ rChild = AnchorCalcPos(window, &rParent, parentPos, anchors);
+ MoveWindow(window, rChild.left, rChild.top, rChild.right - rChild.left, rChild.bottom - rChild.top, FALSE);
+}
+
+RECT AnchorCalcPos(HWND window, const RECT *rParent, const WINDOWPOS *parentPos, int anchors)
+{
+ RECT rChild;
+ RECT rTmp;
+
+ GetWindowRect(window, &rChild);
+ ScreenToClient(parentPos->hwnd, &rChild);
+
+ int cx = rParent->right - rParent->left;
+ int cy = rParent->bottom - rParent->top;
+ if ((cx == parentPos->cx) && (cy == parentPos->cy))
+ {
+ return rChild;
+ }
+ if (parentPos->flags & SWP_NOSIZE)
+ {
+ return rChild;
+ }
+
+ rTmp.left = parentPos->x - rParent->left;
+ rTmp.right = (parentPos->x + parentPos->cx) - rParent->right;
+ rTmp.bottom = (parentPos->y + parentPos->cy) - rParent->bottom;
+ rTmp.top = parentPos->y - rParent->top;
+
+ cx = (rTmp.left) ? -rTmp.left : rTmp.right;
+ cy = (rTmp.top) ? -rTmp.top : rTmp.bottom;
+
+ rChild.right += cx;
+ rChild.bottom += cy;
+ //expanded the window accordingly, now we need to enforce the anchors
+ if ((anchors & ANCHOR_LEFT) && (!(anchors & ANCHOR_RIGHT)))
+ {
+ rChild.right -= cx;
+ }
+ if ((anchors & ANCHOR_TOP) && (!(anchors & ANCHOR_BOTTOM)))
+ {
+ rChild.bottom -= cy;
+ }
+ if ((anchors & ANCHOR_RIGHT) && (!(anchors & ANCHOR_LEFT)))
+ {
+ rChild.left += cx;
+ }
+ if ((anchors & ANCHOR_BOTTOM) && (!(anchors & ANCHOR_TOP)))
+ {
+ rChild.top += cy;
+ }
+ return rChild;
+}
+
+#pragma warning (disable: 4244)
+void UnixTimeToFileTime(time_t t, LPFILETIME pft)
+{
+ // Note that LONGLONG is a 64-bit value
+ LONGLONG ll;
+
+ ll = Int32x32To64(t, 10000000) + 116444736000000000;
+ pft->dwLowDateTime = (DWORD)ll;
+ pft->dwHighDateTime = ll >> 32;
+}
+#pragma warning (default: 4244)
+
+void UnixTimeToSystemTime(time_t t, LPSYSTEMTIME pst)
+{
+ FILETIME ft;
+ SYSTEMTIME st;
+ UnixTimeToFileTime(t, &ft);
+ FileTimeToSystemTime(&ft, &st);
+ SystemTimeToTzSpecificLocalTime(NULL, &st, pst);
+}
+
+HANDLE GetNeededEvent(HANDLE hLastFirstEvent, int index, int direction)
+{
+ int i;
+ HANDLE hEvent = hLastFirstEvent;
+ const char *service;
+ if (direction == DIRECTION_BACK)
+ {
+ service = MS_DB_EVENT_FINDPREV;
+ }
+ else{
+ service = MS_DB_EVENT_FINDNEXT;
+ }
+
+ for (i = 0; i < index; i++)
+ {
+ hEvent = (HANDLE) CallService(service, (WPARAM) hEvent, 0);
+ }
+ return hEvent;
+}
+
+SearchResult SearchHistory(HANDLE hContact, HANDLE hFirstEvent, void *searchData, int direction, int type)
+{
+ if (hFirstEvent == NULL)
+ {
+ const char *service = (direction == DIRECTION_BACK) ? MS_DB_EVENT_FINDLAST : MS_DB_EVENT_FINDFIRST;
+ hFirstEvent = (HANDLE) CallService(service, (WPARAM) hContact, 0);
+ }
+ int index = 0;
+ HANDLE hEvent = hFirstEvent;
+ void *buffer = NULL;
+ TCHAR *search;
+ wchar_t TEMP[2048];
+ bool found = false;
+ int oldSize, newSize;
+ oldSize = newSize = 0;
+
+ DBEVENTINFO dbEvent = {0};
+ dbEvent.cbSize = sizeof(dbEvent);
+
+ while ((!found) && (hEvent))
+ {
+ newSize = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM) hEvent, 0);
+ if (newSize > oldSize)
+ {
+ buffer = (TCHAR *) realloc(buffer, newSize);
+ oldSize = newSize;
+ }
+ dbEvent.pBlob = (PBYTE) buffer;
+ dbEvent.cbBlob = newSize;
+ if (CallService(MS_DB_EVENT_GET, (WPARAM) hEvent, (LPARAM) &dbEvent) == 0) //successful
+ {
+ switch (type)
+ {
+ case SEARCH_TEXT:
+ {
+#ifdef _UNICODE
+ unsigned int size = strlen((char *) dbEvent.pBlob) + 1;
+ if (size < dbEvent.cbBlob)
+ {
+ search = (wchar_t *) &dbEvent.pBlob[size];
+ }
+ else{
+ MultiByteToWideChar(CP_ACP, 0, (char *) buffer, size, TEMP, 2048);
+ search = TEMP;
+ }
+#else
+ search = (char *) buffer;
+#endif
+ TCHAR *data = (TCHAR *) searchData;
+ TCHAR *tmp = _tcsstr(search, data);
+ if (tmp)
+ {
+ found = true;
+ }
+ break;
+ }
+ case SEARCH_TIME:
+ {
+ SYSTEMTIME time;
+ TimeSearchData *data = (TimeSearchData *) searchData;
+ UnixTimeToSystemTime((time_t) dbEvent.timestamp, &time);
+ found = ((data->flags & TSDF_DATE_SET) || (data->flags & TSDF_TIME_SET)) ? true : false;
+ if (data->flags & TSDF_DATE_SET)
+ {
+ found = ((time.wYear == data->time.wYear) && (time.wMonth == data->time.wMonth) && (time.wDay == data->time.wDay));
+ }
+ if (data->flags & TSDF_TIME_SET)
+ {
+ found = found & ((time.wHour == data->time.wHour) && (time.wMinute == data->time.wMinute));
+ }
+ break;
+ }
+ }
+ }
+ if (!found)
+ {
+ hEvent = GetNeededEvent(hEvent, 1, direction);
+ index++;
+ }
+ }
+ free(buffer);
+ SearchResult sr;
+ sr.index = index;
+ sr.hEvent = hEvent;
+ return sr;
+} \ No newline at end of file
diff --git a/plugins/IEHistory/src/utils.h b/plugins/IEHistory/src/utils.h
new file mode 100644
index 0000000000..c423b4ede7
--- /dev/null
+++ b/plugins/IEHistory/src/utils.h
@@ -0,0 +1,97 @@
+/*
+IEView history viewer plugin for Miranda IM
+
+Copyright © 2005-2006 Cristian Libotean
+
+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; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef M_IEHISTORY_UTILS_H
+#define M_IEHISTORY_UTILS_H
+
+#include "stdafx.h"
+#include "time.h"
+
+#define ANCHOR_LEFT 0x000001
+#define ANCHOR_RIGHT 0x000002
+#define ANCHOR_TOP 0x000004
+#define ANCHOR_BOTTOM 0x000008
+#define ANCHOR_ALL ANCHOR_LEFT | ANCHOR_RIGHT | ANCHOR_TOP | ANCHOR_BOTTOM
+
+#define DIRECTION_BACK 0x000001
+#define DIRECTION_FORWARD 0x000002
+
+#define SEARCH_TEXT 0x000001
+#define SEARCH_TIME 0x000002
+
+/*
+#define SIDE_LEFT 0x000001
+#define SIDE_TOP 0x000002
+#define SIDE_RIGHT 0x000004
+#define SIDE_BOTTOM 0x000008
+#define SIDE_TOPLEFT SIDE_TOP | SIDE_LEFT
+#define SIDE_TOPRIGHT SIDE_TOP | SIDE_RIGHT
+#define SIDE_BOTTOMLEFT SIDE_BOTTOM | SIDE_LEFT
+#define SIDE_BOTTOMRIGHT SIDE_BOTTOM | SIDE_RIGHT
+*/
+
+#define TSDF_TIME_SET 0x00000001
+#define TSDF_DATE_SET 0x00000002
+
+struct TimeSearchData{
+ int flags;
+ SYSTEMTIME time;
+};
+
+struct SearchResult{
+ long index;
+ HANDLE hEvent;
+};
+
+//#ifdef _DEBUG
+int LogInit();
+int Log(char *format, ...);
+//#endif
+
+void ScreenToClient(HWND hWnd, LPRECT rect);
+
+int Info(char *title, char *format, ...);
+TCHAR *GetContactName(HANDLE hContact, char *szProto);
+void AnchorMoveWindow(HWND window, const WINDOWPOS *parentPos, int anchors);
+RECT AnchorCalcPos(HWND window, const RECT *rParent, const WINDOWPOS *parentPos, int anchors);
+
+void UnixTimeToFileTime(time_t t, LPFILETIME pft);
+void UnixTimeToSystemTime(time_t t, LPSYSTEMTIME pst);
+
+HANDLE GetNeededEvent(HANDLE hLastFirstEvent, int index, int direction);
+SearchResult SearchHistory(HANDLE hContact, HANDLE hFirstEvent, void *searchData, int direction, int type);
+
+extern void *(*MirandaMalloc)(size_t size);
+extern void *(*MirandaRealloc)(void *data, size_t newSize);
+extern void (*MirandaFree) (void *data);
+
+/*
+static __inline int mir_snprintf(char *buffer, size_t count, const char* fmt, ...) {
+ va_list va;
+ int len;
+
+ va_start(va, fmt);
+ len = _vsnprintf(buffer, count-1, fmt, va);
+ va_end(va);
+ buffer[count-1] = 0;
+ return len;
+}
+*/
+#endif \ No newline at end of file
diff --git a/plugins/IEHistory/src/version.h b/plugins/IEHistory/src/version.h
new file mode 100644
index 0000000000..204fd10561
--- /dev/null
+++ b/plugins/IEHistory/src/version.h
@@ -0,0 +1,53 @@
+/*
+Bonsai plugin for Miranda IM
+
+Copyright © 2006 Cristian Libotean
+
+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; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+*/
+
+#ifndef M_IEHISTORY_VERSION_H
+#define M_IEHISTORY_VERSION_H
+
+#define __MAJOR_VERSION 0
+#define __MINOR_VERSION 0
+#define __RELEASE_NUM 1
+#define __BUILD_NUM 4
+
+#define VERSION PLUGIN_MAKE_VERSION(__MAJOR_VERSION, __MINOR_VERSION, __RELEASE_NUM, __BUILD_NUM)
+
+#define __PLUGINVERSION_STRING __MAJOR_VERSION,__MINOR_VERSION,__RELEASE_NUM,__BUILD_NUM
+#define __PLUGINVERSION_STRING_DOTS __MAJOR_VERSION.__MINOR_VERSION.__RELEASE_NUM.__BUILD_NUM
+#define __STRINGIFY_(x) #x
+#define __STRINGIFY(x) __STRINGIFY_(x)
+#define __VERSION_STRING __STRINGIFY(__PLUGINVERSION_STRING_DOTS)
+
+#ifdef _UNICODE
+#define __DESC "IEView history viewer for unicode cores."
+#else
+#define __DESC "IEView history viewer for non unicode cores."
+#endif
+#define __AUTHOR "Cristian Libotean"
+#define __AUTHOREMAIL "eblis102@yahoo.com"
+#define __COPYRIGHT "© 2006 Cristian Libotean"
+#define __AUTHORWEB "http://www.miranda-im.org/"
+
+#ifdef _UNICODE
+#define __PLUGIN_DISPLAY_NAME "IEView History Viewer (Unicode)"
+#else
+#define __PLUGIN_DISPLAY_NAME "IEView History Viewer"
+#endif
+
+#endif //M_IEHISTORY_VERSION_H