summaryrefslogtreecommitdiff
path: root/plugins/IEHistory/src
diff options
context:
space:
mode:
authorRené Schümann <white06tiger@gmail.com>2014-08-21 11:42:31 +0000
committerRené Schümann <white06tiger@gmail.com>2014-08-21 11:42:31 +0000
commit2ae4a360da9638ecaaa68bbb683187ef8e1faf35 (patch)
tree99a533c91fccdd70bb8bde2360f42bd5a6b7703b /plugins/IEHistory/src
parentd33b48c34e2ce98bd5a73698006be3859a7dfbc4 (diff)
IEHistory: Miranda NG compatibility.
- removed mirandaMem * GetWindowLong => GetWindowLongPtr * SetWindowLong => SetWindowLongPtr * DLGPROC returning int/BOOL => INT_PTR * CallService(MS_DB_EVENT_*) => db_event_* * DBGetContactSetting* => db_get_* * DBWriteContactSetting => db_set_* * contact HANDLE => MCONTACT * CallService(MS_CLIST_ADD*MENUITEM,...) => Menu_Add*MenuItem() * improved GetContactName() - removed some #pragma warning's * version bump to 0.0.1.5 git-svn-id: http://svn.miranda-ng.org/main/trunk@10253 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/IEHistory/src')
-rw-r--r--plugins/IEHistory/src/IEHistory.cpp49
-rw-r--r--plugins/IEHistory/src/commonheaders.h71
-rw-r--r--plugins/IEHistory/src/dlgHandlers.cpp144
-rw-r--r--plugins/IEHistory/src/dlgHandlers.h12
-rw-r--r--plugins/IEHistory/src/events.cpp42
-rw-r--r--plugins/IEHistory/src/mirandaMem.cpp42
-rw-r--r--plugins/IEHistory/src/mirandaMem.h33
-rw-r--r--plugins/IEHistory/src/services.cpp41
-rw-r--r--plugins/IEHistory/src/services.h4
-rw-r--r--plugins/IEHistory/src/stdafx.h3
-rw-r--r--plugins/IEHistory/src/utils.cpp194
-rw-r--r--plugins/IEHistory/src/utils.h22
-rw-r--r--plugins/IEHistory/src/version.h34
13 files changed, 262 insertions, 429 deletions
diff --git a/plugins/IEHistory/src/IEHistory.cpp b/plugins/IEHistory/src/IEHistory.cpp
index 33e892992f..86f93ed20c 100644
--- a/plugins/IEHistory/src/IEHistory.cpp
+++ b/plugins/IEHistory/src/IEHistory.cpp
@@ -23,13 +23,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "commonheaders.h"
#include "services.h"
+int hLangpack;//Miranda NG langpack used by translate functions, filled by mir_getLP()
char ModuleName[] = "IEHistory";
HICON hIcon;
HINSTANCE hInstance;
HANDLE hOpenWindowsList = NULL;
-PLUGINLINK *pluginLink;
-
HMODULE hUxTheme = 0;
BOOL (WINAPI *MyEnableThemeDialogTexture)(HANDLE, DWORD) = NULL;
@@ -42,27 +41,17 @@ BOOL (WINAPI *MyEnableThemeDialogTexture)(HANDLE, DWORD) = NULL;
PLUGININFOEX pluginInfo = {
sizeof(PLUGININFOEX),
__PLUGIN_DISPLAY_NAME,
- VERSION,
+ __VERSION_DWORD,
__DESC,
- __AUTHOR,
- __AUTHOREMAIL,
+ __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
+ {0x2f093b88, 0xf389, 0x44f1, {0x9e, 0x2a, 0x37, 0xc2, 0x91, 0x94, 0x20, 0x3a}} //{2f093b88-f389-44f1-9e2a-37c29194203a}
};
-OLD_MIRANDAPLUGININFO_SUPPORT;
-
extern "C" __declspec(dllexport) PLUGININFOEX *MirandaPluginInfoEx(DWORD mirandaVersion)
{
- Log("%s", "Entering function " __FUNCTION__);
- Log("%s", "Leaving function " __FUNCTION__);
return &pluginInfo;
}
@@ -75,8 +64,9 @@ extern "C" __declspec(dllexport) const MUUID *MirandaPluginInterfaces()
#include <commctrl.h>
-extern "C" int __declspec(dllexport) Load(PLUGINLINK *link)
+extern "C" int __declspec(dllexport) Load(void)
{
+ mir_getLP(&pluginInfo);
INITCOMMONCONTROLSEX icex;
icex.dwSize = sizeof(icex);
@@ -84,48 +74,33 @@ extern "C" int __declspec(dllexport) Load(PLUGINLINK *link)
InitCommonControlsEx(&icex);
- if((hUxTheme = LoadLibraryA("uxtheme.dll")) != 0)
- {
+ 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;
+ if(fdwReason == DLL_PROCESS_ATTACH){
+ DisableThreadLibraryCalls(hinstDLL);
+ LogInit();
+ }
+ return TRUE;
}
diff --git a/plugins/IEHistory/src/commonheaders.h b/plugins/IEHistory/src/commonheaders.h
index e687a27f02..322932f1e4 100644
--- a/plugins/IEHistory/src/commonheaders.h
+++ b/plugins/IEHistory/src/commonheaders.h
@@ -34,27 +34,46 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#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"
-
+#include <newpluginapi.h>
+#include <m_database.h>
+#include <m_utils.h>
+#include <m_system.h>
+#include <m_skin.h>
+#include <m_options.h>
+#include <m_clist.h>
+#include <m_langpack.h>
+#include <m_history.h>
+#include <m_contacts.h>
+#include <m_metacontacts.h>
+#include <m_protocols.h>
+//#include <m_utils.h>
+#include <m_popup.h>
+#include <m_ieview.h>
+
+static FILE* fopen_s2(const char* file,const char* mode){
+ FILE* ret=NULL; fopen_s(&ret,file,mode);
+ return ret;
+}
+#define fopen fopen_s2
+#define strcat strcat_s
+#define _vsnprintf _vsnprintf_s
+#define snprintf _snprintf_s
+#define snwprintf _snwprintf_s
+#define sprintf sprintf_s
+#define itow _itow_s
+#ifndef _UNICODE
+# define itot itoa
+# define sntprintf snprintf
+#else
+# define itot itow
+# define sntprintf snwprintf
+#endif
extern HICON hIcon; //history icon
+extern int hLangpack;
extern char ModuleName[];
extern HINSTANCE hInstance; //dll instance
extern HANDLE hOpenWindowsList;
@@ -63,22 +82,4 @@ 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
+#endif
diff --git a/plugins/IEHistory/src/dlgHandlers.cpp b/plugins/IEHistory/src/dlgHandlers.cpp
index a9d4734abe..3f44cac49a 100644
--- a/plugins/IEHistory/src/dlgHandlers.cpp
+++ b/plugins/IEHistory/src/dlgHandlers.cpp
@@ -32,7 +32,7 @@ struct WorkerThreadData{
IEVIEWEVENT ieEvent;
};
-int LoadName(HWND hWnd);
+void LoadName(HWND hWnd);
int CalcIEViewPos(IEVIEWWINDOW *ieWnd, HWND hMainWindow);
int LoadIEView(HWND hWnd);
int MoveIEView(HWND hWnd);
@@ -60,25 +60,19 @@ int CalcIEViewPos(IEVIEWWINDOW *ieWnd, HWND hMainWindow)
return 0;
}
-int LoadName(HWND hWnd)
+void 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);
+ HistoryWindowData *data = (HistoryWindowData *) GetWindowLongPtr(hWnd, DWLP_USER);
+ TCHAR *szOther = GetContactName(data->contact);
TCHAR buffer[1024];
- _sntprintf(buffer, 1024, _T("%s: IEHistory"), szOther);
+ sntprintf(buffer, 1024, _T("'%s' - IEHistory"), szOther);
SetWindowText(hWnd, buffer);
- free(szOther);
- return 0;
+ mir_free(szOther);
}
int LoadIEView(HWND hWnd)
{
- IEVIEWWINDOW ieWnd = {0};
- ieWnd.cbSize = sizeof(ieWnd);
+ IEVIEWWINDOW ieWnd = {sizeof(ieWnd)};
ieWnd.iType = IEW_CREATE;
ieWnd.dwMode = IEWM_HISTORY;
ieWnd.dwFlags = 0;
@@ -86,7 +80,7 @@ int LoadIEView(HWND hWnd)
CalcIEViewPos(&ieWnd, hWnd);
CallService(MS_IEVIEW_WINDOW, 0, (LPARAM) &ieWnd);
- HistoryWindowData *data = (HistoryWindowData *) GetWindowLong(hWnd, DWL_USER);
+ HistoryWindowData *data = (HistoryWindowData *) GetWindowLongPtr(hWnd, DWLP_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);
@@ -95,7 +89,7 @@ int LoadIEView(HWND hWnd)
int MoveIeView(HWND hWnd)
{
- HistoryWindowData *data = (HistoryWindowData *) GetWindowLong(hWnd, DWL_USER);
+ HistoryWindowData *data = (HistoryWindowData *) GetWindowLongPtr(hWnd, DWLP_USER);
if (data)
{
IEVIEWWINDOW ieWnd = {0};
@@ -111,7 +105,7 @@ int MoveIeView(HWND hWnd)
int DestroyIEView(HWND hWnd)
{
- HistoryWindowData *data = (HistoryWindowData *) GetWindowLong(hWnd, DWL_USER);
+ HistoryWindowData *data = (HistoryWindowData *) GetWindowLongPtr(hWnd, DWLP_USER);
IEVIEWWINDOW ieWnd = {0};
ieWnd.cbSize = sizeof(ieWnd);
ieWnd.parent = hWnd;
@@ -142,7 +136,7 @@ void FillIEViewInfo(IEVIEWEVENTDATA *fillData, DBEVENTINFO dbInfo, PBYTE blob)
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;
+ size_t len = strlen((char *) blob) + 1;
PBYTE pos;
fillData->pszText = (char *) blob;
@@ -166,7 +160,6 @@ DWORD WINAPI WorkerThread(LPVOID lpvData)
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;
@@ -176,7 +169,7 @@ DWORD WINAPI WorkerThread(LPVOID lpvData)
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;
+ IEVIEWEVENT ieEvent = data->ieEvent;
ieEvent.iType = IEE_LOG_MEM_EVENTS;
ieEvent.eventData = ieData;
DBEVENTINFO dbInfo = {0};
@@ -190,7 +183,7 @@ DWORD WINAPI WorkerThread(LPVOID lpvData)
for (i = 0; i < cLoad; i++)
{
- newSize = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM) dbEvent, 0);
+ newSize = db_event_getBlobSize(dbEvent);
if (newSize > oldSize)
{
buffer = (PBYTE) realloc(buffer, newSize);
@@ -199,13 +192,13 @@ DWORD WINAPI WorkerThread(LPVOID lpvData)
}
messages[i] = (PBYTE) realloc(messages[i], newSize);
dbInfo.cbBlob = newSize;
- if (!CallService(MS_DB_EVENT_GET, (WPARAM) dbEvent, (LPARAM) &dbInfo))
+ if (!db_event_get(dbEvent,&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);
+ dbEvent = db_event_next(0,dbEvent);
}
ieData[cLoad - 1].next = NULL; //cLoad < LOAD_COUNT will only happen once, at the end
CallService(MS_IEVIEW_EVENT, 0, (LPARAM) &ieEvent);
@@ -248,11 +241,11 @@ int DoLoadEvents(HWND hWnd, HistoryWindowData *data, IEVIEWEVENT ieEvent)
ScrollToBottom(hWnd);
TCHAR buffer[256];
- _itot(data->index + 1, buffer, 10);
+ itot(data->index + 1, buffer, 10);
SendDlgItemMessage(hWnd, IDC_STATUSBAR, SB_SETTEXT, 0 | SBT_POPOUT, (LPARAM) buffer);
- _itot(data->index + ieEvent.count, buffer, 10);
+ itot(data->index + ieEvent.count, buffer, 10);
SendDlgItemMessage(hWnd, IDC_STATUSBAR, SB_SETTEXT, 1 | SBT_POPOUT, (LPARAM) buffer);
- _itot(data->count, buffer, 10);
+ itot(data->count, buffer, 10);
SendDlgItemMessage(hWnd, IDC_STATUSBAR, SB_SETTEXT, 3 | SBT_POPOUT, (LPARAM) buffer);
RefreshButtonStates(hWnd);
}
@@ -261,31 +254,30 @@ int DoLoadEvents(HWND hWnd, HistoryWindowData *data, IEVIEWEVENT ieEvent)
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);
+ HistoryWindowData *data = (HistoryWindowData *) GetWindowLongPtr(hWnd, DWLP_USER);
+ int count = db_event_count(data->contact);
+ int bLastFirst = db_get_b(NULL, ModuleName, "ShowLastPageFirst", 0);
+ int bRTL = db_get_b(NULL, ModuleName, "EnableRTL", 0);
+ bRTL = db_get_b(data->contact, "Tab_SRMsg", "RTL", bRTL);
data->bEnableRTL = bRTL;
data->count = count;
if (data->itemsPerPage > count)
{
data->itemsPerPage = count;
}
- IEVIEWEVENT ieEvent = {0};
- ieEvent.cbSize = sizeof(ieEvent);
+ IEVIEWEVENT ieEvent = {sizeof(ieEvent)};
ieEvent.hwnd = data->hIEView;
- ieEvent.hContact = data->hContact;
+ ieEvent.hContact = data->contact;
ieEvent.count = (data->itemsPerPage <= 0) ? count : data->itemsPerPage;
- HANDLE hFirstEvent = (HANDLE) CallService(MS_DB_EVENT_FINDFIRST, (WPARAM) data->hContact, 0);
- int index = 0;
+ HANDLE hFirstEvent = db_event_first(data->contact);
+ int num = 0;
if ((data->itemsPerPage > 0) && (bLastFirst))
{
- index = data->count - data->itemsPerPage;
- hFirstEvent = GetNeededEvent(hFirstEvent, index, DIRECTION_FORWARD);
+ num = data->count - data->itemsPerPage;
+ hFirstEvent = GetNeededEvent(hFirstEvent, num, DIRECTION_FORWARD);
}
- data->index = index;
+ data->index = num;
data->hLastFirstEvent = hFirstEvent;
ieEvent.hDbEventFirst = hFirstEvent;
if (data->bEnableRTL)
@@ -298,13 +290,12 @@ int LoadEvents(HWND hWnd)
int LoadPage(HWND hWnd, HANDLE hFirstEvent, long index, long shiftCount, long readCount, int direction)
{
- HistoryWindowData *data = (HistoryWindowData *) GetWindowLong(hWnd, DWL_USER);
+ HistoryWindowData *data = (HistoryWindowData *) GetWindowLongPtr(hWnd, DWLP_USER);
int count = shiftCount;
int newIndex = index;
- IEVIEWEVENT ieEvent = {0};
- ieEvent.cbSize = sizeof(ieEvent);
+ IEVIEWEVENT ieEvent = {sizeof(ieEvent)};
ieEvent.hwnd = data->hIEView;
- ieEvent.hContact = data->hContact;
+ ieEvent.hContact = data->contact;
if (direction == DIRECTION_BACK)
{
@@ -333,12 +324,12 @@ int LoadPage(HWND hWnd, HANDLE hFirstEvent, long index, long shiftCount, long re
ieEvent.dwFlags |= IEEF_RTL;
}
DoLoadEvents(hWnd, data, ieEvent);
- return 0;
+ return 0;
}
int LoadPrev(HWND hWnd)
{
- HistoryWindowData *data = (HistoryWindowData *) GetWindowLong(hWnd, DWL_USER);
+ HistoryWindowData *data = (HistoryWindowData *) GetWindowLongPtr(hWnd, DWLP_USER);
LoadPage(hWnd, data->hLastFirstEvent, data->index, data->itemsPerPage, data->itemsPerPage, DIRECTION_BACK);
int finish = data->index <= 0;
return finish;
@@ -346,7 +337,7 @@ int LoadPrev(HWND hWnd)
int LoadNext(HWND hWnd)
{
- HistoryWindowData *data = (HistoryWindowData *) GetWindowLong(hWnd, DWL_USER);
+ HistoryWindowData *data = (HistoryWindowData *) GetWindowLongPtr(hWnd, DWLP_USER);
LoadPage(hWnd, data->hLastFirstEvent, data->index, data->itemsPerPage, data->itemsPerPage, DIRECTION_FORWARD);
int finish = data->index + data->itemsPerPage >= data->count;
return finish;
@@ -354,7 +345,7 @@ int LoadNext(HWND hWnd)
int ScrollToBottom(HWND hWnd)
{
- HistoryWindowData *data = (HistoryWindowData *) GetWindowLong(hWnd, DWL_USER);
+ HistoryWindowData *data = (HistoryWindowData *) GetWindowLongPtr(hWnd, DWLP_USER);
IEVIEWWINDOW ieWnd = {0};
ieWnd.cbSize = sizeof(ieWnd);
ieWnd.iType = IEW_SCROLLBOTTOM;
@@ -372,7 +363,7 @@ void AddAnchorWindowToDeferList(HDWP &hdWnds, HWND window, RECT *rParent, WINDOW
void RefreshButtonStates(HWND hWnd)
{
- HistoryWindowData *data = (HistoryWindowData *) GetWindowLong(hWnd, DWL_USER);
+ HistoryWindowData *data = (HistoryWindowData *) GetWindowLongPtr(hWnd, DWLP_USER);
int bPrev = data->index > 0;
int bNext = data->index + data->itemsPerPage < data->count;
EnableWindow(GetDlgItem(hWnd, IDC_PREV), bPrev);
@@ -381,7 +372,7 @@ void RefreshButtonStates(HWND hWnd)
-BOOL CALLBACK HistoryDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
+INT_PTR CALLBACK HistoryDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
@@ -391,10 +382,10 @@ BOOL CALLBACK HistoryDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
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);
+ int bRTL = db_get_b(NULL, ModuleName, "EnableRTL", 0);
if (bRTL)
{
- SetWindowLong(hWnd, GWL_EXSTYLE, WS_EX_RTLREADING);
+ SetWindowLongPtr(hWnd, GWL_EXSTYLE, WS_EX_RTLREADING);
}
//InitCommonControls();
HWND hStatusBar = CreateWindow(STATUSCLASSNAME, //class
@@ -414,7 +405,6 @@ BOOL CALLBACK HistoryDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
//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:
{
@@ -423,9 +413,9 @@ BOOL CALLBACK HistoryDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
LoadIEView(hWnd);
LoadEvents(hWnd);
- HistoryWindowData *data = (HistoryWindowData *) GetWindowLong(hWnd, DWL_USER);
+ HistoryWindowData *data = (HistoryWindowData *) GetWindowLongPtr(hWnd, DWLP_USER);
bool bAll = (data->itemsPerPage <= 0) || (data->itemsPerPage >= data->count);
- int bLastFirst = DBGetContactSettingByte(NULL, ModuleName, "ShowLastPageFirst", 0);
+ int bLastFirst = db_get_b(NULL, ModuleName, "ShowLastPageFirst", 0);
if (!bLastFirst)
{
EnableWindow(GetDlgItem(hWnd, IDC_PREV), FALSE);
@@ -442,7 +432,7 @@ BOOL CALLBACK HistoryDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
}
case WM_DESTROY:
{
- HistoryWindowData *data = (HistoryWindowData *) GetWindowLong(hWnd, DWL_USER);
+ HistoryWindowData *data = (HistoryWindowData *) GetWindowLongPtr(hWnd, DWLP_USER);
DestroyIEView(hWnd);
free(data);
WindowList_Remove(hOpenWindowsList, hWnd);
@@ -522,13 +512,13 @@ BOOL CALLBACK HistoryDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
sprintf(buffer, "Error #%d", GetLastError());
MessageBoxA(0, buffer, "Error", MB_OK);
}
- HistoryWindowData *data = (HistoryWindowData *) GetWindowLong(hWnd, DWL_USER);
+ HistoryWindowData *data = (HistoryWindowData *) GetWindowLongPtr(hWnd, DWLP_USER);
SearchWindowData *searchData = (SearchWindowData *) malloc(sizeof(SearchWindowData));
- searchData->hContact = data->hContact;
+ searchData->contact = data->contact;
searchData->hHistoryWindow = hWnd;
searchData->hLastFoundEvent = NULL;
searchData->index = 0;
- SetWindowLong(hSearch, DWL_USER, (LONG) searchData);
+ SetWindowLongPtr(hSearch, DWLP_USER, (LONG_PTR)searchData);
ShowWindow(hSearch, SW_SHOW);
//sprintf(buffer, "Error #%d", GetLastError());
//MessageBoxA(0, buffer, "Error", MB_OK);
@@ -547,24 +537,24 @@ BOOL CALLBACK HistoryDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
#include "prsht.h" //PSN_APPLY
-BOOL CALLBACK OptionsDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
+INT_PTR CALLBACK OptionsDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_INITDIALOG:
{
TranslateDialogDefault(hWnd);
- int count = DBGetContactSettingDword(NULL, ModuleName, "EventsToLoad", 0);
+ int count = db_get_dw(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));
+ CheckDlgButton(hWnd, IDC_ENABLE_RTL, (BOOL) db_get_b(NULL, ModuleName, "EnableRTL", 0));
+ CheckDlgButton(hWnd, IDC_SHOW_LAST_FIRST, (BOOL) db_get_b(NULL, ModuleName, "ShowLastPageFirst", 0));
+ CheckDlgButton(hWnd, IDC_LOAD_BACKGROUND, (BOOL) db_get_b(NULL, ModuleName, "UseWorkerThread", 0));
TCHAR buffer[1024];
- _itot(count, buffer, 10);
+ itot(count, buffer, 10);
SetWindowText(GetDlgItem(hWnd, IDC_EVENTS_COUNT), buffer);
break;
@@ -619,10 +609,10 @@ BOOL CALLBACK OptionsDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
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);
+ db_set_b(NULL, ModuleName, "ShowLastPageFirst", IsDlgButtonChecked(hWnd, IDC_SHOW_LAST_FIRST));
+ db_set_b(NULL, ModuleName, "EnableRTL", IsDlgButtonChecked(hWnd, IDC_ENABLE_RTL));
+ db_set_b(NULL, ModuleName, "UseWorkerThread", IsDlgButtonChecked(hWnd, IDC_LOAD_BACKGROUND));
+ db_set_dw(NULL, ModuleName, "EventsToLoad", count);
break;
}
@@ -643,7 +633,7 @@ BOOL CALLBACK OptionsDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
#include "commctrl.h" //tab control
-BOOL CALLBACK SearchDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
+INT_PTR CALLBACK SearchDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
@@ -675,7 +665,7 @@ BOOL CALLBACK SearchDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
}
case WM_DESTROY:
{
- SearchWindowData *data = (SearchWindowData *) GetWindowLong(hWnd, DWL_USER);
+ SearchWindowData *data = (SearchWindowData *) GetWindowLongPtr(hWnd, DWLP_USER);
free(data);
//DestroyWindow(hWnd);
break;
@@ -692,7 +682,7 @@ BOOL CALLBACK SearchDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
case IDC_SEARCH_DATE:
case IDC_SEARCH_TIME:
{
- SearchWindowData *data = (SearchWindowData *) GetWindowLong(hWnd, DWL_USER);
+ SearchWindowData *data = (SearchWindowData *) GetWindowLongPtr(hWnd, DWLP_USER);
data->hLastFoundEvent = NULL; //start from top if changes occur
break;
}
@@ -725,7 +715,7 @@ BOOL CALLBACK SearchDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
case EN_CHANGE:
{
- SearchWindowData *data = (SearchWindowData *) GetWindowLong(hWnd, DWL_USER);
+ SearchWindowData *data = (SearchWindowData *) GetWindowLongPtr(hWnd, DWLP_USER);
data->hLastFoundEvent = NULL; //start from top if changes occur
break;
}
@@ -739,8 +729,8 @@ BOOL CALLBACK SearchDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
}
case IDC_FIND_NEXT:
{
- SearchWindowData *data = (SearchWindowData *) GetWindowLong(hWnd, DWL_USER);
- const HistoryWindowData *histData = (HistoryWindowData *) GetWindowLong(data->hHistoryWindow, DWL_USER);
+ SearchWindowData *data = (SearchWindowData *) GetWindowLongPtr(hWnd, DWLP_USER);
+ const HistoryWindowData *histData = (HistoryWindowData *) GetWindowLongPtr(data->hHistoryWindow, DWLP_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;
@@ -756,8 +746,8 @@ BOOL CALLBACK SearchDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
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);
+ SendMessage(GetDlgItem(hWnd, IDC_SEARCH_TEXT), WM_GETTEXT, SIZEOF(text), (LPARAM) text);
+ searchResult = SearchHistory(data->contact, data->hLastFoundEvent, text, direction, type);
}
else{//time search
TimeSearchData tsData = {0};
@@ -774,7 +764,7 @@ BOOL CALLBACK SearchDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
date.wMilliseconds = time.wMilliseconds;
}
tsData.time = date;
- searchResult = SearchHistory(data->hContact, data->hLastFoundEvent, &tsData, direction, type);
+ searchResult = SearchHistory(data->contact, data->hLastFoundEvent, &tsData, direction, type);
}
if (searchResult.hEvent)
{
@@ -795,4 +785,4 @@ BOOL CALLBACK SearchDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
}
}
return 0;
-} \ No newline at end of file
+}
diff --git a/plugins/IEHistory/src/dlgHandlers.h b/plugins/IEHistory/src/dlgHandlers.h
index 343b208c6e..990c9da3c0 100644
--- a/plugins/IEHistory/src/dlgHandlers.h
+++ b/plugins/IEHistory/src/dlgHandlers.h
@@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define LOAD_IN_BACKGROUND 0x00000001
struct HistoryWindowData{
- HANDLE hContact;
+ MCONTACT contact;
long count;
long index;
short loadMethod;
@@ -38,13 +38,13 @@ struct HistoryWindowData{
struct SearchWindowData{
long index;
- HANDLE hContact;
+ MCONTACT contact;
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);
+INT_PTR CALLBACK HistoryDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
+INT_PTR CALLBACK OptionsDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
+INT_PTR CALLBACK SearchDlgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
-#endif //M_HISTORY_DLG_HANDLERS_H \ No newline at end of file
+#endif //M_HISTORY_DLG_HANDLERS_H
diff --git a/plugins/IEHistory/src/events.cpp b/plugins/IEHistory/src/events.cpp
index 90b36b1b63..558be95924 100644
--- a/plugins/IEHistory/src/events.cpp
+++ b/plugins/IEHistory/src/events.cpp
@@ -39,7 +39,6 @@ int UnhookEvents()
int OnModulesLoaded(WPARAM wParam, LPARAM lParam)
{
- Log("%s", "Entering function " __FUNCTION__);
CLISTMENUITEM menuItem = {0};
menuItem.cbSize = sizeof(CLISTMENUITEM);
menuItem.flags = 0;
@@ -48,41 +47,32 @@ int OnModulesLoaded(WPARAM wParam, LPARAM lParam)
menuItem.position = 1000090000;
- menuItem.pszName = Translate("View contact's history");
+ menuItem.pszName = Translate("View &history");
menuItem.pszService = MS_HISTORY_SHOWCONTACTHISTORY;
- Log("%s", "Adding first menu (view contact's history)");
- CallService(MS_CLIST_ADDCONTACTMENUITEM, 0, (WPARAM) &menuItem);
+ Menu_AddContactMenuItem(&menuItem);
- menuItem.ptszName = TranslateT("View system history");
- //CallService(MS_CLIST_ADDMAINMENUITEM, 0, (WPARAM) &menuItem);
+/// @todo (White-Tiger#1#08/19/14): fully implement
+ menuItem.pszName = Translate("&System History");
+ Menu_AddMainMenuItem(&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);
+ OPTIONSDIALOGPAGE odp = { 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.ptszTitle = _T("IEHistory");
+ odp.ptszTitle = LPGENT("History");
odp.pfnDlgProc = OptionsDlgProc;
- CallService(MS_OPT_ADDPAGE, wParam, (LPARAM)&odp);
-
- return 0;
- Log("%s", "Leaving function " __FUNCTION__);
-} \ No newline at end of file
+ odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_HISTORY);
+ odp.hInstance = hInstance;
+// odp.ptszGroup = LPGENT("Message Sessions");
+// odp.groupPosition = 910000000;
+ odp.flags=ODPF_BOLDGROUPS|ODPF_TCHAR;
+ Options_AddPage(wParam,&odp);
+ return 0;
+}
diff --git a/plugins/IEHistory/src/mirandaMem.cpp b/plugins/IEHistory/src/mirandaMem.cpp
deleted file mode 100644
index 8ef20cb2e1..0000000000
--- a/plugins/IEHistory/src/mirandaMem.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
-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
deleted file mode 100644
index 7428278000..0000000000
--- a/plugins/IEHistory/src/mirandaMem.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
-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/services.cpp b/plugins/IEHistory/src/services.cpp
index 5683eecda8..0cbd957e0a 100644
--- a/plugins/IEHistory/src/services.cpp
+++ b/plugins/IEHistory/src/services.cpp
@@ -34,29 +34,28 @@ int DestroyServices()
return 0;
}
-int ShowContactHistoryService(WPARAM wParam, LPARAM lParam)
+INT_PTR 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);
+ historyDlg = WindowList_Find(hOpenWindowsList, (MCONTACT)wParam);
+ if (historyDlg == NULL){
+ int count = db_get_dw(NULL, ModuleName, "EventsToLoad", 0);
+ int loadInBackground = db_get_b(NULL, ModuleName, "UseWorkerThread", 0);
+ HistoryWindowData *data;
+ data = (HistoryWindowData *) malloc(sizeof(HistoryWindowData));
+ data->contact = (MCONTACT) 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);
+ SetWindowLongPtr(historyDlg, DWLP_USER, (LONG_PTR)data);
+
+ WindowList_Add(hOpenWindowsList, historyDlg, (MCONTACT) wParam);
+ }
+ ShowWindow(historyDlg, SW_SHOWNORMAL);
return 0;
-} \ No newline at end of file
+}
diff --git a/plugins/IEHistory/src/services.h b/plugins/IEHistory/src/services.h
index 40e680a04e..11d448ade9 100644
--- a/plugins/IEHistory/src/services.h
+++ b/plugins/IEHistory/src/services.h
@@ -27,6 +27,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
int InitServices();
int DestroyServices();
-int ShowContactHistoryService(WPARAM wParam, LPARAM lParam);
+INT_PTR ShowContactHistoryService(WPARAM wParam, LPARAM lParam);
-#endif //M_IEHISTORY_PROVIDED_SERVICES_H \ No newline at end of file
+#endif //M_IEHISTORY_PROVIDED_SERVICES_H
diff --git a/plugins/IEHistory/src/stdafx.h b/plugins/IEHistory/src/stdafx.h
index fe90144550..30794ae02f 100644
--- a/plugins/IEHistory/src/stdafx.h
+++ b/plugins/IEHistory/src/stdafx.h
@@ -42,6 +42,3 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
// 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
index 91577e698f..424ce76b6b 100644
--- a/plugins/IEHistory/src/utils.cpp
+++ b/plugins/IEHistory/src/utils.cpp
@@ -20,18 +20,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "commonheaders.h"
+#ifdef _DEBUG
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;
@@ -56,10 +53,9 @@ int Log(char *format, ...)
}
fputs(str, fout);
fclose(fout);
-#endif
return 0;
-
}
+#endif
@@ -69,7 +65,7 @@ int Info(char *title, char *format, ...)
va_list vararg;
int tBytes;
va_start(vararg, format);
- tBytes = _snprintf(str, sizeof(str), format, vararg);
+ tBytes = snprintf(str, sizeof(str), format, vararg);
if (tBytes > 0)
{
str[tBytes] = 0;
@@ -82,42 +78,24 @@ int Info(char *title, char *format, ...)
returns the name of a contact
*/
-#pragma warning (disable: 4312)
-TCHAR *GetContactName(HANDLE hContact, char *szProto)
+TCHAR *GetContactName(MCONTACT contact)
{
- CONTACTINFO ctInfo;
- int ret;
-
- ZeroMemory((void *) &ctInfo, sizeof(ctInfo));
- ctInfo.cbSize = sizeof(ctInfo);
- ctInfo.szProto = szProto;
+ CONTACTINFO ctInfo={sizeof(ctInfo)};
+// if(db_mc_isMeta(contact))
+// contact=db_mc_getMostOnline(contact);
+ ctInfo.szProto = GetContactProto(contact);
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;
- }
+#endif
+ ctInfo.hContact = contact;
+ if(CallService(MS_CONTACT_GETCONTACTINFO,0,(LPARAM)&ctInfo)){
+ return NULL;
+ }
+ TCHAR* buffer = _tcsdup(ctInfo.pszVal);
+ mir_free(ctInfo.pszVal);
return buffer;
}
-#pragma warning (default: 4312)
/*
Moves a control with regard to certain anchors (like delphi, c#, ...)
@@ -201,7 +179,6 @@ RECT AnchorCalcPos(HWND window, const RECT *rParent, const WINDOWPOS *parentPos,
return rChild;
}
-#pragma warning (disable: 4244)
void UnixTimeToFileTime(time_t t, LPFILETIME pft)
{
// Note that LONGLONG is a 64-bit value
@@ -211,7 +188,6 @@ void UnixTimeToFileTime(time_t t, LPFILETIME pft)
pft->dwLowDateTime = (DWORD)ll;
pft->dwHighDateTime = ll >> 32;
}
-#pragma warning (default: 4244)
void UnixTimeToSystemTime(time_t t, LPSYSTEMTIME pst)
{
@@ -222,38 +198,34 @@ void UnixTimeToSystemTime(time_t t, LPSYSTEMTIME pst)
SystemTimeToTzSpecificLocalTime(NULL, &st, pst);
}
-HANDLE GetNeededEvent(HANDLE hLastFirstEvent, int index, int direction)
+HANDLE GetNeededEvent(HANDLE hEvent, int num, 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;
- }
+ typedef HANDLE (__stdcall *db_event_step_t)(MCONTACT hContact,HANDLE hDbEvent);
+ db_event_step_t db_event_step;
+ if(direction==DIRECTION_BACK){
+ db_event_step=db_event_prev;
+ }else{
+ db_event_step=db_event_next;
+ }
- for (i = 0; i < index; i++)
- {
- hEvent = (HANDLE) CallService(service, (WPARAM) hEvent, 0);
- }
+ for (i = 0; i < num; ++i){
+ hEvent = db_event_step(0,hEvent);
+ }
return hEvent;
}
-SearchResult SearchHistory(HANDLE hContact, HANDLE hFirstEvent, void *searchData, int direction, int type)
+SearchResult SearchHistory(MCONTACT contact, 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);
- }
+ if (hFirstEvent == NULL){
+ typedef HANDLE (__stdcall *db_event_start_t)(MCONTACT contact);
+ db_event_start_t db_event_start=(direction==DIRECTION_BACK) ? db_event_last : db_event_first;
+ hFirstEvent=db_event_start(contact);
+ }
int index = 0;
HANDLE hEvent = hFirstEvent;
void *buffer = NULL;
TCHAR *search;
- wchar_t TEMP[2048];
bool found = false;
int oldSize, newSize;
oldSize = newSize = 0;
@@ -261,70 +233,68 @@ SearchResult SearchHistory(HANDLE hContact, HANDLE hFirstEvent, void *searchDat
DBEVENTINFO dbEvent = {0};
dbEvent.cbSize = sizeof(dbEvent);
- while ((!found) && (hEvent))
- {
- newSize = CallService(MS_DB_EVENT_GETBLOBSIZE, (WPARAM) hEvent, 0);
- if (newSize > oldSize)
+ while ((!found) && (hEvent)){
+ newSize = db_event_getBlobSize(hEvent);
+ if (newSize > oldSize)
+ {
+ buffer = (TCHAR *) realloc(buffer, newSize);
+ oldSize = newSize;
+ }
+ dbEvent.pBlob = (PBYTE) buffer;
+ dbEvent.cbBlob = newSize;
+ if (db_event_get(hEvent,&dbEvent) == 0){ //successful
+ switch (type)
{
- 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:
{
- 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;
- }
+ wchar_t TEMP[2048];
+ size_t size = strlen((char *) dbEvent.pBlob) + 1;
+ if (size < dbEvent.cbBlob)
+ {
+ search = (wchar_t *) &dbEvent.pBlob[size];
+ }
+ else{
+ MultiByteToWideChar(CP_ACP, 0, (char *) buffer, (int)size, TEMP, 2048);
+ search = TEMP;
+ }
#else
- search = (char *) buffer;
-#endif
- TCHAR *data = (TCHAR *) searchData;
- TCHAR *tmp = _tcsstr(search, data);
- if (tmp)
- {
- found = true;
- }
- break;
+ 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));
}
- case SEARCH_TIME:
+ if (data->flags & TSDF_TIME_SET)
{
- 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;
+ found = found & ((time.wHour == data->time.wHour) && (time.wMinute == data->time.wMinute));
}
+ break;
}
}
- if (!found)
- {
- hEvent = GetNeededEvent(hEvent, 1, direction);
- index++;
- }
}
+ 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
index c423b4ede7..7cad1a1116 100644
--- a/plugins/IEHistory/src/utils.h
+++ b/plugins/IEHistory/src/utils.h
@@ -22,7 +22,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define M_IEHISTORY_UTILS_H
#include "stdafx.h"
-#include "time.h"
+#include <time.h>
+#include <m_core.h>
#define ANCHOR_LEFT 0x000001
#define ANCHOR_RIGHT 0x000002
@@ -60,27 +61,26 @@ struct SearchResult{
HANDLE hEvent;
};
-//#ifdef _DEBUG
+#ifdef _DEBUG
int LogInit();
int Log(char *format, ...);
-//#endif
+#else
+# define LogInit()
+# define Log(fmt,...)
+#endif
void ScreenToClient(HWND hWnd, LPRECT rect);
int Info(char *title, char *format, ...);
-TCHAR *GetContactName(HANDLE hContact, char *szProto);
+TCHAR *GetContactName(MCONTACT contact);
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);
+HANDLE GetNeededEvent(HANDLE hLastFirstEvent, int num, int direction);
+SearchResult SearchHistory(MCONTACT contact, HANDLE hFirstEvent, void *searchData, int direction, int type);
/*
static __inline int mir_snprintf(char *buffer, size_t count, const char* fmt, ...) {
@@ -94,4 +94,4 @@ static __inline int mir_snprintf(char *buffer, size_t count, const char* fmt, ..
return len;
}
*/
-#endif \ No newline at end of file
+#endif
diff --git a/plugins/IEHistory/src/version.h b/plugins/IEHistory/src/version.h
index 204fd10561..a9f8e10311 100644
--- a/plugins/IEHistory/src/version.h
+++ b/plugins/IEHistory/src/version.h
@@ -24,30 +24,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#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 __BUILD_NUM 5
+
+#include <stdver.h>
+
+#define __DESC "IEView History Viewer"
+#define __AUTHOR "Cristian Libotean, Miranda NG team"
+//#define __AUTHOREMAIL "eblis102@yahoo.com"
+#define __AUTHOREMAIL ""
+#define __COPYRIGHT "© 2006 Cristian Libotean, 2014 Miranda NG team"
+#define __AUTHORWEB "http://miranda-ng.org/p/IEHistory"
#define __PLUGIN_DISPLAY_NAME "IEView History Viewer"
-#endif
#endif //M_IEHISTORY_VERSION_H