summaryrefslogtreecommitdiff
path: root/plugins/NewStory
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/NewStory')
-rw-r--r--plugins/NewStory/src/calendartool.cpp45
-rw-r--r--plugins/NewStory/src/fonts.cpp10
-rw-r--r--plugins/NewStory/src/history.cpp194
-rw-r--r--plugins/NewStory/src/history_array.cpp48
-rw-r--r--plugins/NewStory/src/history_control.cpp676
-rw-r--r--plugins/NewStory/src/options.cpp100
-rw-r--r--plugins/NewStory/src/templates.cpp282
-rw-r--r--plugins/NewStory/src/utils.cpp46
-rw-r--r--plugins/NewStory/src/utils.h9
9 files changed, 653 insertions, 757 deletions
diff --git a/plugins/NewStory/src/calendartool.cpp b/plugins/NewStory/src/calendartool.cpp
index dd2578d33a..49960debf6 100644
--- a/plugins/NewStory/src/calendartool.cpp
+++ b/plugins/NewStory/src/calendartool.cpp
@@ -1,21 +1,12 @@
#include "stdafx.h"
-struct CalendarToolData
-{
- int x, y;
-};
-
INT_PTR CALLBACK CalendarToolDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- CalendarToolData* data = (CalendarToolData*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
switch (msg) {
case WM_INITDIALOG:
- data = (CalendarToolData*)lParam;
- SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)data);
-
// This causes ALL miranda dialogs to have drop-shadow enabled. That's bad =(
// SetClassLong(hwnd, GCL_STYLE, GetClassLong(hwnd, GCL_STYLE)|CS_DROPSHADOW);
- SetWindowPos(hwnd, HWND_TOP, data->x, data->y, 0, 0, SWP_NOSIZE);
+ SetWindowPos(hwnd, HWND_TOP, LOWORD(lParam), HIWORD(lParam), 0, 0, SWP_NOSIZE);
return TRUE;
case WM_ACTIVATE:
@@ -36,37 +27,29 @@ INT_PTR CALLBACK CalendarToolDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
break;
case WM_NOTIFY:
- {
- LPNMHDR hdr = (LPNMHDR)lParam;
- if ((hdr->idFrom = IDC_MONTHCALENDAR1) && (hdr->code == MCN_SELECT)) {
- LPNMSELCHANGE lpnmsc = (LPNMSELCHANGE)lParam;
- struct tm tm_sel;
- tm_sel.tm_hour = tm_sel.tm_min = tm_sel.tm_sec = 0;
- tm_sel.tm_isdst = 1;
- tm_sel.tm_mday = lpnmsc->stSelStart.wDay;
- tm_sel.tm_mon = lpnmsc->stSelStart.wMonth - 1;
- tm_sel.tm_year = lpnmsc->stSelStart.wYear - 1900;
- EndDialog(hwnd, mktime(&tm_sel));
+ {
+ LPNMHDR hdr = (LPNMHDR)lParam;
+ if ((hdr->idFrom == IDC_MONTHCALENDAR1) && (hdr->code == MCN_SELECT)) {
+ LPNMSELCHANGE lpnmsc = (LPNMSELCHANGE)lParam;
+ struct tm tm_sel;
+ tm_sel.tm_hour = tm_sel.tm_min = tm_sel.tm_sec = 0;
+ tm_sel.tm_isdst = 1;
+ tm_sel.tm_mday = lpnmsc->stSelStart.wDay;
+ tm_sel.tm_mon = lpnmsc->stSelStart.wMonth - 1;
+ tm_sel.tm_year = lpnmsc->stSelStart.wYear - 1900;
+ EndDialog(hwnd, mktime(&tm_sel));
+ }
}
return TRUE;
- }
case WM_CLOSE:
DestroyWindow(hwnd);
return TRUE;
-
- case WM_DESTROY:
- delete data;
- data = 0;
- SetWindowLongPtr(hwnd, GWLP_USERDATA, 0);
}
return FALSE;
}
time_t CalendarTool_Show(HWND hwnd, int x, int y)
{
- CalendarToolData* data = new CalendarToolData;
- data->x = x;
- data->y = y;
- return DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CALENDARTOOL), hwnd, CalendarToolDlgProc, (LPARAM)data);
+ return DialogBoxParam(g_plugin.getInst(), MAKEINTRESOURCE(IDD_CALENDARTOOL), hwnd, CalendarToolDlgProc, MAKELONG(x, y));
}
diff --git a/plugins/NewStory/src/fonts.cpp b/plugins/NewStory/src/fonts.cpp
index fcbb90748e..eb389738aa 100644
--- a/plugins/NewStory/src/fonts.cpp
+++ b/plugins/NewStory/src/fonts.cpp
@@ -33,10 +33,10 @@ MyFontID fonts[] =
int evtFontsChanged(WPARAM, LPARAM)
{
- for (auto& it : colors)
+ for (auto &it : colors)
it.cl = Colour_Get(MODULENAME, it.szName);
- for (auto& it : fonts) {
+ for (auto &it : fonts) {
it.cl = (COLORREF)Font_Get(MODULENAME, it.szName, &it.lf);
DeleteObject(it.hfnt);
@@ -58,7 +58,7 @@ void InitFonts()
strncpy_s(cid.group, MODULENAME, _TRUNCATE);
strncpy_s(cid.dbSettingsGroup, MODULENAME, _TRUNCATE);
- for (auto& it : colors) {
+ for (auto &it : colors) {
cid.order = int(&it - colors);
strncpy_s(cid.name, it.szName, _TRUNCATE);
strncpy_s(cid.setting, it.szSetting, _TRUNCATE);
@@ -71,7 +71,7 @@ void InitFonts()
strncpy_s(fontid.group, MODULENAME, _TRUNCATE);
strncpy_s(fontid.dbSettingsGroup, MODULENAME, _TRUNCATE);
- for (auto& it : fonts) {
+ for (auto &it : fonts) {
fontid.order = int(&it - fonts);
strncpy_s(fontid.name, it.szName, _TRUNCATE);
strncpy_s(fontid.setting, it.szSetting, _TRUNCATE);
@@ -84,6 +84,6 @@ void InitFonts()
void DestroyFonts()
{
- for (auto& it : fonts)
+ for (auto &it : fonts)
DeleteObject(it.hfnt);
}
diff --git a/plugins/NewStory/src/history.cpp b/plugins/NewStory/src/history.cpp
index 7fe96e8ed1..f1837c2203 100644
--- a/plugins/NewStory/src/history.cpp
+++ b/plugins/NewStory/src/history.cpp
@@ -4,13 +4,6 @@
// Visit http://miranda-im.org/ for details on Miranda Instant Messenger
////////////////////////////////////////////////////////////////////////
-/*
-for the date picker:
- case WM_ACTIVATE:
- if (wParam == WA_INACTIVE) PostMessage(m_hwndDialog, WM_CLOSE, 0, 0);
- break;
-*/
-
#include "stdafx.h"
MWindowList hNewstoryWindows = 0;
@@ -122,7 +115,7 @@ struct WindowData
InfoBarEvents ibMessages, ibFiles, ibUrls, ibTotal;
};
-void LayoutFilterBar(HDWP hDwp, int x, int y, int w, InfoBarEvents* ib)
+void LayoutFilterBar(HDWP hDwp, int x, int y, int w, InfoBarEvents *ib)
{
hDwp = DeferWindowPos(hDwp, ib->hwndIco, 0,
x, y, 16, 16, SWP_NOZORDER);
@@ -141,7 +134,7 @@ void LayoutFilterBar(HDWP hDwp, int x, int y, int w, InfoBarEvents* ib)
}
-void ShowHideControls(HWND hwnd, WindowData* data)
+void ShowHideControls(HWND hwnd, WindowData *data)
{
int cmd;
@@ -183,7 +176,7 @@ void ShowHideControls(HWND hwnd, WindowData* data)
ShowWindow(data->hwndSearchText, cmd);
}
-void LayoutHistoryWnd(HWND hwnd, WindowData* data)
+void LayoutHistoryWnd(HWND hwnd, WindowData *data)
{
int i;
RECT rc;
@@ -219,18 +212,18 @@ void LayoutHistoryWnd(HWND hwnd, WindowData* data)
}
// infobar
-// hDwp = DeferWindowPos(hDwp, data->hwndIcoProtocol, 0,
-// w-100+WND_SPACING, WND_SPACING,
-// 16, 16,
-// SWP_NOZORDER);
-// hDwp = DeferWindowPos(hDwp, data->hwndTxtNickname, 0,
-// w-100+WND_SPACING*2+16, WND_SPACING,
-// 100, 16,
-// SWP_NOZORDER);
-// hDwp = DeferWindowPos(hDwp, data->hwndTxtUID, 0,
-// w-100+WND_SPACING*2+16, WND_SPACING*2+16,
-// 100, 16,
-// SWP_NOZORDER);
+ // hDwp = DeferWindowPos(hDwp, data->hwndIcoProtocol, 0,
+ // w-100+WND_SPACING, WND_SPACING,
+ // 16, 16,
+ // SWP_NOZORDER);
+ // hDwp = DeferWindowPos(hDwp, data->hwndTxtNickname, 0,
+ // w-100+WND_SPACING*2+16, WND_SPACING,
+ // 100, 16,
+ // SWP_NOZORDER);
+ // hDwp = DeferWindowPos(hDwp, data->hwndTxtUID, 0,
+ // w-100+WND_SPACING*2+16, WND_SPACING*2+16,
+ // 100, 16,
+ // SWP_NOZORDER);
// filter bar
int hFilterBar = 0;
@@ -413,7 +406,7 @@ INT_PTR CALLBACK HistoryDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
//CallSnappingWindowProc(hwnd, msg, wParam, lParam);
- WindowData* data = (WindowData*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
+ WindowData *data = (WindowData *)GetWindowLongPtr(hwnd, GWLP_USERDATA);
if ((msg >= NSM_FIRST) && (msg < NSM_LAST)) {
int result = SendMessage(GetDlgItem(hwnd, IDC_ITEMS2), msg, wParam, lParam);
@@ -423,7 +416,6 @@ INT_PTR CALLBACK HistoryDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
switch (msg) {
case WM_INITDIALOG:
- {
data = new WindowData;
data->hContact = (MCONTACT)lParam;
data->disableTimeTreeChange = false;
@@ -570,7 +562,7 @@ INT_PTR CALLBACK HistoryDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
WindowList_Add(hNewstoryWindows, hwnd, data->hContact);
if (data->hContact && (data->hContact != INVALID_CONTACT_ID)) {
- wchar_t* title = TplFormatString(TPL_TITLE, data->hContact, 0);
+ wchar_t *title = TplFormatString(TPL_TITLE, data->hContact, 0);
SetWindowText(hwnd, title);
mir_free(title);
}
@@ -586,19 +578,17 @@ INT_PTR CALLBACK HistoryDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
SendMessage(hwnd, UM_UPDATEICONS, 0, 0);
SetFocus(GetDlgItem(hwnd, IDC_ITEMS2));
+ {
+ int left = db_get_dw(data->hContact, MODULENAME, "left"),
+ top = db_get_dw(data->hContact, MODULENAME, "top"),
+ right = db_get_dw(data->hContact, MODULENAME, "right"),
+ bottom = db_get_dw(data->hContact, MODULENAME, "bottom");
- int left = db_get_dw(data->hContact, MODULENAME, "left"),
- top = db_get_dw(data->hContact, MODULENAME, "top"),
- right = db_get_dw(data->hContact, MODULENAME, "right"),
- bottom = db_get_dw(data->hContact, MODULENAME, "bottom");
-
- if (left - right && top - bottom)
- MoveWindow(hwnd, left, top, right - left, bottom - top, TRUE);
-
+ if (left - right && top - bottom)
+ MoveWindow(hwnd, left, top, right - left, bottom - top, TRUE);
+ }
ShowHideControls(hwnd, data);
-
return TRUE;
- }
case UM_UPDATEICONS:
SendMessage(hwnd, WM_SETICON, (WPARAM)ICON_SMALL, (LPARAM)g_plugin.getIcon(ICO_NEWSTORY));
@@ -701,48 +691,44 @@ INT_PTR CALLBACK HistoryDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
return TRUE;
case WM_DRAWITEM:
- {
- LPDRAWITEMSTRUCT lpdis;
- lpdis = (LPDRAWITEMSTRUCT)lParam;
+ {
+ LPDRAWITEMSTRUCT lpdis;
+ lpdis = (LPDRAWITEMSTRUCT)lParam;
- if (lpdis->CtlType == ODT_MENU)
- return Menu_DrawItem(lParam);
+ if (lpdis->CtlType == ODT_MENU)
+ return Menu_DrawItem(lParam);
- if (lpdis->itemID == -1)
- return FALSE;
+ if (lpdis->itemID == -1)
+ return FALSE;
- return TRUE;
- }
+ return TRUE;
+ }
case WM_NOTIFY:
- {
- LPNMHDR hdr = (LPNMHDR)lParam;
- switch (hdr->idFrom) {
- case IDC_TIMETREE:
{
- switch (hdr->code) {
- case TVN_SELCHANGED:
- {
- if (data->disableTimeTreeChange) {
- data->disableTimeTreeChange = false;
- }
- else {
- // LPNMTREEVIEW pnmtv = (LPNMTREEVIEW)lParam;
- // int id = pnmtv->itemNew.lParam;
- // SendMessage(GetDlgItem(hwnd, IDC_ITEMS), LB_SETCARETINDEX, id, 0);
- // SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(IDC_ITEMS, LBN_SELCHANGE), (LPARAM)GetDlgItem(hwnd, IDC_ITEMS));
- // SendMessage(GetDlgItem(hwnd, IDC_ITEMS), LB_SETTOPINDEX, id, 0);
- // SendMessage(GetDlgItem(hwnd, IDC_ITEMS), LB_SELITEMRANGE, FALSE, MAKELPARAM(0,data->eventCount));
- // SendMessage(GetDlgItem(hwnd, IDC_ITEMS), LB_SELITEMRANGE, TRUE, MAKELPARAM(id,id));
+ LPNMHDR hdr = (LPNMHDR)lParam;
+ switch (hdr->idFrom) {
+ case IDC_TIMETREE:
+ switch (hdr->code) {
+ case TVN_SELCHANGED:
+ if (data->disableTimeTreeChange) {
+ data->disableTimeTreeChange = false;
+ }
+ else {
+ // LPNMTREEVIEW pnmtv = (LPNMTREEVIEW)lParam;
+ // int id = pnmtv->itemNew.lParam;
+ // SendMessage(GetDlgItem(hwnd, IDC_ITEMS), LB_SETCARETINDEX, id, 0);
+ // SendMessage(hwnd, WM_COMMAND, MAKEWPARAM(IDC_ITEMS, LBN_SELCHANGE), (LPARAM)GetDlgItem(hwnd, IDC_ITEMS));
+ // SendMessage(GetDlgItem(hwnd, IDC_ITEMS), LB_SETTOPINDEX, id, 0);
+ // SendMessage(GetDlgItem(hwnd, IDC_ITEMS), LB_SELITEMRANGE, FALSE, MAKELPARAM(0,data->eventCount));
+ // SendMessage(GetDlgItem(hwnd, IDC_ITEMS), LB_SELITEMRANGE, TRUE, MAKELPARAM(id,id));
+ }
+ break;
}
break;
}
- }
- break;
}
- }
- }
- return TRUE;
+ return TRUE;
case WM_COMMAND:
// if (Menu_ProcessCommand(MAKEWPARAM(LOWORD(wParam), MPCF_CONTACTMENU), (LPARAM) data->hContact))
@@ -763,35 +749,32 @@ INT_PTR CALLBACK HistoryDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
break;
case IDC_DATEPOPUP:
- {
- GetWindowRect(GetDlgItem(hwnd, LOWORD(wParam)), &rc);
- time_t tm_jump = CalendarTool_Show(hwnd, rc.left, rc.bottom);
- if (tm_jump) PostMessage(hwnd, UM_JUMP2TIME, tm_jump, 0);
+ {
+ GetWindowRect(GetDlgItem(hwnd, LOWORD(wParam)), &rc);
+ time_t tm_jump = CalendarTool_Show(hwnd, rc.left, rc.bottom);
+ if (tm_jump) PostMessage(hwnd, UM_JUMP2TIME, tm_jump, 0);
+ }
break;
- }
case IDC_USERMENU:
- {
- HMENU hMenu = Menu_BuildContactMenu(data->hContact);
- GetWindowRect(GetDlgItem(hwnd, LOWORD(wParam)), &rc);
- TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwnd, NULL);
- DestroyMenu(hMenu);
- break;
- }
+ {
+ HMENU hMenu = Menu_BuildContactMenu(data->hContact);
+ GetWindowRect(GetDlgItem(hwnd, LOWORD(wParam)), &rc);
+ TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwnd, NULL);
+ DestroyMenu(hMenu);
+ break;
+ }
case IDC_LOGOPTIONS:
- {
GetWindowRect(GetDlgItem(hwnd, LOWORD(wParam)), &rc);
- // DWORD itemID = 0;
+
switch (TrackPopupMenu(GetSubMenu(data->hMenu, 2), TPM_RETURNCMD, rc.left, rc.bottom, 0, hwnd, NULL)) {
- // case ID_LOGOPTIONS_SHOWTIMETREE:
- // {
- // data->showFlags = toggleBit(data->showFlags, HIST_TIMETREE);
- // CheckMenuItem(GetSubMenu(data->hMenu, 1), ID_LOGOPTIONS_SHOWTIMETREE,
- // data->showFlags&HIST_TIMETREE ? MF_CHECKED : MF_UNCHECKED);
- // ShowWindow(GetDlgItem(hwnd, IDC_TIMETREE), data->showFlags&HIST_TIMETREE ? SW_SHOW : SW_HIDE);
- // break;
- // }
+ // case ID_LOGOPTIONS_SHOWTIMETREE:
+ // data->showFlags = toggleBit(data->showFlags, HIST_TIMETREE);
+ // CheckMenuItem(GetSubMenu(data->hMenu, 1), ID_LOGOPTIONS_SHOWTIMETREE,
+ // data->showFlags&HIST_TIMETREE ? MF_CHECKED : MF_UNCHECKED);
+ // ShowWindow(GetDlgItem(hwnd, IDC_TIMETREE), data->showFlags&HIST_TIMETREE ? SW_SHOW : SW_HIDE);
+ // break;
case ID_LOGOPTIONS_OPTIONS:
g_plugin.openOptions(nullptr, L"Newstory", L"General");
@@ -803,7 +786,6 @@ INT_PTR CALLBACK HistoryDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
}
PostMessage(hwnd, WM_SIZE, 0, 0);
break;
- }
case IDC_SEARCH:
if (data->wndOptions & WND_OPT_SEARCHBAR)
@@ -921,25 +903,25 @@ INT_PTR CALLBACK HistoryDlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara
// break;
case IDC_FINDPREV:
- {
- int bufSize = GetWindowTextLength(GetDlgItem(hwnd, IDC_SEARCHTEXT)) + 1;
- wchar_t* buf = new wchar_t[bufSize];
- GetWindowText(GetDlgItem(hwnd, IDC_SEARCHTEXT), buf, GetWindowTextLength(GetDlgItem(hwnd, IDC_SEARCHTEXT)) + 1);
- SendMessage(GetDlgItem(hwnd, IDC_ITEMS2), NSM_FINDPREV, (WPARAM)buf, 0);
- delete[] buf;
- }
- break;
+ {
+ int bufSize = GetWindowTextLength(GetDlgItem(hwnd, IDC_SEARCHTEXT));
+ wchar_t *buf = new wchar_t[bufSize+1];
+ GetWindowText(GetDlgItem(hwnd, IDC_SEARCHTEXT), buf, bufSize);
+ SendMessage(GetDlgItem(hwnd, IDC_ITEMS2), NSM_FINDPREV, (WPARAM)buf, 0);
+ delete[] buf;
+ }
+ break;
case IDOK:
case IDC_FINDNEXT:
- {
- int bufSize = GetWindowTextLength(GetDlgItem(hwnd, IDC_SEARCHTEXT)) + 1;
- wchar_t* buf = new wchar_t[bufSize];
- GetWindowText(GetDlgItem(hwnd, IDC_SEARCHTEXT), buf, GetWindowTextLength(GetDlgItem(hwnd, IDC_SEARCHTEXT)) + 1);
- SendMessage(GetDlgItem(hwnd, IDC_ITEMS2), NSM_FINDNEXT, (WPARAM)buf, 0);
- delete[] buf;
- }
- break;
+ {
+ int bufSize = GetWindowTextLength(GetDlgItem(hwnd, IDC_SEARCHTEXT));
+ wchar_t *buf = new wchar_t[bufSize+1];
+ GetWindowText(GetDlgItem(hwnd, IDC_SEARCHTEXT), buf, bufSize);
+ SendMessage(GetDlgItem(hwnd, IDC_ITEMS2), NSM_FINDNEXT, (WPARAM)buf, 0);
+ delete[] buf;
+ }
+ break;
case IDC_COPY:
SendMessage(GetDlgItem(hwnd, IDC_ITEMS2), NSM_COPY, 0, 0);
diff --git a/plugins/NewStory/src/history_array.cpp b/plugins/NewStory/src/history_array.cpp
index 86946e6a16..f4138a68a7 100644
--- a/plugins/NewStory/src/history_array.cpp
+++ b/plugins/NewStory/src/history_array.cpp
@@ -27,45 +27,39 @@ bool HistoryArray::ItemData::load(EventLoadMode mode)
switch (dbe.eventType) {
case EVENTTYPE_STATUSCHANGE:
case EVENTTYPE_MESSAGE:
- {
- atext = (char*)dbe.pBlob;
+ atext = (char *)dbe.pBlob;
atext_del = false;
- aLength = mir_strlen(atext);
+ aLength = (int)mir_strlen(atext);
if (dbe.cbBlob > (DWORD)aLength + 1) {
- wtext = (wchar_t*)(dbe.pBlob + aLength + 1);
+ wtext = (wchar_t *)(dbe.pBlob + aLength + 1);
wtext_del = false;
}
break;
- }
case EVENTTYPE_AUTHREQUEST:
- {
atext = new char[512];
atext_del = true;
if ((dbe.cbBlob > 8) && *(dbe.pBlob + 8)) {
mir_snprintf(atext, 512, ("%s requested authorization"), dbe.pBlob + 8);
}
else {
- mir_snprintf(atext, 512, ("%d requested authorization"), *(DWORD*)(dbe.pBlob));
+ mir_snprintf(atext, 512, ("%d requested authorization"), *(DWORD *)(dbe.pBlob));
}
- aLength = mir_strlen(atext);
+ aLength = (int)mir_strlen(atext);
break;
- }
case EVENTTYPE_ADDED:
- {
atext = new char[512];
atext_del = true;
if ((dbe.cbBlob > 8) && *(dbe.pBlob + 8)) {
mir_snprintf(atext, 512, ("%s added you to the contact list"), dbe.pBlob + 8);
}
else {
- mir_snprintf(atext, 512, ("%d added you to the contact list"), *(DWORD*)(dbe.pBlob));
+ mir_snprintf(atext, 512, ("%d added you to the contact list"), *(DWORD *)(dbe.pBlob));
}
- aLength = mir_strlen(atext);
+ aLength = (int)mir_strlen(atext);
break;
}
- }
if (atext && !wtext) {
#ifdef UNICODE
@@ -78,17 +72,15 @@ bool HistoryArray::ItemData::load(EventLoadMode mode)
wtext_del = false;
#endif
}
- else
- if (!atext && wtext) {
- // strange situation, really :) I'll fix this later
- }
- else
- if (!atext && !wtext) {
- atext = "";
- atext_del = false;
- wtext = L"";
- wtext_del = false;
- }
+ else if (!atext && wtext) {
+ // strange situation, really :) I'll fix this later
+ }
+ else if (!atext && !wtext) {
+ atext = "";
+ atext_del = false;
+ wtext = L"";
+ wtext_del = false;
+ }
return true;
}
@@ -119,7 +111,7 @@ HistoryArray::~HistoryArray()
bool HistoryArray::allocateBlock(int count)
{
- ItemBlock* newBlock = new ItemBlock;
+ ItemBlock *newBlock = new ItemBlock;
newBlock->items = new ItemData[count];
newBlock->count = count;
newBlock->prev = tail;
@@ -139,7 +131,7 @@ bool HistoryArray::allocateBlock(int count)
void HistoryArray::clear()
{
while (head) {
- ItemBlock* next = head->next;
+ ItemBlock *next = head->next;
// for (int i = 0; i < head->count; ++i)
// destroyEvent(head->items[i]);
delete[] head->items;
@@ -195,10 +187,10 @@ bool HistoryArray::preloadEvents(int count)
return true;
}
*/
-HistoryArray::ItemData* HistoryArray::get(int id, EventLoadMode mode)
+HistoryArray::ItemData *HistoryArray::get(int id, EventLoadMode mode)
{
int offset = 0;
- for (ItemBlock* p = head; p; p = p->next) {
+ for (ItemBlock *p = head; p; p = p->next) {
if (id < offset + p->count) {
if (mode != ELM_NOTHING)
p->items[id - offset].load(mode);
diff --git a/plugins/NewStory/src/history_control.cpp b/plugins/NewStory/src/history_control.cpp
index 8cdb1f88a0..fcc76c98c8 100644
--- a/plugins/NewStory/src/history_control.cpp
+++ b/plugins/NewStory/src/history_control.cpp
@@ -11,7 +11,7 @@ void InitNewstoryControl()
WNDCLASS wndclass = {};
wndclass.style = /*CS_HREDRAW | CS_VREDRAW | */CS_DBLCLKS | CS_GLOBALCLASS;
wndclass.lpfnWndProc = NewstoryListWndProc;
- wndclass.cbWndExtra = sizeof(void*);
+ wndclass.cbWndExtra = sizeof(void *);
wndclass.hInstance = g_plugin.getInst();
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndclass.lpszClassName = _T(NEWSTORYLIST_CLASS);
@@ -47,14 +47,14 @@ struct NewstoryListData : public MZeroedObject
// return CreateFontIndirect(&lf);
//}
-static void ScrollListBy(HWND hwnd, NewstoryListData* data, int scrollItems, int scrollPixels);
-static void EnsureVisible(HWND hwnd, NewstoryListData* data, int item);
-static void FixScrollPosition(HWND hwnd, NewstoryListData* data);
-static void RecalcScrollBar(HWND hwnd, NewstoryListData* data);
-static void BeginEditItem(HWND hwnd, NewstoryListData* data, int index);
-static void EndEditItem(HWND hwnd, NewstoryListData* data);
-static int LayoutItem(HWND hwnd, HistoryArray* items, int index);
-static int PaintItem(HDC hdc, HistoryArray* items, int index, int top, int width);
+static void ScrollListBy(HWND hwnd, NewstoryListData *data, int scrollItems, int scrollPixels);
+static void EnsureVisible(HWND hwnd, NewstoryListData *data, int item);
+static void FixScrollPosition(HWND hwnd, NewstoryListData *data);
+static void RecalcScrollBar(HWND hwnd, NewstoryListData *data);
+static void BeginEditItem(HWND hwnd, NewstoryListData *data, int index);
+static void EndEditItem(HWND hwnd, NewstoryListData *data);
+static int LayoutItem(HWND hwnd, HistoryArray *items, int index);
+static int PaintItem(HDC hdc, HistoryArray *items, int index, int top, int width);
// Edit box
@@ -63,32 +63,32 @@ static LRESULT CALLBACK HistoryEditWndProc(HWND hwnd, UINT msg, WPARAM wParam, L
{
switch (msg) {
case WM_KEYDOWN:
- {
- switch (wParam) {
- case VK_ESCAPE:
{
- EndEditItem(GetParent(hwnd), (NewstoryListData*)GetWindowLongPtr(GetParent(hwnd), 0));
- return 0;
- }
+ switch (wParam) {
+ case VK_ESCAPE:
+ {
+ EndEditItem(GetParent(hwnd), (NewstoryListData *)GetWindowLongPtr(GetParent(hwnd), 0));
+ return 0;
+ }
+ }
+ break;
}
- break;
- }
case WM_GETDLGCODE:
- {
- if (lParam) {
- MSG* msg2 = (MSG*)lParam;
- if (msg2->message == WM_KEYDOWN && msg2->wParam == VK_TAB)
- return 0;
- if (msg2->message == WM_CHAR && msg2->wParam == '\t')
- return 0;
+ {
+ if (lParam) {
+ MSG *msg2 = (MSG *)lParam;
+ if (msg2->message == WM_KEYDOWN && msg2->wParam == VK_TAB)
+ return 0;
+ if (msg2->message == WM_CHAR && msg2->wParam == '\t')
+ return 0;
+ }
+ return DLGC_WANTMESSAGE;
}
- return DLGC_WANTMESSAGE;
- }
- // case WM_KILLFOCUS:
- // {
- // EndEditItem(GetParent(hwnd), (NewstoryListData *)GetWindowLong(GetParent(hwnd), 0));
- // return 0;
- // }
+ // case WM_KILLFOCUS:
+ // {
+ // EndEditItem(GetParent(hwnd), (NewstoryListData *)GetWindowLong(GetParent(hwnd), 0));
+ // return 0;
+ // }
}
return CallWindowProc(OldEditWndProc, hwnd, msg, wParam, lParam);
}
@@ -97,7 +97,7 @@ static LRESULT CALLBACK HistoryEditWndProc(HWND hwnd, UINT msg, WPARAM wParam, L
// WndProc
LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
- NewstoryListData* data = (NewstoryListData*)GetWindowLongPtr(hwnd, 0);
+ NewstoryListData *data = (NewstoryListData *)GetWindowLongPtr(hwnd, 0);
switch (msg) {
case WM_CREATE:
@@ -119,156 +119,153 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
return data->items.getCount();
case NSM_SELECTITEMS:
- {
- int start = min(data->items.getCount() - 1, max(0, wParam));
- int end = min(data->items.getCount() - 1, max(0, lParam));
- if (start > end) {
- start ^= end;
- end ^= start;
- start ^= end;
+ {
+ int start = min(data->items.getCount() - 1, max(0, wParam));
+ int end = min(data->items.getCount() - 1, max(0, lParam));
+ if (start > end) {
+ start ^= end;
+ end ^= start;
+ start ^= end;
+ }
+ for (int i = start; i <= end; ++i)
+ data->items.get(i, ELM_NOTHING)->flags |= HIF_SELECTED;
+ InvalidateRect(hwnd, 0, FALSE);
+ return 0;
}
- for (int i = start; i <= end; ++i)
- data->items.get(i, ELM_NOTHING)->flags |= HIF_SELECTED;
- InvalidateRect(hwnd, 0, FALSE);
- return 0;
- }
case NSM_TOGGLEITEMS:
- {
- int start = min(data->items.getCount() - 1, max(0, wParam));
- int end = min(data->items.getCount() - 1, max(0, lParam));
- if (start > end) {
- start ^= end;
- end ^= start;
- start ^= end;
- }
- for (int i = start; i <= end; ++i) {
- if (data->items.get(i, ELM_NOTHING)->flags & HIF_SELECTED) {
- data->items.get(i, ELM_NOTHING)->flags &= ~HIF_SELECTED;
+ {
+ int start = min(data->items.getCount() - 1, max(0, wParam));
+ int end = min(data->items.getCount() - 1, max(0, lParam));
+ if (start > end) {
+ start ^= end;
+ end ^= start;
+ start ^= end;
}
- else {
- data->items.get(i, ELM_NOTHING)->flags |= HIF_SELECTED;
+ for (int i = start; i <= end; ++i) {
+ if (data->items.get(i, ELM_NOTHING)->flags & HIF_SELECTED) {
+ data->items.get(i, ELM_NOTHING)->flags &= ~HIF_SELECTED;
+ }
+ else {
+ data->items.get(i, ELM_NOTHING)->flags |= HIF_SELECTED;
+ }
}
+ InvalidateRect(hwnd, 0, FALSE);
+ return 0;
}
- InvalidateRect(hwnd, 0, FALSE);
- return 0;
- }
case NSM_SELECTITEMS2:
- {
- int start = min(data->items.getCount() - 1, max(0, wParam));
- int end = min(data->items.getCount() - 1, max(0, lParam));
- if (start > end) {
- start ^= end;
- end ^= start;
- start ^= end;
- }
- int count = data->items.getCount();
- for (int i = 0; i < count; ++i) {
- if ((i >= start) && (i <= end)) {
- data->items.get(i, ELM_NOTHING)->flags |= HIF_SELECTED;
+ {
+ int start = min(data->items.getCount() - 1, max(0, wParam));
+ int end = min(data->items.getCount() - 1, max(0, lParam));
+ if (start > end) {
+ start ^= end;
+ end ^= start;
+ start ^= end;
}
- else {
- data->items.get(i, ELM_NOTHING)->flags &= ~((DWORD)HIF_SELECTED);
+ int count = data->items.getCount();
+ for (int i = 0; i < count; ++i) {
+ if ((i >= start) && (i <= end)) {
+ data->items.get(i, ELM_NOTHING)->flags |= HIF_SELECTED;
+ }
+ else {
+ data->items.get(i, ELM_NOTHING)->flags &= ~((DWORD)HIF_SELECTED);
+ }
}
+ InvalidateRect(hwnd, 0, FALSE);
+ return 0;
}
- InvalidateRect(hwnd, 0, FALSE);
- return 0;
- }
case NSM_DESELECTITEMS:
- {
- int start = min(data->items.getCount() - 1, max(0, wParam));
- int end = min(data->items.getCount() - 1, max(0, lParam));
- if (start > end) {
- start ^= end;
- end ^= start;
- start ^= end;
+ {
+ int start = min(data->items.getCount() - 1, max(0, wParam));
+ int end = min(data->items.getCount() - 1, max(0, lParam));
+ if (start > end) {
+ start ^= end;
+ end ^= start;
+ start ^= end;
+ }
+ for (int i = start; i <= end; ++i)
+ data->items.get(i, ELM_NOTHING)->flags &= ~((DWORD)HIF_SELECTED);
+ InvalidateRect(hwnd, 0, FALSE);
+ return 0;
}
- for (int i = start; i <= end; ++i)
- data->items.get(i, ELM_NOTHING)->flags &= ~((DWORD)HIF_SELECTED);
- InvalidateRect(hwnd, 0, FALSE);
- return 0;
- }
case NSM_ENSUREVISIBLE:
EnsureVisible(hwnd, data, wParam);
return 0;
case NSM_GETITEMFROMPIXEL:
- {
- RECT rc;
- GetClientRect(hwnd, &rc);
- int height = rc.bottom - rc.top;
- DWORD count = data->items.getCount();
- DWORD current = data->scrollTopItem;
- int top = data->scrollTopPixel;
- int bottom = top + LayoutItem(hwnd, &data->items, current);
- while (top <= height) {
- if ((lParam >= top) && (lParam <= bottom))
- return current;
- if (++current >= count)
- return -1;
- top = bottom;
- bottom = top + LayoutItem(hwnd, &data->items, current);
+ {
+ RECT rc;
+ GetClientRect(hwnd, &rc);
+ int height = rc.bottom - rc.top;
+ DWORD count = data->items.getCount();
+ DWORD current = data->scrollTopItem;
+ int top = data->scrollTopPixel;
+ int bottom = top + LayoutItem(hwnd, &data->items, current);
+ while (top <= height) {
+ if ((lParam >= top) && (lParam <= bottom))
+ return current;
+ if (++current >= count)
+ return -1;
+ top = bottom;
+ bottom = top + LayoutItem(hwnd, &data->items, current);
+ }
+ return -1;
}
- return -1;
- }
case NSM_SETCARET:
- {
- if ((wParam >= 0) && (wParam < data->items.getCount())) {
- data->caret = wParam;
- if (lParam) {
- SendMessage(hwnd, NSM_ENSUREVISIBLE, data->caret, 0);
+ {
+ if ((wParam >= 0) && (wParam < data->items.getCount())) {
+ data->caret = wParam;
+ if (lParam) {
+ SendMessage(hwnd, NSM_ENSUREVISIBLE, data->caret, 0);
+ }
}
}
- }
case NSM_GETCARET:
- {
- return data->caret;
- }
+ {
+ return data->caret;
+ }
case NSM_FINDNEXT:
- {
- int id = data->items.FindNext(SendMessage(hwnd, NSM_GETCARET, 0, 0), HistoryArray::Filter(HistoryArray::Filter::EVENTONLY, (wchar_t*)wParam));
- if (id >= 0) {
- SendMessage(hwnd, NSM_SELECTITEMS2, id, id);
- SendMessage(hwnd, NSM_SETCARET, id, TRUE);
+ {
+ int id = data->items.FindNext(SendMessage(hwnd, NSM_GETCARET, 0, 0), HistoryArray::Filter(HistoryArray::Filter::EVENTONLY, (wchar_t *)wParam));
+ if (id >= 0) {
+ SendMessage(hwnd, NSM_SELECTITEMS2, id, id);
+ SendMessage(hwnd, NSM_SETCARET, id, TRUE);
+ }
+ return id;
}
- return id;
- }
case NSM_FINDPREV:
- {
- int id = data->items.FindPrev(SendMessage(hwnd, NSM_GETCARET, 0, 0), HistoryArray::Filter(HistoryArray::Filter::EVENTONLY, (wchar_t*)wParam));
- if (id >= 0) {
- SendMessage(hwnd, NSM_SELECTITEMS2, id, id);
- SendMessage(hwnd, NSM_SETCARET, id, TRUE);
+ {
+ int id = data->items.FindPrev(SendMessage(hwnd, NSM_GETCARET, 0, 0), HistoryArray::Filter(HistoryArray::Filter::EVENTONLY, (wchar_t *)wParam));
+ if (id >= 0) {
+ SendMessage(hwnd, NSM_SELECTITEMS2, id, id);
+ SendMessage(hwnd, NSM_SETCARET, id, TRUE);
+ }
+ return id;
}
- return id;
- }
case NSM_COPY:
- {
- wchar_t* res = 0;
- wchar_t* buf;
-
- int eventCount = data->items.getCount();
- for (int i = 0; i < eventCount; i++) {
- HistoryArray::ItemData* item = data->items.get(i, ELM_NOTHING);
- if (item->flags & HIF_SELECTED) {
- buf = TplFormatString(TPL_COPY_MESSAGE, item->hContact, item);
- res = appendString(res, buf);
- mir_free(buf);
+ {
+ CMStringW res;
+
+ int eventCount = data->items.getCount();
+ for (int i = 0; i < eventCount; i++) {
+ HistoryArray::ItemData *item = data->items.get(i, ELM_NOTHING);
+ if (item->flags & HIF_SELECTED)
+ res.Append(ptrW(TplFormatString(TPL_COPY_MESSAGE, item->hContact, item)));
}
+
+ CopyText(hwnd, res);
}
+ __fallthrough;
+ // End of history list control messages
- CopyText(hwnd, res);
- mir_free(res);
- }
- // End of history list control messages
case WM_SIZE:
InvalidateRect(hwnd, 0, FALSE);
break;
@@ -277,96 +274,95 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
return 1;
case WM_PRINTCLIENT:
- {
- // PaintClc(hwnd, dat, (HDC) wParam, NULL);
- break;
- }
- /*
- case WM_NCPAINT:
- {
- RECT rc;
- GetWindowRect(hwnd, &rc);
+ {
+ // PaintClc(hwnd, dat, (HDC) wParam, NULL);
+ break;
+ }
+ /*
+ case WM_NCPAINT:
+ {
+ RECT rc;
+ GetWindowRect(hwnd, &rc);
- HDC hdc;
- hdc = GetDCEx(hwnd, (HRGN)wParam, DCX_WINDOW|DCX_INTERSECTRGN);
- FrameRect(hdc, &rc, (HBRUSH)GetStockObject(BLACK_BRUSH));
- ReleaseDC(hwnd, hdc);
- }
- */
- /*
- case WM_NCPAINT:
- {
- if (wParam == 1)
- break;
+ HDC hdc;
+ hdc = GetDCEx(hwnd, (HRGN)wParam, DCX_WINDOW|DCX_INTERSECTRGN);
+ FrameRect(hdc, &rc, (HBRUSH)GetStockObject(BLACK_BRUSH));
+ ReleaseDC(hwnd, hdc);
+ }
+ */
+ /*
+ case WM_NCPAINT:
{
- POINT ptTopLeft = { 0, 0 };
- HRGN hClientRgn;
- ClientToScreen(hwnd, &ptTopLeft);
- hClientRgn = CreateRectRgn(0, 0, 1, 1);
- CombineRgn(hClientRgn, (HRGN) wParam, NULL, RGN_COPY);
- OffsetRgn(hClientRgn, -ptTopLeft.x, -ptTopLeft.y);
- InvalidateRgn(hwnd, hClientRgn, FALSE);
- DeleteObject(hClientRgn);
- UpdateWindow(hwnd);
+ if (wParam == 1)
+ break;
+ {
+ POINT ptTopLeft = { 0, 0 };
+ HRGN hClientRgn;
+ ClientToScreen(hwnd, &ptTopLeft);
+ hClientRgn = CreateRectRgn(0, 0, 1, 1);
+ CombineRgn(hClientRgn, (HRGN) wParam, NULL, RGN_COPY);
+ OffsetRgn(hClientRgn, -ptTopLeft.x, -ptTopLeft.y);
+ InvalidateRgn(hwnd, hClientRgn, FALSE);
+ DeleteObject(hClientRgn);
+ UpdateWindow(hwnd);
+ }
+ break;
}
- break;
- }
- */
+ */
case WM_PAINT:
- {
- HDC hdcWindow;
- PAINTSTRUCT ps;
- hdcWindow = BeginPaint(hwnd, &ps);
-
- /* we get so many InvalidateRect()'s that there is no point painting,
- Windows in theory shouldn't queue up WM_PAINTs in this case but it does so
- we'll just ignore them */
- if (IsWindowVisible(hwnd)) {
- RECT rc;
- GetClientRect(hwnd, &rc);
+ {
+ HDC hdcWindow;
+ PAINTSTRUCT ps;
+ hdcWindow = BeginPaint(hwnd, &ps);
+
+ /* we get so many InvalidateRect()'s that there is no point painting,
+ Windows in theory shouldn't queue up WM_PAINTs in this case but it does so
+ we'll just ignore them */
+ if (IsWindowVisible(hwnd)) {
+ RECT rc;
+ GetClientRect(hwnd, &rc);
+
+ HDC hdc = CreateCompatibleDC(hdcWindow);
+ HBITMAP hbmSave = (HBITMAP)SelectObject(hdc, CreateCompatibleBitmap(hdcWindow, rc.right - rc.left, rc.bottom - rc.top));
+
+ GetClientRect(hwnd, &rc);
+ int height = rc.bottom - rc.top;
+ int width = rc.right - rc.left;
+ int top = data->scrollTopPixel;
+ int idx = data->scrollTopItem;
+ while ((top < height) && (idx < data->items.getCount()))
+ top += PaintItem(hdc, &data->items, idx++, top, width);
+
+ if (top <= height) {
+ RECT rc2;
+ SetRect(&rc2, 0, top, width, height);
+
+ HBRUSH hbr;
+ hbr = CreateSolidBrush(RGB(0xff, 0xff, 0xff));
+ FillRect(hdc, &rc2, hbr);
+ DeleteObject(hbr);
+ }
- // HDC hdc = hdcWindow;
- HDC hdc = CreateCompatibleDC(hdcWindow);
- HBITMAP hbmSave = (HBITMAP)SelectObject(hdc, CreateCompatibleBitmap(hdcWindow, rc.right - rc.left, rc.bottom - rc.top));
+ GetWindowRect(hwnd, &rc);
+ rc.right -= rc.left; rc.left = 0;
+ rc.bottom -= rc.top; rc.top = 0;
+ DrawEdge(hdc, &rc, BDR_SUNKENOUTER, BF_RECT);
- GetClientRect(hwnd, &rc);
- int height = rc.bottom - rc.top;
- int width = rc.right - rc.left;
- int top = data->scrollTopPixel;
- int idx = data->scrollTopItem;
- while ((top < height) && (idx < data->items.getCount()))
- top += PaintItem(hdc, &data->items, idx++, top, width);
-
- if (top <= height) {
- RECT rc2;
- SetRect(&rc2, 0, top, width, height);
-
- HBRUSH hbr;
- hbr = CreateSolidBrush(RGB(0xff, 0xff, 0xff));
- FillRect(hdc, &rc2, hbr);
- DeleteObject(hbr);
+ BitBlt(hdcWindow, 0, 0, rc.right, rc.bottom, hdc, 0, 0, SRCCOPY);
+ DeleteObject(SelectObject(hdc, hbmSave));
+ DeleteDC(hdc);
}
- GetWindowRect(hwnd, &rc);
- rc.right -= rc.left; rc.left = 0;
- rc.bottom -= rc.top; rc.top = 0;
- DrawEdge(hdc, &rc, BDR_SUNKENOUTER, BF_RECT);
-
- BitBlt(hdcWindow, 0, 0, rc.right, rc.bottom, hdc, 0, 0, SRCCOPY);
- DeleteObject(SelectObject(hdc, hbmSave));
- DeleteDC(hdc);
+ EndPaint(hwnd, &ps);
}
-
- EndPaint(hwnd, &ps);
- }
- break;
+ break;
case WM_SETFOCUS:
return 0;
case WM_GETDLGCODE:
if (lParam) {
- MSG* msg2 = (MSG*)lParam;
+ MSG *msg2 = (MSG *)lParam;
if (msg2->message == WM_KEYDOWN) {
if (msg2->wParam == VK_TAB)
return 0;
@@ -383,36 +379,36 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
return DLGC_WANTMESSAGE;
case WM_KEYDOWN:
- {
- switch (wParam) {
- case VK_UP:
- SendMessage(hwnd, NSM_SELECTITEMS2, data->caret - 1, data->caret - 1);
- SendMessage(hwnd, NSM_SETCARET, data->caret - 1, TRUE);
- break;
+ {
+ switch (wParam) {
+ case VK_UP:
+ SendMessage(hwnd, NSM_SELECTITEMS2, data->caret - 1, data->caret - 1);
+ SendMessage(hwnd, NSM_SETCARET, data->caret - 1, TRUE);
+ break;
- case VK_DOWN:
- SendMessage(hwnd, NSM_SELECTITEMS2, data->caret + 1, data->caret + 1);
- SendMessage(hwnd, NSM_SETCARET, data->caret + 1, TRUE);
- break;
+ case VK_DOWN:
+ SendMessage(hwnd, NSM_SELECTITEMS2, data->caret + 1, data->caret + 1);
+ SendMessage(hwnd, NSM_SETCARET, data->caret + 1, TRUE);
+ break;
- case VK_PRIOR:
- break;
+ case VK_PRIOR:
+ break;
- case VK_NEXT:
- break;
+ case VK_NEXT:
+ break;
- case VK_HOME:
- break;
+ case VK_HOME:
+ break;
- case VK_END:
- break;
+ case VK_END:
+ break;
- case VK_F2:
- BeginEditItem(hwnd, data, data->caret);
+ case VK_F2:
+ BeginEditItem(hwnd, data, data->caret);
+ break;
+ }
break;
}
- break;
- }
case WM_SYSCHAR:
case WM_CHAR:
@@ -436,107 +432,107 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
break;
case WM_LBUTTONDOWN:
- {
- int item = SendMessage(hwnd, NSM_GETITEMFROMPIXEL, LOWORD(lParam), HIWORD(lParam));
- if (item >= 0) {
- if (data->caret != item)
- EndEditItem(hwnd, data);
+ {
+ int item = SendMessage(hwnd, NSM_GETITEMFROMPIXEL, LOWORD(lParam), HIWORD(lParam));
+ if (item >= 0) {
+ if (data->caret != item)
+ EndEditItem(hwnd, data);
- if (wParam & MK_CONTROL) {
- SendMessage(hwnd, NSM_TOGGLEITEMS, item, item);
- SendMessage(hwnd, NSM_SETCARET, item, TRUE);
- }
- else
- if (wParam & MK_SHIFT) {
- SendMessage(hwnd, NSM_SELECTITEMS, data->caret, item);
+ if (wParam & MK_CONTROL) {
+ SendMessage(hwnd, NSM_TOGGLEITEMS, item, item);
SendMessage(hwnd, NSM_SETCARET, item, TRUE);
}
- else {
- if (data->caret == item) {
- BeginEditItem(hwnd, data, item);
+ else
+ if (wParam & MK_SHIFT) {
+ SendMessage(hwnd, NSM_SELECTITEMS, data->caret, item);
+ SendMessage(hwnd, NSM_SETCARET, item, TRUE);
}
else {
- SendMessage(hwnd, NSM_SELECTITEMS2, item, item);
- SendMessage(hwnd, NSM_SETCARET, item, TRUE);
+ if (data->caret == item) {
+ BeginEditItem(hwnd, data, item);
+ }
+ else {
+ SendMessage(hwnd, NSM_SELECTITEMS2, item, item);
+ SendMessage(hwnd, NSM_SETCARET, item, TRUE);
+ }
}
- }
+ }
}
- }
- SetFocus(hwnd);
- return 0;
+ SetFocus(hwnd);
+ return 0;
case WM_MOUSEWHEEL:
- {
- DWORD s_scrollTopItem = data->scrollTopItem;
- int s_scrollTopPixel = data->scrollTopPixel;
+ {
+ DWORD s_scrollTopItem = data->scrollTopItem;
+ int s_scrollTopPixel = data->scrollTopPixel;
- UINT scrollLines;
- if (!SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &scrollLines, FALSE))
- scrollLines = 3;
- ScrollListBy(hwnd, data, 0, (short)HIWORD(wParam) * 10 * (signed)scrollLines / WHEEL_DELTA);
+ UINT scrollLines;
+ if (!SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &scrollLines, FALSE))
+ scrollLines = 3;
+ ScrollListBy(hwnd, data, 0, (short)HIWORD(wParam) * 10 * (signed)scrollLines / WHEEL_DELTA);
- if ((s_scrollTopItem != data->scrollTopItem) || (s_scrollTopPixel != data->scrollTopPixel))
- InvalidateRect(hwnd, 0, FALSE);
+ if ((s_scrollTopItem != data->scrollTopItem) || (s_scrollTopPixel != data->scrollTopPixel))
+ InvalidateRect(hwnd, 0, FALSE);
- return TRUE;
- }
+ return TRUE;
+ }
case WM_VSCROLL:
- {
- DWORD s_scrollTopItem = data->scrollTopItem;
- int s_scrollTopPixel = data->scrollTopPixel;
-
- switch (LOWORD(wParam)) {
- case SB_LINEUP:
- ScrollListBy(hwnd, data, 0, 10);
- break;
- case SB_LINEDOWN:
- ScrollListBy(hwnd, data, 0, -10);
- break;
- case SB_PAGEUP:
- ScrollListBy(hwnd, data, -10, 0);
- break;
- case SB_PAGEDOWN:
- ScrollListBy(hwnd, data, 10, 0);
- break;
- case SB_BOTTOM:
- data->scrollTopItem = data->items.getCount() - 1;
- data->scrollTopPixel = 0;
- break;
- case SB_TOP:
- data->scrollTopItem = 0;
- data->scrollTopPixel = 0;
- break;
- case SB_THUMBTRACK:
{
- SCROLLINFO si;
- si.cbSize = sizeof(si);
- si.fMask = SIF_TRACKPOS | SIF_RANGE;
- GetScrollInfo(hwnd, SB_VERT, &si);
- int pos = si.nTrackPos;
-
- if (pos == si.nMax) {
- data->scrollTopItem = data->items.getCount();
- data->scrollTopPixel = -1000;
- }
- else {
- data->scrollTopItem = pos / AVERAGE_ITEM_HEIGHT;
- int itemHeight = LayoutItem(hwnd, &data->items, data->scrollTopItem);
- data->scrollTopPixel = -pos % AVERAGE_ITEM_HEIGHT * itemHeight / AVERAGE_ITEM_HEIGHT;
+ DWORD s_scrollTopItem = data->scrollTopItem;
+ int s_scrollTopPixel = data->scrollTopPixel;
+
+ switch (LOWORD(wParam)) {
+ case SB_LINEUP:
+ ScrollListBy(hwnd, data, 0, 10);
+ break;
+ case SB_LINEDOWN:
+ ScrollListBy(hwnd, data, 0, -10);
+ break;
+ case SB_PAGEUP:
+ ScrollListBy(hwnd, data, -10, 0);
+ break;
+ case SB_PAGEDOWN:
+ ScrollListBy(hwnd, data, 10, 0);
+ break;
+ case SB_BOTTOM:
+ data->scrollTopItem = data->items.getCount() - 1;
+ data->scrollTopPixel = 0;
+ break;
+ case SB_TOP:
+ data->scrollTopItem = 0;
+ data->scrollTopPixel = 0;
+ break;
+ case SB_THUMBTRACK:
+ {
+ SCROLLINFO si;
+ si.cbSize = sizeof(si);
+ si.fMask = SIF_TRACKPOS | SIF_RANGE;
+ GetScrollInfo(hwnd, SB_VERT, &si);
+ int pos = si.nTrackPos;
+
+ if (pos == si.nMax) {
+ data->scrollTopItem = data->items.getCount();
+ data->scrollTopPixel = -1000;
+ }
+ else {
+ data->scrollTopItem = pos / AVERAGE_ITEM_HEIGHT;
+ int itemHeight = LayoutItem(hwnd, &data->items, data->scrollTopItem);
+ data->scrollTopPixel = -pos % AVERAGE_ITEM_HEIGHT * itemHeight / AVERAGE_ITEM_HEIGHT;
+ }
+ FixScrollPosition(hwnd, data);
+ }
+ break;
+
+ default:
+ return 0;
}
- FixScrollPosition(hwnd, data);
- }
- break;
- default:
- return 0;
+ if ((s_scrollTopItem != data->scrollTopItem) || (s_scrollTopPixel != data->scrollTopPixel))
+ InvalidateRect(hwnd, 0, FALSE);
+ break;
}
- if ((s_scrollTopItem != data->scrollTopItem) || (s_scrollTopPixel != data->scrollTopPixel))
- InvalidateRect(hwnd, 0, FALSE);
- break;
- }
-
case WM_DESTROY:
delete data;
SetWindowLongPtr(hwnd, 0, 0);
@@ -548,7 +544,7 @@ LRESULT CALLBACK NewstoryListWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
/////////////////////////////////////////////////////////////////////////
// Utilities
-static void ScrollListBy(HWND hwnd, NewstoryListData* data, int scrollItems, int scrollPixels)
+static void ScrollListBy(HWND hwnd, NewstoryListData *data, int scrollItems, int scrollPixels)
{
if (scrollItems) {
data->scrollTopItem += scrollItems;
@@ -581,7 +577,7 @@ static void ScrollListBy(HWND hwnd, NewstoryListData* data, int scrollItems, int
FixScrollPosition(hwnd, data);
}
-static void EnsureVisible(HWND hwnd, NewstoryListData* data, int item)
+static void EnsureVisible(HWND hwnd, NewstoryListData *data, int item)
{
if (data->scrollTopItem >= item) {
data->scrollTopItem = item;
@@ -614,7 +610,7 @@ static void EnsureVisible(HWND hwnd, NewstoryListData* data, int item)
FixScrollPosition(hwnd, data);
}
-static void FixScrollPosition(HWND hwnd, NewstoryListData* data)
+static void FixScrollPosition(HWND hwnd, NewstoryListData *data)
{
EndEditItem(hwnd, data);
@@ -644,7 +640,7 @@ static void FixScrollPosition(HWND hwnd, NewstoryListData* data)
RecalcScrollBar(hwnd, data);
}
-static void RecalcScrollBar(HWND hwnd, NewstoryListData* data)
+static void RecalcScrollBar(HWND hwnd, NewstoryListData *data)
{
SCROLLINFO si = { 0 };
RECT clRect;
@@ -658,7 +654,7 @@ static void RecalcScrollBar(HWND hwnd, NewstoryListData* data)
SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
}
-static void BeginEditItem(HWND hwnd, NewstoryListData* data, int index)
+static void BeginEditItem(HWND hwnd, NewstoryListData *data, int index)
{
if (data->hwndEditBox)
EndEditItem(hwnd, data);
@@ -674,7 +670,7 @@ static void BeginEditItem(HWND hwnd, NewstoryListData* data, int index)
int itemHeight = LayoutItem(hwnd, &data->items, idx);
while (top < height) {
if (idx == index) {
- HistoryArray::ItemData* item = data->items.get(index, ELM_DATA);
+ HistoryArray::ItemData *item = data->items.get(index, ELM_DATA);
int tpl;
int fontid;
@@ -717,7 +713,7 @@ static void BeginEditItem(HWND hwnd, NewstoryListData* data, int index)
break;
}
- wchar_t* text = TplFormatString(tpl, item->hContact, item);
+ ptrW text(TplFormatString(tpl, item->hContact, item));
data->hwndEditBox = CreateWindow(L"EDIT", text, WS_CHILD | WS_BORDER | ES_READONLY | ES_MULTILINE | ES_AUTOVSCROLL, 0, top, rc.right - rc.left, itemHeight, hwnd, NULL, g_plugin.getInst(), NULL);
OldEditWndProc = (WNDPROC)SetWindowLongPtr(data->hwndEditBox, GWLP_WNDPROC, (LONG_PTR)HistoryEditWndProc);
SendMessage(data->hwndEditBox, WM_SETFONT, (WPARAM)fonts[fontid].hfnt, 0);
@@ -725,7 +721,6 @@ static void BeginEditItem(HWND hwnd, NewstoryListData* data, int index)
SendMessage(data->hwndEditBox, EM_SETSEL, 0, (LPARAM)(-1));
ShowWindow(data->hwndEditBox, SW_SHOW);
SetFocus(data->hwndEditBox);
- mir_free(text);
break;
}
top += itemHeight;
@@ -734,19 +729,19 @@ static void BeginEditItem(HWND hwnd, NewstoryListData* data, int index)
}
}
-static void EndEditItem(HWND, NewstoryListData* data)
+static void EndEditItem(HWND, NewstoryListData *data)
{
DestroyWindow(data->hwndEditBox);
data->hwndEditBox = 0;
}
-static int LayoutItem(HWND hwnd, HistoryArray* items, int index)
+static int LayoutItem(HWND hwnd, HistoryArray *items, int index)
{
HDC hdc = GetDC(hwnd);
RECT rc; GetClientRect(hwnd, &rc);
int width = rc.right - rc.left;
- HistoryArray::ItemData* item = items->get(index, ELM_DATA);
+ HistoryArray::ItemData *item = items->get(index, ELM_DATA);
if (!item) return 0;
int tpl;
@@ -784,11 +779,8 @@ static int LayoutItem(HWND hwnd, HistoryArray* items, int index)
}
HFONT hfnt = (HFONT)SelectObject(hdc, fonts[fontid].hfnt);
- if (!item->data) {
- wchar_t* buf = TplFormatString(tpl, item->hContact, item);
- item->data = MTextCreateW(htuLog, buf);
- mir_free(buf);
- }
+ if (!item->data)
+ item->data = MTextCreateW(htuLog, ptrW(TplFormatString(tpl, item->hContact, item)));
SIZE sz;
sz.cx = width - 6;
@@ -800,10 +792,10 @@ static int LayoutItem(HWND hwnd, HistoryArray* items, int index)
return sz.cy + 5;
}
-static int PaintItem(HDC hdc, HistoryArray* items, int index, int top, int width)
+static int PaintItem(HDC hdc, HistoryArray *items, int index, int top, int width)
{
if (!items) return 0;
- HistoryArray::ItemData* item = items->get(index, ELM_DATA);
+ HistoryArray::ItemData *item = items->get(index, ELM_DATA);
// LOGFONT lfText;
COLORREF clText, clBack, clLine;
@@ -861,7 +853,7 @@ static int PaintItem(HDC hdc, HistoryArray* items, int index, int top, int width
}
if (!item->data) {
- wchar_t* buf = TplFormatString(tpl, item->hContact, item);
+ wchar_t *buf = TplFormatString(tpl, item->hContact, item);
item->data = MTextCreateW(htuLog, buf);
mir_free(buf);
if (!item->data)
diff --git a/plugins/NewStory/src/options.cpp b/plugins/NewStory/src/options.cpp
index 02a0d013d9..093a9e845c 100644
--- a/plugins/NewStory/src/options.cpp
+++ b/plugins/NewStory/src/options.cpp
@@ -78,7 +78,7 @@ static INT_PTR CALLBACK OptTemplatesDlgProc(HWND hwnd, UINT msg, WPARAM wParam,
mir_free(templates[CurrentTemplate].tmpValue);
{
int length = GetWindowTextLength(GetDlgItem(hwnd, IDC_EDITTEMPLATE)) + 1;
- templates[CurrentTemplate].tmpValue = (wchar_t*)mir_alloc(length * sizeof(wchar_t));
+ templates[CurrentTemplate].tmpValue = (wchar_t *)mir_alloc(length * sizeof(wchar_t));
GetWindowText(GetDlgItem(hwnd, IDC_EDITTEMPLATE), templates[CurrentTemplate].tmpValue, length);
HistoryArray::ItemData item;
@@ -91,7 +91,7 @@ static INT_PTR CALLBACK OptTemplatesDlgProc(HWND hwnd, UINT msg, WPARAM wParam,
if (item.hContact && item.hEvent) {
item.load(ELM_DATA);
- wchar_t* preview = TplFormatStringEx(CurrentTemplate, templates[CurrentTemplate].tmpValue, item.hContact, &item);
+ wchar_t *preview = TplFormatStringEx(CurrentTemplate, templates[CurrentTemplate].tmpValue, item.hContact, &item);
SetWindowText(GetDlgItem(hwnd, IDC_PREVIEW), preview);
// SetWindowText(GetDlgItem(hwnd, IDC_GPREVIEW), preview);
SetWindowText(GetDlgItem(hwnd, IDC_GPREVIEW), L"$hit :)");
@@ -149,58 +149,58 @@ static INT_PTR CALLBACK OptTemplatesDlgProc(HWND hwnd, UINT msg, WPARAM wParam,
switch (((LPNMHDR)lParam)->code) {
case TVN_SELCHANGED:
case TVN_SELCHANGING:
- {
- LPNMTREEVIEW lpnmtv = (LPNMTREEVIEW)lParam;
-
- TVITEM tvi;
- tvi.hItem = TreeView_GetSelection(GetDlgItem(hwnd, IDC_TEMPLATES));
- tvi.mask = TVIF_PARAM;
- TreeView_GetItem(GetDlgItem(hwnd, IDC_TEMPLATES), &tvi);
-
- if ((tvi.lParam < 0) || (tvi.lParam >= TPL_COUNT)) {
- EnableWindow(GetDlgItem(hwnd, IDC_EDITTEMPLATE), FALSE);
- EnableWindow(GetDlgItem(hwnd, IDC_GPREVIEW), FALSE);
- EnableWindow(GetDlgItem(hwnd, IDC_PREVIEW), FALSE);
- EnableWindow(GetDlgItem(hwnd, IDC_DISCARD), FALSE);
- EnableWindow(GetDlgItem(hwnd, IDC_UPDATEPREVIEW), FALSE);
- EnableWindow(GetDlgItem(hwnd, IDC_VARHELP), FALSE);
- /* HTREEITEM hItem = TreeView_GetChild(GetDlgItem(hwnd, IDC_TEMPLATES), tvi.hItem);
- if (hItem)
- {
- TreeView_Expand(GetDlgItem(hwnd, IDC_TEMPLATES), tvi.hItem, TVE_EXPAND);
- TreeView_SelectItem(GetDlgItem(hwnd, IDC_TEMPLATES), hItem);
- }*/
- break;
- }
- else {
- EnableWindow(GetDlgItem(hwnd, IDC_EDITTEMPLATE), TRUE);
- EnableWindow(GetDlgItem(hwnd, IDC_GPREVIEW), TRUE);
- EnableWindow(GetDlgItem(hwnd, IDC_PREVIEW), TRUE);
- EnableWindow(GetDlgItem(hwnd, IDC_DISCARD), TRUE);
- EnableWindow(GetDlgItem(hwnd, IDC_UPDATEPREVIEW), TRUE);
- EnableWindow(GetDlgItem(hwnd, IDC_VARHELP), TRUE);
- }
+ {
+ LPNMTREEVIEW lpnmtv = (LPNMTREEVIEW)lParam;
+
+ TVITEM tvi;
+ tvi.hItem = TreeView_GetSelection(GetDlgItem(hwnd, IDC_TEMPLATES));
+ tvi.mask = TVIF_PARAM;
+ TreeView_GetItem(GetDlgItem(hwnd, IDC_TEMPLATES), &tvi);
+
+ if ((tvi.lParam < 0) || (tvi.lParam >= TPL_COUNT)) {
+ EnableWindow(GetDlgItem(hwnd, IDC_EDITTEMPLATE), FALSE);
+ EnableWindow(GetDlgItem(hwnd, IDC_GPREVIEW), FALSE);
+ EnableWindow(GetDlgItem(hwnd, IDC_PREVIEW), FALSE);
+ EnableWindow(GetDlgItem(hwnd, IDC_DISCARD), FALSE);
+ EnableWindow(GetDlgItem(hwnd, IDC_UPDATEPREVIEW), FALSE);
+ EnableWindow(GetDlgItem(hwnd, IDC_VARHELP), FALSE);
+ /*
+ HTREEITEM hItem = TreeView_GetChild(GetDlgItem(hwnd, IDC_TEMPLATES), tvi.hItem);
+ if (hItem) {
+ TreeView_Expand(GetDlgItem(hwnd, IDC_TEMPLATES), tvi.hItem, TVE_EXPAND);
+ TreeView_SelectItem(GetDlgItem(hwnd, IDC_TEMPLATES), hItem);
+ }*/
+ break;
+ }
+ else {
+ EnableWindow(GetDlgItem(hwnd, IDC_EDITTEMPLATE), TRUE);
+ EnableWindow(GetDlgItem(hwnd, IDC_GPREVIEW), TRUE);
+ EnableWindow(GetDlgItem(hwnd, IDC_PREVIEW), TRUE);
+ EnableWindow(GetDlgItem(hwnd, IDC_DISCARD), TRUE);
+ EnableWindow(GetDlgItem(hwnd, IDC_UPDATEPREVIEW), TRUE);
+ EnableWindow(GetDlgItem(hwnd, IDC_VARHELP), TRUE);
+ }
- if ((lpnmtv->itemOld.mask & TVIF_HANDLE) && lpnmtv->itemOld.hItem && (lpnmtv->itemOld.hItem != lpnmtv->itemNew.hItem) && (lpnmtv->itemOld.lParam >= 0) && (lpnmtv->itemOld.lParam < TPL_COUNT)) {
- if (templates[lpnmtv->itemOld.lParam].tmpValue)
- mir_free(templates[lpnmtv->itemOld.lParam].tmpValue);
- int length = GetWindowTextLength(GetDlgItem(hwnd, IDC_EDITTEMPLATE)) + 1;
- templates[lpnmtv->itemOld.lParam].tmpValue = (wchar_t*)mir_alloc(length * sizeof(wchar_t));
- GetWindowText(GetDlgItem(hwnd, IDC_EDITTEMPLATE), templates[lpnmtv->itemOld.lParam].tmpValue, length);
- }
+ if ((lpnmtv->itemOld.mask & TVIF_HANDLE) && lpnmtv->itemOld.hItem && (lpnmtv->itemOld.hItem != lpnmtv->itemNew.hItem) && (lpnmtv->itemOld.lParam >= 0) && (lpnmtv->itemOld.lParam < TPL_COUNT)) {
+ if (templates[lpnmtv->itemOld.lParam].tmpValue)
+ mir_free(templates[lpnmtv->itemOld.lParam].tmpValue);
+ int length = GetWindowTextLength(GetDlgItem(hwnd, IDC_EDITTEMPLATE)) + 1;
+ templates[lpnmtv->itemOld.lParam].tmpValue = (wchar_t *)mir_alloc(length * sizeof(wchar_t));
+ GetWindowText(GetDlgItem(hwnd, IDC_EDITTEMPLATE), templates[lpnmtv->itemOld.lParam].tmpValue, length);
+ }
- CurrentTemplate = tvi.lParam;
+ CurrentTemplate = tvi.lParam;
- if (templates[CurrentTemplate].tmpValue)
- SetWindowText(GetDlgItem(hwnd, IDC_EDITTEMPLATE), templates[CurrentTemplate].tmpValue);
- else if (templates[CurrentTemplate].value)
- SetWindowText(GetDlgItem(hwnd, IDC_EDITTEMPLATE), templates[CurrentTemplate].value);
- else
- SetWindowText(GetDlgItem(hwnd, IDC_EDITTEMPLATE), templates[CurrentTemplate].defvalue);
+ if (templates[CurrentTemplate].tmpValue)
+ SetWindowText(GetDlgItem(hwnd, IDC_EDITTEMPLATE), templates[CurrentTemplate].tmpValue);
+ else if (templates[CurrentTemplate].value)
+ SetWindowText(GetDlgItem(hwnd, IDC_EDITTEMPLATE), templates[CurrentTemplate].value);
+ else
+ SetWindowText(GetDlgItem(hwnd, IDC_EDITTEMPLATE), templates[CurrentTemplate].defvalue);
- PostMessage(hwnd, WM_COMMAND, MAKEWPARAM(IDC_UPDATEPREVIEW, 0), 0);
- }
- break;
+ PostMessage(hwnd, WM_COMMAND, MAKEWPARAM(IDC_UPDATEPREVIEW, 0), 0);
+ }
+ break;
case TVN_KEYDOWN:
case NM_CLICK:
diff --git a/plugins/NewStory/src/templates.cpp b/plugins/NewStory/src/templates.cpp
index abe7e34913..828efaf4fe 100644
--- a/plugins/NewStory/src/templates.cpp
+++ b/plugins/NewStory/src/templates.cpp
@@ -1,105 +1,21 @@
#include "stdafx.h"
-void TplInitVars(TemplateVars* vars);
-void TplCleanVars(TemplateVars* vars);
-__forceinline wchar_t* TplGetVar(TemplateVars* vars, char id);
-__forceinline void TplSetVar(TemplateVars* vars, char id, wchar_t* v, bool d);
-int TplMeasureVars(TemplateVars* vars, wchar_t* str);
-
-void vfGlobal(int mode, TemplateVars* vars, MCONTACT hContact, HistoryArray::ItemData* item);
-void vfContact(int mode, TemplateVars* vars, MCONTACT hContact, HistoryArray::ItemData* item);
-void vfSystem(int mode, TemplateVars* vars, MCONTACT hContact, HistoryArray::ItemData* item);
-void vfEvent(int mode, TemplateVars* vars, MCONTACT hContact, HistoryArray::ItemData* item);
-void vfMessage(int mode, TemplateVars* vars, MCONTACT hContact, HistoryArray::ItemData* item);
-void vfFile(int mode, TemplateVars* vars, MCONTACT hContact, HistoryArray::ItemData* item);
-void vfUrl(int mode, TemplateVars* vars, MCONTACT hContact, HistoryArray::ItemData* item);
-void vfSign(int mode, TemplateVars* vars, MCONTACT hContact, HistoryArray::ItemData* item);
-void vfAuth(int mode, TemplateVars* vars, MCONTACT hContact, HistoryArray::ItemData* item);
-void vfAdded(int mode, TemplateVars* vars, MCONTACT hContact, HistoryArray::ItemData* item);
-void vfDeleted(int mode, TemplateVars* vars, MCONTACT hContact, HistoryArray::ItemData* item);
-void vfOther(int mode, TemplateVars* vars, MCONTACT hContact, HistoryArray::ItemData* item);
-
-TemplateInfo templates[TPL_COUNT] =
-{
- { "tpl/interface/title", L"Interface", ICO_NEWSTORY, L"Window Title",
- L"%N's Newstory [%c messages total]", 0, 0,
- { vfGlobal, vfContact, 0, 0, 0 } },
-
- { "tpl/msglog/msg", L"Message Log", ICO_SENDMSG, L"Messages",
- L"%I%i[b]%N, %t:[/b]\x0d\x0a%M", 0, 0,
- { vfGlobal, vfContact, vfEvent, vfMessage, 0 } },
- { "tpl/msglog/file", L"Message Log", ICO_FILE, L"Files",
- L"%I%i[b]%N, %t:[/b]%n%M", 0, 0,
- { vfGlobal, vfContact, vfEvent, vfFile, 0 } },
- { "tpl/msglog/status", L"Message Log", ICO_SIGNIN, L"Status Changes",
- L"%I%i[b]%N, %t:[/b]%n%M", 0, 0,
- { vfGlobal, vfContact, vfEvent, vfSign, 0 } },
- { "tpl/msglog/other", L"Message Log", ICO_UNKNOWN, L"Other Events",
- L"%I%i[b]%N, %t:[/b]%n%M", 0, 0,
- { vfGlobal, vfContact, vfEvent, vfOther, 0 } },
-
- { "tpl/msglog/authrq", L"Message Log", ICO_UNKNOWN, L"Authorization Requests",
- L"%I%i[b]%N, %t:[/b]%n%M", 0, 0,
- { vfGlobal, vfEvent, vfSystem, vfAuth, 0 } },
- { "tpl/msglog/added", L"Message Log", ICO_UNKNOWN, L"'You were added' events",
- L"%I%i[b]%N, %t:[/b]%n%M", 0, 0,
- { vfGlobal, vfEvent, vfSystem, vfAdded, 0 } },
- { "tpl/msglog/deleted", L"Message Log", ICO_UNKNOWN, L"'You were deleted' events",
- L"%I%i[b]%N, %t:[/b]%n%M", 0, 0,
- { vfGlobal, vfEvent, vfSystem, vfDeleted, 0 } },
-
- { "tpl/copy/msg", L"Clipboard", ICO_SENDMSG, L"Messages",
- L"%N, %t:\x0d\x0a%M%n", 0, 0,
- { vfGlobal, vfContact, vfEvent, vfMessage, 0 } },
- { "tpl/copy/file", L"Clipboard", ICO_FILE, L"Files",
- L"%N, %t:\x0d\x0a%M%n", 0, 0,
- { vfGlobal, vfContact, vfEvent, vfFile, 0 } },
- { "tpl/copy/url", L"Clipboard", ICO_URL, L"URLs",
- L"%N, %t:\x0d\x0a%M%n", 0, 0,
- { vfGlobal, vfContact, vfEvent, vfUrl, 0 } },
- { "tpl/copy/status", L"Clipboard", ICO_SIGNIN, L"Status Changes",
- L"%N, %t:\x0d\x0a%M%n", 0, 0,
- { vfGlobal, vfContact, vfEvent, vfSign, 0 } },
- { "tpl/copy/other", L"Clipboard", ICO_UNKNOWN, L"Other Events",
- L"%N, %t:\x0d\x0a%M%n", 0, 0,
- { vfGlobal, vfContact, vfEvent, vfOther, 0 } },
-
- { "tpl/copy/authrq", L"Clipboard", ICO_UNKNOWN, L"Authorization Requests",
- L"%N, %t:\x0d\x0a%M%n", 0, 0,
- { vfGlobal, vfEvent, vfSystem, vfAuth, 0 } },
- { "tpl/copy/added", L"Clipboard", ICO_UNKNOWN, L"'You were added' events",
- L"%N, %t:\x0d\x0a%M%n", 0, 0,
- { vfGlobal, vfEvent, vfSystem, vfAdded, 0 } },
- { "tpl/copy/deleted", L"Clipboard", ICO_UNKNOWN, L"'You were deleted' events",
- L"%N, %t:\x0d\x0a%M%n", 0, 0,
- { vfGlobal, vfEvent, vfSystem, vfDeleted, 0 } }
-};
-
-void LoadTemplates()
+__forceinline wchar_t *TplGetVar(TemplateVars *vars, char id)
{
- for (int i = 0; i < TPL_COUNT; i++) {
- DBVARIANT dbv = { 0 };
- db_get_ws(0, MODULENAME, templates[i].setting, &dbv);
- if (templates[i].value)
- mir_free(templates[i].value);
- if (dbv.pwszVal) {
- templates[i].value = mir_wstrdup(dbv.pwszVal);
- }
- else {
- templates[i].value = 0;
- }
- db_free(&dbv);
- }
+ return vars->val[id];
}
-void SaveTemplates()
+__forceinline void TplSetVar(TemplateVars *vars, char id, wchar_t *v, bool d)
{
- for (int i = 0; i < TPL_COUNT; i++)
- if (templates[i].value)
- db_set_ws(0, MODULENAME, templates[i].setting, templates[i].value);
+ if (vars->val[id] && vars->del[id])
+ mir_free(vars->val[id]);
+ vars->val[id] = mir_wstrdup(v);
+ vars->del[id] = d;
}
-wchar_t* TplFormatStringEx(int tpl, wchar_t* sztpl, MCONTACT hContact, HistoryArray::ItemData* item)
+int TplMeasureVars(TemplateVars* vars, wchar_t* str);
+
+wchar_t *TplFormatStringEx(int tpl, wchar_t *sztpl, MCONTACT hContact, HistoryArray::ItemData *item)
{
if ((tpl < 0) || (tpl >= TPL_COUNT) || !sztpl)
return mir_wstrdup(L"");
@@ -115,11 +31,11 @@ wchar_t* TplFormatStringEx(int tpl, wchar_t* sztpl, MCONTACT hContact, HistoryAr
if (templates[tpl].vf[i])
templates[tpl].vf[i](VFM_VARS, &vars, hContact, item);
- wchar_t* buf = (wchar_t*)mir_alloc(sizeof(wchar_t) * (TplMeasureVars(&vars, sztpl) + 1));
- wchar_t* bufptr = buf;
- for (wchar_t* p = sztpl; *p; p++) {
+ wchar_t *buf = (wchar_t *)mir_alloc(sizeof(wchar_t) * (TplMeasureVars(&vars, sztpl) + 1));
+ wchar_t *bufptr = buf;
+ for (wchar_t *p = sztpl; *p; p++) {
if (*p == '%') {
- wchar_t* var = TplGetVar(&vars, (char)(p[1] & 0xff));
+ wchar_t *var = TplGetVar(&vars, (char)(p[1] & 0xff));
if (var) {
mir_wstrcpy(bufptr, var);
bufptr += mir_wstrlen(var);
@@ -132,7 +48,7 @@ wchar_t* TplFormatStringEx(int tpl, wchar_t* sztpl, MCONTACT hContact, HistoryAr
return buf;
}
-wchar_t* TplFormatString(int tpl, MCONTACT hContact, HistoryArray::ItemData* item)
+wchar_t *TplFormatString(int tpl, MCONTACT hContact, HistoryArray::ItemData *item)
{
if ((tpl < 0) || (tpl >= TPL_COUNT))
return mir_wstrdup(L"");
@@ -151,11 +67,11 @@ wchar_t* TplFormatString(int tpl, MCONTACT hContact, HistoryArray::ItemData* ite
if (templates[tpl].vf[i])
templates[tpl].vf[i](VFM_VARS, &vars, hContact, item);
- wchar_t* buf = (wchar_t*)mir_alloc(sizeof(wchar_t) * (TplMeasureVars(&vars, templates[tpl].value) + 1));
- wchar_t* bufptr = buf;
- for (wchar_t* p = templates[tpl].value; *p; p++) {
+ wchar_t *buf = (wchar_t *)mir_alloc(sizeof(wchar_t) * (TplMeasureVars(&vars, templates[tpl].value) + 1));
+ wchar_t *bufptr = buf;
+ for (wchar_t *p = templates[tpl].value; *p; p++) {
if (*p == '%') {
- wchar_t* var = TplGetVar(&vars, (char)(p[1] & 0xff));
+ wchar_t *var = TplGetVar(&vars, (char)(p[1] & 0xff));
if (var) {
mir_wstrcpy(bufptr, var);
bufptr += mir_wstrlen(var);
@@ -169,7 +85,7 @@ wchar_t* TplFormatString(int tpl, MCONTACT hContact, HistoryArray::ItemData* ite
}
// Variable management
-void TplInitVars(TemplateVars* vars)
+void TplInitVars(TemplateVars *vars)
{
for (int i = 0; i < 256; i++) {
vars->val[i] = 0;
@@ -177,7 +93,7 @@ void TplInitVars(TemplateVars* vars)
}
}
-void TplCleanVars(TemplateVars* vars)
+void TplCleanVars(TemplateVars *vars)
{
for (int i = 0; i < 256; i++)
if (vars->val[i] && vars->del[i]) {
@@ -187,25 +103,12 @@ void TplCleanVars(TemplateVars* vars)
}
}
-__forceinline wchar_t* TplGetVar(TemplateVars* vars, char id)
-{
- return vars->val[id];
-}
-
-__forceinline void TplSetVar(TemplateVars* vars, char id, wchar_t* v, bool d)
-{
- if (vars->val[id] && vars->del[id])
- mir_free(vars->val[id]);
- vars->val[id] = mir_wstrdup(v);
- vars->del[id] = d;
-}
-
-int TplMeasureVars(TemplateVars* vars, wchar_t* str)
+int TplMeasureVars(TemplateVars *vars, wchar_t *str)
{
int res = 0;
- for (wchar_t* p = str; *p; p++) {
+ for (wchar_t *p = str; *p; p++) {
if (*p == '%') {
- wchar_t* var = TplGetVar(vars, (char)(p[1] & 0xff));
+ wchar_t *var = TplGetVar(vars, (char)(p[1] & 0xff));
if (var) res += mir_wstrlen(var);
p++;
}
@@ -215,7 +118,7 @@ int TplMeasureVars(TemplateVars* vars, wchar_t* str)
}
// Loading variables
-void vfGlobal(int, TemplateVars* vars, MCONTACT, HistoryArray::ItemData*)
+void vfGlobal(int, TemplateVars *vars, MCONTACT, HistoryArray::ItemData *)
{
// %%: simply % character
TplSetVar(vars, '%', L"%", false);
@@ -225,14 +128,14 @@ void vfGlobal(int, TemplateVars* vars, MCONTACT, HistoryArray::ItemData*)
// %M: my nick (not for messages)
//todo: not working now
- wchar_t* buf = Clist_GetContactDisplayName(0, 0);
+ wchar_t *buf = Clist_GetContactDisplayName(0, 0);
TplSetVar(vars, 'M', buf, false);
}
-void vfContact(int, TemplateVars* vars, MCONTACT hContact, HistoryArray::ItemData*)
+void vfContact(int, TemplateVars *vars, MCONTACT hContact, HistoryArray::ItemData *)
{
// %N: buddy's nick (not for messages)
- wchar_t* nick = Clist_GetContactDisplayName(hContact, 0);
+ wchar_t *nick = Clist_GetContactDisplayName(hContact, 0);
TplSetVar(vars, 'N', nick, false);
wchar_t buf[20];
@@ -241,7 +144,7 @@ void vfContact(int, TemplateVars* vars, MCONTACT hContact, HistoryArray::ItemDat
TplSetVar(vars, 'c', buf, false);
}
-void vfSystem(int, TemplateVars* vars, MCONTACT hContact, HistoryArray::ItemData*)
+void vfSystem(int, TemplateVars *vars, MCONTACT hContact, HistoryArray::ItemData *)
{
// %N: buddy's nick (not for messages)
TplSetVar(vars, 'N', L"System Event", false);
@@ -252,23 +155,22 @@ void vfSystem(int, TemplateVars* vars, MCONTACT hContact, HistoryArray::ItemData
TplSetVar(vars, 'c', buf, false);
}
-void vfEvent(int, TemplateVars* vars, MCONTACT, HistoryArray::ItemData* item)
+void vfEvent(int, TemplateVars *vars, MCONTACT, HistoryArray::ItemData *item)
{
HICON hIcon;
wchar_t buf[100];
// %N: Nickname
if (item->dbe.flags & DBEF_SENT) {
- char* proto = Proto_GetBaseAccountName(item->hContact);
+ char *proto = Proto_GetBaseAccountName(item->hContact);
ptrW nick(Contact_GetInfo(CNF_DISPLAY, 0, proto));
TplSetVar(vars, 'N', nick, false);
}
else {
- wchar_t* nick = Clist_GetContactDisplayName(item->hContact, 0);
+ wchar_t *nick = Clist_GetContactDisplayName(item->hContact, 0);
TplSetVar(vars, 'N', nick, false);
}
-
// %I: Icon
switch (item->dbe.eventType) {
case EVENTTYPE_MESSAGE:
@@ -303,94 +205,176 @@ void vfEvent(int, TemplateVars* vars, MCONTACT, HistoryArray::ItemData* item)
TplSetVar(vars, 'D', L">>", false);
// %t: timestamp
- _tcsftime(buf, _countof(buf), L"%d.%m.%Y, %H:%M", _localtime32((__time32_t*)&item->dbe.timestamp));
+ _tcsftime(buf, _countof(buf), L"%d.%m.%Y, %H:%M", _localtime32((__time32_t *)&item->dbe.timestamp));
TplSetVar(vars, 't', buf, true);
// %h: hour (24 hour format, 0-23)
- _tcsftime(buf, _countof(buf), L"%H", _localtime32((__time32_t*)&item->dbe.timestamp));
+ _tcsftime(buf, _countof(buf), L"%H", _localtime32((__time32_t *)&item->dbe.timestamp));
TplSetVar(vars, 'h', buf, true);
// %a: hour (12 hour format)
- _tcsftime(buf, _countof(buf), L"%h", _localtime32((__time32_t*)&item->dbe.timestamp));
+ _tcsftime(buf, _countof(buf), L"%h", _localtime32((__time32_t *)&item->dbe.timestamp));
TplSetVar(vars, 'a', buf, true);
// %m: minute
- _tcsftime(buf, _countof(buf), L"%M", _localtime32((__time32_t*)&item->dbe.timestamp));
+ _tcsftime(buf, _countof(buf), L"%M", _localtime32((__time32_t *)&item->dbe.timestamp));
TplSetVar(vars, 'm', buf, true);
// %s: second
- _tcsftime(buf, _countof(buf), L"%S", _localtime32((__time32_t*)&item->dbe.timestamp));
+ _tcsftime(buf, _countof(buf), L"%S", _localtime32((__time32_t *)&item->dbe.timestamp));
TplSetVar(vars, 's', buf, true);
// %o: month
- _tcsftime(buf, _countof(buf), L"%m", _localtime32((__time32_t*)&item->dbe.timestamp));
+ _tcsftime(buf, _countof(buf), L"%m", _localtime32((__time32_t *)&item->dbe.timestamp));
TplSetVar(vars, 'o', buf, true);
// %d: day of month
- _tcsftime(buf, _countof(buf), L"%d", _localtime32((__time32_t*)&item->dbe.timestamp));
+ _tcsftime(buf, _countof(buf), L"%d", _localtime32((__time32_t *)&item->dbe.timestamp));
TplSetVar(vars, 'd', buf, true);
// %y: year
- _tcsftime(buf, _countof(buf), L"%Y", _localtime32((__time32_t*)&item->dbe.timestamp));
+ _tcsftime(buf, _countof(buf), L"%Y", _localtime32((__time32_t *)&item->dbe.timestamp));
TplSetVar(vars, 'y', buf, true);
// %w: day of week (Sunday, Monday.. translateable)
- _tcsftime(buf, _countof(buf), L"%A", _localtime32((__time32_t*)&item->dbe.timestamp));
+ _tcsftime(buf, _countof(buf), L"%A", _localtime32((__time32_t *)&item->dbe.timestamp));
TplSetVar(vars, 'w', TranslateW(buf), false);
// %p: AM/PM symbol
- _tcsftime(buf, _countof(buf), L"%p", _localtime32((__time32_t*)&item->dbe.timestamp));
+ _tcsftime(buf, _countof(buf), L"%p", _localtime32((__time32_t *)&item->dbe.timestamp));
TplSetVar(vars, 'p', buf, true);
// %O: Name of month, translateable
- _tcsftime(buf, _countof(buf), L"%B", _localtime32((__time32_t*)&item->dbe.timestamp));
+ _tcsftime(buf, _countof(buf), L"%B", _localtime32((__time32_t *)&item->dbe.timestamp));
TplSetVar(vars, 'O', TranslateW(buf), false);
}
-void vfMessage(int, TemplateVars* vars, MCONTACT, HistoryArray::ItemData* item)
+void vfMessage(int, TemplateVars *vars, MCONTACT, HistoryArray::ItemData *item)
{
// %M: the message string itself
TplSetVar(vars, 'M', item->getTBuf(), false);
}
-void vfFile(int, TemplateVars* vars, MCONTACT, HistoryArray::ItemData* item)
+void vfFile(int, TemplateVars *vars, MCONTACT, HistoryArray::ItemData *item)
{
// %M: the message string itself
TplSetVar(vars, 'M', item->getTBuf(), false);
}
-void vfUrl(int, TemplateVars* vars, MCONTACT, HistoryArray::ItemData* item)
+void vfUrl(int, TemplateVars *vars, MCONTACT, HistoryArray::ItemData *item)
{
// %M: the message string itself
TplSetVar(vars, 'M', item->getTBuf(), false);
}
-void vfSign(int, TemplateVars* vars, MCONTACT, HistoryArray::ItemData* item)
+void vfSign(int, TemplateVars *vars, MCONTACT, HistoryArray::ItemData *item)
{
// %M: the message string itself
TplSetVar(vars, 'M', item->getTBuf(), false);
}
-void vfAuth(int, TemplateVars* vars, MCONTACT, HistoryArray::ItemData* item)
+void vfAuth(int, TemplateVars *vars, MCONTACT, HistoryArray::ItemData *item)
{
// %M: the message string itself
TplSetVar(vars, 'M', item->getTBuf(), false);
}
-void vfAdded(int, TemplateVars* vars, MCONTACT, HistoryArray::ItemData* item)
+void vfAdded(int, TemplateVars *vars, MCONTACT, HistoryArray::ItemData *item)
{
// %M: the message string itself
TplSetVar(vars, 'M', item->getTBuf(), false);
}
-void vfDeleted(int, TemplateVars* vars, MCONTACT, HistoryArray::ItemData* item)
+void vfDeleted(int, TemplateVars *vars, MCONTACT, HistoryArray::ItemData *item)
{
// %M: the message string itself
TplSetVar(vars, 'M', item->getTBuf(), false);
}
-void vfOther(int, TemplateVars* vars, MCONTACT, HistoryArray::ItemData*)
+void vfOther(int, TemplateVars *vars, MCONTACT, HistoryArray::ItemData *)
{
// %M: the message string itself
TplSetVar(vars, 'M', L"Unknown Event", false);
}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+
+TemplateInfo templates[TPL_COUNT] =
+{
+ { "tpl/interface/title", L"Interface", ICO_NEWSTORY, L"Window Title",
+ L"%N's Newstory [%c messages total]", 0, 0,
+ { vfGlobal, vfContact, 0, 0, 0 } },
+
+ { "tpl/msglog/msg", L"Message Log", ICO_SENDMSG, L"Messages",
+ L"%I%i[b]%N, %t:[/b]\x0d\x0a%M", 0, 0,
+ { vfGlobal, vfContact, vfEvent, vfMessage, 0 } },
+ { "tpl/msglog/file", L"Message Log", ICO_FILE, L"Files",
+ L"%I%i[b]%N, %t:[/b]%n%M", 0, 0,
+ { vfGlobal, vfContact, vfEvent, vfFile, 0 } },
+ { "tpl/msglog/status", L"Message Log", ICO_SIGNIN, L"Status Changes",
+ L"%I%i[b]%N, %t:[/b]%n%M", 0, 0,
+ { vfGlobal, vfContact, vfEvent, vfSign, 0 } },
+ { "tpl/msglog/other", L"Message Log", ICO_UNKNOWN, L"Other Events",
+ L"%I%i[b]%N, %t:[/b]%n%M", 0, 0,
+ { vfGlobal, vfContact, vfEvent, vfOther, 0 } },
+
+ { "tpl/msglog/authrq", L"Message Log", ICO_UNKNOWN, L"Authorization Requests",
+ L"%I%i[b]%N, %t:[/b]%n%M", 0, 0,
+ { vfGlobal, vfEvent, vfSystem, vfAuth, 0 } },
+ { "tpl/msglog/added", L"Message Log", ICO_UNKNOWN, L"'You were added' events",
+ L"%I%i[b]%N, %t:[/b]%n%M", 0, 0,
+ { vfGlobal, vfEvent, vfSystem, vfAdded, 0 } },
+ { "tpl/msglog/deleted", L"Message Log", ICO_UNKNOWN, L"'You were deleted' events",
+ L"%I%i[b]%N, %t:[/b]%n%M", 0, 0,
+ { vfGlobal, vfEvent, vfSystem, vfDeleted, 0 } },
+
+ { "tpl/copy/msg", L"Clipboard", ICO_SENDMSG, L"Messages",
+ L"%N, %t:\x0d\x0a%M%n", 0, 0,
+ { vfGlobal, vfContact, vfEvent, vfMessage, 0 } },
+ { "tpl/copy/file", L"Clipboard", ICO_FILE, L"Files",
+ L"%N, %t:\x0d\x0a%M%n", 0, 0,
+ { vfGlobal, vfContact, vfEvent, vfFile, 0 } },
+ { "tpl/copy/url", L"Clipboard", ICO_URL, L"URLs",
+ L"%N, %t:\x0d\x0a%M%n", 0, 0,
+ { vfGlobal, vfContact, vfEvent, vfUrl, 0 } },
+ { "tpl/copy/status", L"Clipboard", ICO_SIGNIN, L"Status Changes",
+ L"%N, %t:\x0d\x0a%M%n", 0, 0,
+ { vfGlobal, vfContact, vfEvent, vfSign, 0 } },
+ { "tpl/copy/other", L"Clipboard", ICO_UNKNOWN, L"Other Events",
+ L"%N, %t:\x0d\x0a%M%n", 0, 0,
+ { vfGlobal, vfContact, vfEvent, vfOther, 0 } },
+
+ { "tpl/copy/authrq", L"Clipboard", ICO_UNKNOWN, L"Authorization Requests",
+ L"%N, %t:\x0d\x0a%M%n", 0, 0,
+ { vfGlobal, vfEvent, vfSystem, vfAuth, 0 } },
+ { "tpl/copy/added", L"Clipboard", ICO_UNKNOWN, L"'You were added' events",
+ L"%N, %t:\x0d\x0a%M%n", 0, 0,
+ { vfGlobal, vfEvent, vfSystem, vfAdded, 0 } },
+ { "tpl/copy/deleted", L"Clipboard", ICO_UNKNOWN, L"'You were deleted' events",
+ L"%N, %t:\x0d\x0a%M%n", 0, 0,
+ { vfGlobal, vfEvent, vfSystem, vfDeleted, 0 } }
+};
+
+void LoadTemplates()
+{
+ for (int i = 0; i < TPL_COUNT; i++) {
+ DBVARIANT dbv = { 0 };
+ db_get_ws(0, MODULENAME, templates[i].setting, &dbv);
+ if (templates[i].value)
+ mir_free(templates[i].value);
+ if (dbv.pwszVal) {
+ templates[i].value = mir_wstrdup(dbv.pwszVal);
+ }
+ else {
+ templates[i].value = 0;
+ }
+ db_free(&dbv);
+ }
+}
+
+void SaveTemplates()
+{
+ for (auto &it : templates)
+ if (it.value)
+ db_set_ws(0, MODULENAME, it.setting, it.value);
+}
diff --git a/plugins/NewStory/src/utils.cpp b/plugins/NewStory/src/utils.cpp
index fc73af9a17..e3bea2beeb 100644
--- a/plugins/NewStory/src/utils.cpp
+++ b/plugins/NewStory/src/utils.cpp
@@ -7,23 +7,23 @@ DWORD toggleBit(DWORD dw, DWORD bit)
return dw | bit;
}
-bool CheckFilter(wchar_t* buf, wchar_t* filter)
+bool CheckFilter(wchar_t *buf, wchar_t *filter)
{
// MessageBox(0, buf, filter, MB_OK);
- int l1 = mir_wstrlen(buf);
- int l2 = mir_wstrlen(filter);
+ int l1 = (int)mir_wstrlen(buf);
+ int l2 = (int)mir_wstrlen(filter);
for (int i = 0; i < l1 - l2 + 1; i++)
if (CompareString(LOCALE_USER_DEFAULT, NORM_IGNORECASE, buf + i, l2, filter, l2) == CSTR_EQUAL)
return true;
return false;
}
-void CopyText(HWND hwnd, wchar_t* text)
+void CopyText(HWND hwnd, const wchar_t *text)
{
OpenClipboard(hwnd);
EmptyClipboard();
- HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, sizeof(wchar_t) * (mir_wstrlen(text) + 1));
- wchar_t* s = (wchar_t*)GlobalLock(hMem);
+ HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, sizeof(wchar_t) * (int)(mir_wstrlen(text) + 1));
+ wchar_t *s = (wchar_t *)GlobalLock(hMem);
mir_wstrcpy(s, text);
GlobalUnlock(hMem);
#ifdef UNICODE
@@ -204,37 +204,3 @@ void CopyText(HWND hwnd, wchar_t* text)
free(tEnd);
}*/
-
-char* appendString(char* s1, char* s2)
-{
- if (s1) {
- int l1 = mir_strlen(s1);
- int l2 = mir_strlen(s2);
- char* buf = (char*)mir_alloc(l1 + l2 + 1);
- mir_snprintf(buf, l1 + l2 + 1, "%s%s", s1, s2);
- mir_free(s1);
- return buf;
- }
- else {
- char* buf = (char*)mir_alloc(mir_strlen(s2) + 1);
- mir_strcpy(buf, s2);
- return buf;
- }
-}
-
-wchar_t* appendString(wchar_t* s1, wchar_t* s2)
-{
- if (s1) {
- int l1 = mir_wstrlen(s1);
- int l2 = mir_wstrlen(s2);
- wchar_t* buf = (wchar_t*)mir_alloc(sizeof(wchar_t) * (l1 + l2 + 1));
- mir_snwprintf(buf, l1 + l2 + 1, L"%s%s", s1, s2);
- mir_free(s1);
- return buf;
- }
- else {
- wchar_t* buf = (wchar_t*)mir_alloc(sizeof(wchar_t) * (mir_wstrlen(s2) + 1));
- mir_wstrcpy(buf, s2);
- return buf;
- }
-}
diff --git a/plugins/NewStory/src/utils.h b/plugins/NewStory/src/utils.h
index f5b787e23c..47fd360d6f 100644
--- a/plugins/NewStory/src/utils.h
+++ b/plugins/NewStory/src/utils.h
@@ -1,8 +1,5 @@
DWORD toggleBit(DWORD dw, DWORD bit);
-bool CheckFilter(wchar_t* buf, wchar_t* filter);
+bool CheckFilter(wchar_t *buf, wchar_t *filter);
-void CopyText(HWND hwnd, wchar_t* text);
-void ExportHistory(HANDLE hContact, char* fnTemplate, char* fn, HWND hwndList);
-
-char* appendString(char* s1, char* s2);
-wchar_t* appendString(wchar_t* s1, wchar_t* s2);
+void CopyText(HWND hwnd, const wchar_t *text);
+void ExportHistory(HANDLE hContact, char *fnTemplate, char *fn, HWND hwndList);