summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-09-13 19:45:47 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-09-13 19:45:47 +0000
commitfd748a24ce28cbafa4c4417878751a8f0884d111 (patch)
tree853fd8ad0f471b968f50f2d299cb1f674feff161
parenta6adee75cb2203221213268847f08006107fe2c9 (diff)
code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@10442 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--plugins/TabSRMM/src/generic_msghandlers.cpp6
-rw-r--r--plugins/TabSRMM/src/infopanel.cpp4
-rw-r--r--plugins/TabSRMM/src/msgdialog.cpp236
-rw-r--r--plugins/TabSRMM/src/msgdlgutils.cpp118
-rw-r--r--plugins/TabSRMM/src/sendlater.cpp4
-rw-r--r--plugins/TabSRMM/src/utils.cpp293
-rw-r--r--plugins/TabSRMM/src/utils.h59
-rw-r--r--plugins/TabSRMM/src/version.h2
8 files changed, 349 insertions, 373 deletions
diff --git a/plugins/TabSRMM/src/generic_msghandlers.cpp b/plugins/TabSRMM/src/generic_msghandlers.cpp
index 40b5ad4a0f..61f93fc7ba 100644
--- a/plugins/TabSRMM/src/generic_msghandlers.cpp
+++ b/plugins/TabSRMM/src/generic_msghandlers.cpp
@@ -1110,16 +1110,14 @@ LRESULT TSAPI DM_WMCopyHandler(HWND hwnd, WNDPROC oldWndProc, UINT msg, WPARAM w
if (OpenClipboard(hwnd)) {
HANDLE hClip = GetClipboardData(CF_UNICODETEXT);
if (hClip) {
- HGLOBAL hgbl;
- TCHAR *tszLocked;
TCHAR *tszText = (TCHAR*)mir_alloc((lstrlen((TCHAR*)hClip) + 2) * sizeof(TCHAR));
lstrcpy(tszText, (TCHAR*)hClip);
Utils::FilterEventMarkers(tszText);
EmptyClipboard();
- hgbl = GlobalAlloc(GMEM_MOVEABLE, (lstrlen(tszText) + 1) * sizeof(TCHAR));
- tszLocked = (TCHAR*)GlobalLock(hgbl);
+ HGLOBAL hgbl = GlobalAlloc(GMEM_MOVEABLE, (lstrlen(tszText) + 1) * sizeof(TCHAR));
+ TCHAR *tszLocked = (TCHAR*)GlobalLock(hgbl);
lstrcpy(tszLocked, tszText);
GlobalUnlock(hgbl);
SetClipboardData(CF_UNICODETEXT, hgbl);
diff --git a/plugins/TabSRMM/src/infopanel.cpp b/plugins/TabSRMM/src/infopanel.cpp
index 4899a93deb..30fafd3cd5 100644
--- a/plugins/TabSRMM/src/infopanel.cpp
+++ b/plugins/TabSRMM/src/infopanel.cpp
@@ -770,11 +770,11 @@ LRESULT CInfoPanel::cmdHandler(UINT cmd)
switch (cmd) {
case CMD_IP_COPY:
if (m_hoverFlags & HOVER_NICK) {
- Utils::CopyToClipBoard(const_cast<wchar_t *>(m_dat->cache->getNick()), m_dat->hwnd);
+ Utils::CopyToClipBoard(m_dat->cache->getNick(), m_dat->hwnd);
return(S_OK);
}
if (m_hoverFlags & HOVER_UIN) {
- Utils::CopyToClipBoard(m_isChat ? m_dat->si->ptszTopic : const_cast<wchar_t *>(m_dat->cache->getUIN()), m_dat->hwnd);
+ Utils::CopyToClipBoard(m_isChat ? m_dat->si->ptszTopic : m_dat->cache->getUIN(), m_dat->hwnd);
return(S_OK);
}
break;
diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp
index 68b285ef28..85931cb996 100644
--- a/plugins/TabSRMM/src/msgdialog.cpp
+++ b/plugins/TabSRMM/src/msgdialog.cpp
@@ -559,6 +559,7 @@ static LRESULT CALLBACK MessageLogSubclassProc(HWND hwnd, UINT msg, WPARAM wPara
static LRESULT CALLBACK MessageEditSubclassProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
+ BOOL isCtrl, isShift, isAlt;
HWND hwndParent = GetParent(hwnd);
TWindowData *mwdat = (TWindowData*)GetWindowLongPtr(hwndParent, GWLP_USERDATA);
if (mwdat == NULL)
@@ -587,32 +588,28 @@ static LRESULT CALLBACK MessageEditSubclassProc(HWND hwnd, UINT msg, WPARAM wPar
break;
case WM_CHAR:
- {
- BOOL isCtrl, isShift, isAlt;
- KbdState(mwdat, isShift, isCtrl, isAlt);
+ KbdState(mwdat, isShift, isCtrl, isAlt);
- if (PluginConfig.g_bSoundOnTyping && !isAlt && !isCtrl && !(mwdat->pContainer->dwFlags & CNT_NOSOUND) && wParam != VK_ESCAPE && !(wParam == VK_TAB && PluginConfig.m_AllowTab))
- SkinPlaySound("SoundOnTyping");
+ if (PluginConfig.g_bSoundOnTyping && !isAlt && !isCtrl && !(mwdat->pContainer->dwFlags & CNT_NOSOUND) && wParam != VK_ESCAPE && !(wParam == VK_TAB && PluginConfig.m_AllowTab))
+ SkinPlaySound("SoundOnTyping");
- if (isCtrl && !isAlt) {
- switch (wParam) {
- case 0x02: // bold
- if (mwdat->SendFormat)
- SendMessage(hwndParent, WM_COMMAND, MAKELONG(IDC_FONTBOLD, IDC_MESSAGE), 0);
- return 0;
- case 0x09:
- if (mwdat->SendFormat)
- SendMessage(hwndParent, WM_COMMAND, MAKELONG(IDC_FONTITALIC, IDC_MESSAGE), 0);
- return 0;
- case 21:
- if (mwdat->SendFormat)
- SendMessage(hwndParent, WM_COMMAND, MAKELONG(IDC_FONTUNDERLINE, IDC_MESSAGE), 0);
- return 0;
- case 0x0b:
- SetWindowText(hwnd, _T(""));
- return 0;
- }
- break;
+ if (isCtrl && !isAlt) {
+ switch (wParam) {
+ case 0x02: // bold
+ if (mwdat->SendFormat)
+ SendMessage(hwndParent, WM_COMMAND, MAKELONG(IDC_FONTBOLD, IDC_MESSAGE), 0);
+ return 0;
+ case 0x09:
+ if (mwdat->SendFormat)
+ SendMessage(hwndParent, WM_COMMAND, MAKELONG(IDC_FONTITALIC, IDC_MESSAGE), 0);
+ return 0;
+ case 21:
+ if (mwdat->SendFormat)
+ SendMessage(hwndParent, WM_COMMAND, MAKELONG(IDC_FONTUNDERLINE, IDC_MESSAGE), 0);
+ return 0;
+ case 0x0b:
+ SetWindowText(hwnd, _T(""));
+ return 0;
}
}
break;
@@ -625,9 +622,9 @@ static LRESULT CALLBACK MessageEditSubclassProc(HWND hwnd, UINT msg, WPARAM wPar
case WM_PASTE:
case EM_PASTESPECIAL:
if (OpenClipboard(hwnd)) {
- HANDLE hClip;
- if (hClip = GetClipboardData(CF_TEXT)) {
- if (lstrlenA((char *)hClip) > mwdat->nMax) {
+ HANDLE hClip = GetClipboardData(CF_TEXT);
+ if (hClip) {
+ if (lstrlenA((char*)hClip) > mwdat->nMax) {
TCHAR szBuffer[512];
if (M.GetByte("autosplit", 0))
mir_sntprintf(szBuffer, SIZEOF(szBuffer), TranslateT("WARNING: The message you are trying to paste exceeds the message size limit for the active protocol. It will be sent in chunks of max %d characters"), mwdat->nMax - 10);
@@ -644,104 +641,101 @@ static LRESULT CALLBACK MessageEditSubclassProc(HWND hwnd, UINT msg, WPARAM wPar
break;
case WM_KEYDOWN:
- {
- BOOL isCtrl, isShift, isAlt;
- KbdState(mwdat, isShift, isCtrl, isAlt);
-
- if (PluginConfig.g_bSoundOnTyping && !isAlt && !(mwdat->pContainer->dwFlags & CNT_NOSOUND) && wParam == VK_DELETE)
- SkinPlaySound("SoundOnTyping");
+ KbdState(mwdat, isShift, isCtrl, isAlt);
- if (wParam == VK_INSERT && !isShift && !isCtrl && !isAlt) {
- mwdat->fInsertMode = !mwdat->fInsertMode;
- SendMessage(hwndParent, WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(hwnd), EN_CHANGE), (LPARAM)hwnd);
- }
- if (wParam == VK_CAPITAL || wParam == VK_NUMLOCK)
- SendMessage(hwndParent, WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(hwnd), EN_CHANGE), (LPARAM)hwnd);
+ if (PluginConfig.g_bSoundOnTyping && !isAlt && !(mwdat->pContainer->dwFlags & CNT_NOSOUND) && wParam == VK_DELETE)
+ SkinPlaySound("SoundOnTyping");
- if (wParam == VK_RETURN) {
- if (mwdat->fEditNotesActive)
- break;
+ if (wParam == VK_INSERT && !isShift && !isCtrl && !isAlt) {
+ mwdat->fInsertMode = !mwdat->fInsertMode;
+ SendMessage(hwndParent, WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(hwnd), EN_CHANGE), (LPARAM)hwnd);
+ }
+ if (wParam == VK_CAPITAL || wParam == VK_NUMLOCK)
+ SendMessage(hwndParent, WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(hwnd), EN_CHANGE), (LPARAM)hwnd);
- if (isShift) {
- if (PluginConfig.m_SendOnShiftEnter) {
- PostMessage(hwndParent, WM_COMMAND, IDOK, 0);
- return 0;
- }
- else break;
- }
- if ((isCtrl && !isShift) ^ (0 != PluginConfig.m_SendOnEnter)) {
- PostMessage(hwndParent, WM_COMMAND, IDOK, 0);
- return 0;
- }
- if (PluginConfig.m_SendOnEnter || PluginConfig.m_SendOnDblEnter) {
- if (isCtrl)
- break;
+ if (wParam == VK_RETURN) {
+ if (mwdat->fEditNotesActive)
+ break;
- if (PluginConfig.m_SendOnDblEnter) {
- LONG_PTR lastEnterTime = GetWindowLongPtr(hwnd, GWLP_USERDATA);
- if (lastEnterTime + 2 < time(NULL)) {
- lastEnterTime = time(NULL);
- SetWindowLongPtr(hwnd, GWLP_USERDATA, lastEnterTime);
- break;
- }
- else {
- SendMessage(hwnd, WM_KEYDOWN, VK_BACK, 0);
- SendMessage(hwnd, WM_KEYUP, VK_BACK, 0);
- PostMessage(hwndParent, WM_COMMAND, IDOK, 0);
- return 0;
- }
- }
+ if (isShift) {
+ if (PluginConfig.m_SendOnShiftEnter) {
PostMessage(hwndParent, WM_COMMAND, IDOK, 0);
return 0;
}
else break;
}
- else SetWindowLongPtr(hwnd, GWLP_USERDATA, 0);
-
- if (isCtrl && !isAlt && !isShift) {
- if (!isShift && (wParam == VK_UP || wParam == VK_DOWN)) { // input history scrolling (ctrl-up / down)
- SetWindowLongPtr(hwnd, GWLP_USERDATA, 0);
- if (mwdat)
- mwdat->cache->inputHistoryEvent(wParam);
- return 0;
- }
+ if ((isCtrl && !isShift) ^ (0 != PluginConfig.m_SendOnEnter)) {
+ PostMessage(hwndParent, WM_COMMAND, IDOK, 0);
+ return 0;
}
- if (isCtrl && isAlt && !isShift) {
- switch (wParam) {
- case VK_UP:
- case VK_DOWN:
- case VK_PRIOR:
- case VK_NEXT:
- case VK_HOME:
- case VK_END:
- WPARAM wp = 0;
-
- SetWindowLongPtr(hwnd, GWLP_USERDATA, 0);
- if (wParam == VK_UP)
- wp = MAKEWPARAM(SB_LINEUP, 0);
- else if (wParam == VK_PRIOR)
- wp = MAKEWPARAM(SB_PAGEUP, 0);
- else if (wParam == VK_NEXT)
- wp = MAKEWPARAM(SB_PAGEDOWN, 0);
- else if (wParam == VK_HOME)
- wp = MAKEWPARAM(SB_TOP, 0);
- else if (wParam == VK_END) {
- DM_ScrollToBottom(mwdat, 0, 0);
+ if (PluginConfig.m_SendOnEnter || PluginConfig.m_SendOnDblEnter) {
+ if (isCtrl)
+ break;
+
+ if (PluginConfig.m_SendOnDblEnter) {
+ LONG_PTR lastEnterTime = GetWindowLongPtr(hwnd, GWLP_USERDATA);
+ if (lastEnterTime + 2 < time(NULL)) {
+ lastEnterTime = time(NULL);
+ SetWindowLongPtr(hwnd, GWLP_USERDATA, lastEnterTime);
+ break;
+ }
+ else {
+ SendMessage(hwnd, WM_KEYDOWN, VK_BACK, 0);
+ SendMessage(hwnd, WM_KEYUP, VK_BACK, 0);
+ PostMessage(hwndParent, WM_COMMAND, IDOK, 0);
return 0;
}
- else if (wParam == VK_DOWN)
- wp = MAKEWPARAM(SB_LINEDOWN, 0);
+ }
+ PostMessage(hwndParent, WM_COMMAND, IDOK, 0);
+ return 0;
+ }
+ else break;
+ }
+ else SetWindowLongPtr(hwnd, GWLP_USERDATA, 0);
- if (mwdat->hwndIEView == 0 && mwdat->hwndHPP == 0)
- SendMessage(GetDlgItem(hwndParent, IDC_LOG), WM_VSCROLL, wp, 0);
- else
- SendMessage(mwdat->hwndIWebBrowserControl, WM_VSCROLL, wp, 0);
+ if (isCtrl && !isAlt && !isShift) {
+ if (!isShift && (wParam == VK_UP || wParam == VK_DOWN)) { // input history scrolling (ctrl-up / down)
+ SetWindowLongPtr(hwnd, GWLP_USERDATA, 0);
+ if (mwdat)
+ mwdat->cache->inputHistoryEvent(wParam);
+ return 0;
+ }
+ }
+ if (isCtrl && isAlt && !isShift) {
+ switch (wParam) {
+ case VK_UP:
+ case VK_DOWN:
+ case VK_PRIOR:
+ case VK_NEXT:
+ case VK_HOME:
+ case VK_END:
+ WPARAM wp = 0;
+
+ SetWindowLongPtr(hwnd, GWLP_USERDATA, 0);
+ if (wParam == VK_UP)
+ wp = MAKEWPARAM(SB_LINEUP, 0);
+ else if (wParam == VK_PRIOR)
+ wp = MAKEWPARAM(SB_PAGEUP, 0);
+ else if (wParam == VK_NEXT)
+ wp = MAKEWPARAM(SB_PAGEDOWN, 0);
+ else if (wParam == VK_HOME)
+ wp = MAKEWPARAM(SB_TOP, 0);
+ else if (wParam == VK_END) {
+ DM_ScrollToBottom(mwdat, 0, 0);
return 0;
}
+ else if (wParam == VK_DOWN)
+ wp = MAKEWPARAM(SB_LINEDOWN, 0);
+
+ if (mwdat->hwndIEView == 0 && mwdat->hwndHPP == 0)
+ SendMessage(GetDlgItem(hwndParent, IDC_LOG), WM_VSCROLL, wp, 0);
+ else
+ SendMessage(mwdat->hwndIWebBrowserControl, WM_VSCROLL, wp, 0);
+ return 0;
}
- if (wParam == VK_RETURN)
- break;
}
+ if (wParam == VK_RETURN)
+ break;
case WM_SYSKEYDOWN:
mwdat->fkeyProcessed = false;
@@ -763,22 +757,18 @@ static LRESULT CALLBACK MessageEditSubclassProc(HWND hwnd, UINT msg, WPARAM wPar
mwdat->fkeyProcessed = false;
return 0;
}
- {
- HWND hwndDlg = hwndParent;
- BOOL isCtrl, isShift, isAlt;
- KbdState(mwdat, isShift, isCtrl, isAlt);
- if ((wParam >= '0' && wParam <= '9') && isAlt) { // ALT-1 -> ALT-0 direct tab selection
- BYTE bChar = (BYTE)wParam;
- int iIndex;
+ KbdState(mwdat, isShift, isCtrl, isAlt);
+ if ((wParam >= '0' && wParam <= '9') && isAlt) { // ALT-1 -> ALT-0 direct tab selection
+ BYTE bChar = (BYTE)wParam;
+ int iIndex;
- if (bChar == '0')
- iIndex = 10;
- else
- iIndex = bChar - (BYTE)'0';
- SendMessage(mwdat->pContainer->hwnd, DM_SELECTTAB, DM_SELECT_BY_INDEX, (LPARAM)iIndex);
- return 0;
- }
+ if (bChar == '0')
+ iIndex = 10;
+ else
+ iIndex = bChar - (BYTE)'0';
+ SendMessage(mwdat->pContainer->hwnd, DM_SELECTTAB, DM_SELECT_BY_INDEX, (LPARAM)iIndex);
+ return 0;
}
break;
@@ -3042,7 +3032,7 @@ quote_from_last:
return 0;
case DM_UINTOCLIPBOARD:
- Utils::CopyToClipBoard(const_cast<TCHAR *>(dat->cache->getUIN()), hwndDlg);
+ Utils::CopyToClipBoard(dat->cache->getUIN(), hwndDlg);
return 0;
// broadcasted when GLOBAL info panel setting changes
diff --git a/plugins/TabSRMM/src/msgdlgutils.cpp b/plugins/TabSRMM/src/msgdlgutils.cpp
index a6bed193e1..9ab8640666 100644
--- a/plugins/TabSRMM/src/msgdlgutils.cpp
+++ b/plugins/TabSRMM/src/msgdlgutils.cpp
@@ -858,7 +858,9 @@ char* TSAPI Message_GetFromStream(HWND hwndRtf, const TWindowData *dat, DWORD dw
// convert rich edit code to bbcode (if wanted). Otherwise, strip all RTF formatting
// tags and return plain text
-BOOL TSAPI DoRtfToTags(TCHAR * pszText, const TWindowData *dat)
+#define SETCHAR(c) InsertThis[0]=c; InsertThis[1]=0;
+
+BOOL TSAPI DoRtfToTags(TCHAR *pszText, const TWindowData *dat)
{
BOOL bJustRemovedRTF = TRUE;
BOOL bTextHasStarted = FALSE;
@@ -888,13 +890,13 @@ BOOL TSAPI DoRtfToTags(TCHAR * pszText, const TWindowData *dat)
MoveMemory(pszText, p1, (lstrlen(p1) + 1) * sizeof(TCHAR));
p1 = pszText;
// iterate through all characters, if rtf control character found then take action
- while (*p1 != (TCHAR) '\0') {
+ while (*p1 != '\0') {
mir_sntprintf(InsertThis, SIZEOF(InsertThis), _T(""));
iRemoveChars = 0;
switch (*p1) {
- case (TCHAR) '\\':
- if (p1 == _tcsstr(p1, _T("\\cf"))) { // foreground color
+ case '\\':
+ if (!_tcsncmp(p1, _T("\\cf"), 3)) { // foreground color
TCHAR szTemp[20];
int iCol = _ttoi(p1 + 3);
int iInd = Utils::RTFColorToIndex(iCol);
@@ -906,7 +908,7 @@ BOOL TSAPI DoRtfToTags(TCHAR * pszText, const TWindowData *dat)
mir_sntprintf(InsertThis, SIZEOF(InsertThis), (iInd > 0) ? (inColor ? _T("[/color][color=%s]") : _T("[color=%s]")) : (inColor ? _T("[/color]") : _T("")), Utils::rtf_ctable[iInd - 1].szName);
inColor = iInd > 0 ? 1 : 0;
}
- else if (p1 == _tcsstr(p1, _T("\\highlight"))) { //background color
+ else if (!_tcsncmp(p1, _T("\\highlight"), 10)) { //background color
TCHAR szTemp[20];
int iCol = _ttoi(p1 + 10);
bJustRemovedRTF = TRUE;
@@ -914,120 +916,123 @@ BOOL TSAPI DoRtfToTags(TCHAR * pszText, const TWindowData *dat)
mir_sntprintf(szTemp, SIZEOF(szTemp), _T("%d"), iCol);
iRemoveChars = 10 + lstrlen(szTemp);
}
- else if (p1 == _tcsstr(p1, _T("\\par"))) { // newline
+ else if (!_tcsncmp(p1, _T("\\par"), 4)) { // newline
bTextHasStarted = TRUE;
bJustRemovedRTF = TRUE;
iRemoveChars = 4;
}
- else if (p1 == _tcsstr(p1, _T("\\line"))) { // soft line break;
+ else if (!_tcsncmp(p1, _T("\\line"), 5)) { // soft line break;
bTextHasStarted = TRUE;
bJustRemovedRTF = TRUE;
iRemoveChars = 5;
- mir_sntprintf(InsertThis, SIZEOF(InsertThis), _T("\n"));
+ SETCHAR('\n');
}
- else if (p1 == _tcsstr(p1, _T("\\endash"))) {
+ else if (!_tcsncmp(p1, _T("\\endash"), 7)) {
bTextHasStarted = bJustRemovedRTF = TRUE;
iRemoveChars = 7;
- mir_sntprintf(InsertThis, SIZEOF(InsertThis), _T("%c"), 0x2013);
+ SETCHAR(0x2013);
}
- else if (p1 == _tcsstr(p1, _T("\\emdash"))) {
+ else if (!_tcsncmp(p1, _T("\\emdash"), 7)) {
bTextHasStarted = TRUE;
bJustRemovedRTF = TRUE;
iRemoveChars = 7;
- mir_sntprintf(InsertThis, SIZEOF(InsertThis), _T("%c"), 0x2014);
+ SETCHAR(0x2014);
}
- else if (p1 == _tcsstr(p1, _T("\\bullet"))) {
+ else if (!_tcsncmp(p1, _T("\\bullet"), 7)) {
bTextHasStarted = TRUE;
bJustRemovedRTF = TRUE;
iRemoveChars = 7;
- mir_sntprintf(InsertThis, SIZEOF(InsertThis), _T("%c"), 0x2022);
+ SETCHAR(0x2022);
}
- else if (p1 == _tcsstr(p1, _T("\\ldblquote"))) {
+ else if (!_tcsncmp(p1, _T("\\ldblquote"), 10)) {
bTextHasStarted = TRUE;
bJustRemovedRTF = TRUE;
iRemoveChars = 10;
- mir_sntprintf(InsertThis, SIZEOF(InsertThis), _T("%c"), 0x201C);
+ SETCHAR(0x201C);
}
- else if (p1 == _tcsstr(p1, _T("\\rdblquote"))) {
+ else if (!_tcsncmp(p1, _T("\\rdblquote"), 10)) {
bTextHasStarted = TRUE;
bJustRemovedRTF = TRUE;
iRemoveChars = 10;
- mir_sntprintf(InsertThis, SIZEOF(InsertThis), _T("%c"), 0x201D);
+ SETCHAR(0x201D);
}
- else if (p1 == _tcsstr(p1, _T("\\lquote"))) {
+ else if (!_tcsncmp(p1, _T("\\lquote"), 7)) {
bTextHasStarted = TRUE;
bJustRemovedRTF = TRUE;
iRemoveChars = 7;
- mir_sntprintf(InsertThis, SIZEOF(InsertThis), _T("%c"), 0x2018);
+ SETCHAR(0x2018);
}
- else if (p1 == _tcsstr(p1, _T("\\rquote"))) {
+ else if (!_tcsncmp(p1, _T("\\rquote"), 7)) {
bTextHasStarted = TRUE;
bJustRemovedRTF = TRUE;
iRemoveChars = 7;
- mir_sntprintf(InsertThis, SIZEOF(InsertThis), _T("%c"), 0x2019);
+ SETCHAR(0x2019);
}
- else if (p1 == _tcsstr(p1, _T("\\b"))) { //bold
+ else if (!_tcsncmp(p1, _T("\\b"), 2)) { //bold
bTextHasStarted = TRUE;
bJustRemovedRTF = TRUE;
- iRemoveChars = (p1[2] != (TCHAR) '0') ? 2 : 3;
+ iRemoveChars = (p1[2] != '0') ? 2 : 3;
if (!(lf.lfWeight == FW_BOLD)) { // only allow bold if the font itself isn't a bold one, otherwise just strip it..
if (dat->SendFormat)
- mir_sntprintf(InsertThis, SIZEOF(InsertThis), (p1[2] != (TCHAR) '0') ? _T("[b]") : _T("[/b]"));
+ mir_sntprintf(InsertThis, SIZEOF(InsertThis), (p1[2] != '0') ? _T("[b]") : _T("[/b]"));
}
}
- else if (p1 == _tcsstr(p1, _T("\\i"))) { // italics
+ else if (!_tcsncmp(p1, _T("\\i"), 2)) { // italics
bTextHasStarted = TRUE;
bJustRemovedRTF = TRUE;
- iRemoveChars = (p1[2] != (TCHAR) '0') ? 2 : 3;
+ iRemoveChars = (p1[2] != '0') ? 2 : 3;
if (!lf.lfItalic) { // same as for bold
if (dat->SendFormat)
- mir_sntprintf(InsertThis, SIZEOF(InsertThis), (p1[2] != (TCHAR) '0') ? _T("[i]") : _T("[/i]"));
+ mir_sntprintf(InsertThis, SIZEOF(InsertThis), (p1[2] != '0') ? _T("[i]") : _T("[/i]"));
}
}
- else if (p1 == _tcsstr(p1, _T("\\strike"))) { // strike-out
+ else if (!_tcsncmp(p1, _T("\\strike"), 7)) { // strike-out
bTextHasStarted = TRUE;
bJustRemovedRTF = TRUE;
- iRemoveChars = (p1[7] != (TCHAR) '0') ? 7 : 8;
+ iRemoveChars = (p1[7] != '0') ? 7 : 8;
if (!lf.lfStrikeOut) { // same as for bold
if (dat->SendFormat)
- mir_sntprintf(InsertThis, SIZEOF(InsertThis), (p1[7] != (TCHAR) '0') ? _T("[s]") : _T("[/s]"));
+ mir_sntprintf(InsertThis, SIZEOF(InsertThis), (p1[7] != '0') ? _T("[s]") : _T("[/s]"));
}
}
- else if (p1 == _tcsstr(p1, _T("\\ul"))) { // underlined
+ else if (!_tcsncmp(p1, _T("\\ul"), 3)) { // underlined
bTextHasStarted = TRUE;
bJustRemovedRTF = TRUE;
- if (p1[3] == (TCHAR) 'n')
+ if (p1[3] == 'n')
iRemoveChars = 7;
- else if (p1[3] == (TCHAR) '0')
+ else if (p1[3] == '0')
iRemoveChars = 4;
else
iRemoveChars = 3;
- if (!lf.lfUnderline) { // same as for bold
+ if (!lf.lfUnderline) // same as for bold
if (dat->SendFormat)
- mir_sntprintf(InsertThis, SIZEOF(InsertThis), (p1[3] != (TCHAR) '0' && p1[3] != (TCHAR) 'n') ? _T("[u]") : _T("[/u]"));
- }
+ mir_sntprintf(InsertThis, SIZEOF(InsertThis), (p1[3] != '0' && p1[3] != 'n') ? _T("[u]") : _T("[/u]"));
}
- else if (p1 == _tcsstr(p1, _T("\\tab"))) { // tab
+ else if (!_tcsncmp(p1, _T("\\tab"), 4)) { // tab
bTextHasStarted = TRUE;
bJustRemovedRTF = TRUE;
iRemoveChars = 4;
- mir_sntprintf(InsertThis, SIZEOF(InsertThis), _T("%c"), 0x09);
+ SETCHAR('\t');
}
- else if (p1[1] == (TCHAR) '\\' || p1[1] == (TCHAR) '{' || p1[1] == (TCHAR) '}') { // escaped characters
+ else if (p1[1] == '\\' || p1[1] == '{' || p1[1] == '}') { // escaped characters
bTextHasStarted = TRUE;
- //bJustRemovedRTF = TRUE;
iRemoveChars = 2;
- mir_sntprintf(InsertThis, SIZEOF(InsertThis), _T("%c"), p1[1]);
+ SETCHAR(p1[1]);
}
- else if (p1[1] == (TCHAR) '\'') { // special character
+ else if (p1[1] == '~') { // non-breaking space
+ bTextHasStarted = TRUE;
+ iRemoveChars = 2;
+ SETCHAR(0xA0);
+ }
+ else if (p1[1] == '\'') { // special character
bTextHasStarted = TRUE;
bJustRemovedRTF = FALSE;
- if (p1[2] != (TCHAR) ' ' && p1[2] != (TCHAR) '\\') {
+ if (p1[2] != ' ' && p1[2] != '\\') {
int iLame = 0;
TCHAR * p3;
TCHAR *stoppedHere;
- if (p1[3] != (TCHAR) ' ' && p1[3] != (TCHAR) '\\') {
+ if (p1[3] != ' ' && p1[3] != '\\') {
_tcsncpy(InsertThis, p1 + 2, 3);
iRemoveChars = 4;
InsertThis[2] = 0;
@@ -1040,27 +1045,25 @@ BOOL TSAPI DoRtfToTags(TCHAR * pszText, const TWindowData *dat)
// convert string containing char in hex format to int.
p3 = InsertThis;
iLame = _tcstol(p3, &stoppedHere, 16);
- mir_sntprintf(InsertThis, SIZEOF(InsertThis), _T("%c"), (TCHAR)iLame);
-
+ SETCHAR(iLame);
}
- else
- iRemoveChars = 2;
+ else iRemoveChars = 2;
}
else { // remove unknown RTF command
int j = 1;
bJustRemovedRTF = TRUE;
- while (!_tcschr(_T(" !$%()#*\"'"), p1[j]) && p1[j] != (TCHAR) '§' && p1[j] != (TCHAR) '\\' && p1[j] != (TCHAR) '\0')
+ while (!_tcschr(_T(" !$%()#*\"'"), p1[j]) && p1[j] != '§' && p1[j] != '\\' && p1[j] != '\0')
j++;
iRemoveChars = j;
}
break;
- case (TCHAR) '{': // other RTF control characters
- case (TCHAR) '}':
+ case '{': // other RTF control characters
+ case '}':
iRemoveChars = 1;
break;
- case (TCHAR) ' ': // remove spaces following a RTF command
+ case ' ': // remove spaces following a RTF command
if (bJustRemovedRTF)
iRemoveChars = 1;
bJustRemovedRTF = FALSE;
@@ -1074,10 +1077,11 @@ BOOL TSAPI DoRtfToTags(TCHAR * pszText, const TWindowData *dat)
}
// move the memory and paste in new commands instead of the old RTF
- if (lstrlen(InsertThis) || iRemoveChars) {
- MoveMemory(p1 + lstrlen(InsertThis), p1 + iRemoveChars, (lstrlen(p1) - iRemoveChars + 1) * sizeof(TCHAR));
- CopyMemory(p1, InsertThis, lstrlen(InsertThis) * sizeof(TCHAR));
- p1 += lstrlen(InsertThis);
+ if (InsertThis[0] || iRemoveChars) {
+ size_t cbLen = _tcslen(InsertThis);
+ MoveMemory(p1 + cbLen, p1 + iRemoveChars, (lstrlen(p1) - iRemoveChars + 1) * sizeof(TCHAR));
+ CopyMemory(p1, InsertThis, cbLen * sizeof(TCHAR));
+ p1 += cbLen;
}
else p1++;
}
diff --git a/plugins/TabSRMM/src/sendlater.cpp b/plugins/TabSRMM/src/sendlater.cpp
index be92ccc2ce..4b064cd43c 100644
--- a/plugins/TabSRMM/src/sendlater.cpp
+++ b/plugins/TabSRMM/src/sendlater.cpp
@@ -818,7 +818,7 @@ INT_PTR CALLBACK CSendLater::DlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
if (!job)
continue;
- switch(HIWORD(wParam)) {
+ switch (HIWORD(wParam)) {
case ID_QUEUEMANAGER_MARKSELECTEDFORREMOVAL:
job->bCode = CSendLaterJob::JOB_REMOVABLE;
job->fFailed = true;
@@ -832,7 +832,7 @@ INT_PTR CALLBACK CSendLater::DlgProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
job->writeFlags();
break;
case ID_QUEUEMANAGER_COPYMESSAGETOCLIPBOARD:
- Utils::CopyToClipBoard((TCHAR*)ptrT( mir_utf8decodeT(job->sendBuffer)), m_hwndDlg);
+ Utils::CopyToClipBoard((TCHAR*)ptrT(mir_utf8decodeT(job->sendBuffer)), m_hwndDlg);
break;
case ID_QUEUEMANAGER_RESETSELECTED:
if (job->bCode == CSendLaterJob::JOB_DEFERRED) {
diff --git a/plugins/TabSRMM/src/utils.cpp b/plugins/TabSRMM/src/utils.cpp
index ec6609ee52..62c99da38c 100644
--- a/plugins/TabSRMM/src/utils.cpp
+++ b/plugins/TabSRMM/src/utils.cpp
@@ -68,7 +68,6 @@ TCHAR* Utils::FilterEventMarkers(TCHAR *wszText)
}
break;
}
- //mad
while (true) {
if ((beginmark = text.find( _T("\xAA"))) != text.npos) {
@@ -86,11 +85,10 @@ TCHAR* Utils::FilterEventMarkers(TCHAR *wszText)
return wszText;
}
-/**
-* this translates formatting tags into rtf sequences...
-* flags: loword = words only for simple * /_ formatting
-* hiword = bbcode support (strip bbcodes if 0)
-*/
+/////////////////////////////////////////////////////////////////////////////////////////
+// this translates formatting tags into rtf sequences...
+// flags: loword = words only for simple * /_ formatting
+// hiword = bbcode support (strip bbcodes if 0)
const TCHAR* Utils::FormatRaw(TWindowData *dat, const TCHAR *msg, int flags, BOOL isSent)
{
@@ -195,6 +193,7 @@ invalid_code:
beginmark++;
continue;
}
+
// search a corresponding endmarker which fulfills the criteria
INT_PTR tempmark = beginmark + 1;
while ((endmark = message.find(endmarker, tempmark)) != message.npos) {
@@ -226,11 +225,8 @@ ok:
break;
}
- /*
- * check if the code enclosed by simple formatting tags is a valid smiley code and skip formatting if
- * it really is one.
- */
-
+ // check if the code enclosed by simple formatting tags is a valid smiley code and skip formatting if
+ // it really is one.
if (PluginConfig.g_SmileyAddAvail && (endmark > (beginmark + 1))) {
tstring smcode;
smcode.assign(message, beginmark, (endmark - beginmark) + 1);
@@ -258,10 +254,9 @@ ok:
return(message.c_str());
}
-/**
-* format the title bar string for IM chat sessions using placeholders.
-* the caller must mir_free() the returned string
-*/
+/////////////////////////////////////////////////////////////////////////////////////////
+// format the title bar string for IM chat sessions using placeholders.
+// the caller must mir_free() the returned string
const TCHAR* Utils::FormatTitleBar(const TWindowData *dat, const TCHAR *szFormat)
{
@@ -358,7 +353,6 @@ const TCHAR* Utils::FormatTitleBar(const TWindowData *dat, const TCHAR *szFormat
case 'm': {
TCHAR *szFinalStatus = NULL;
BYTE xStatus = dat->cache->getXStatusId();
-
if (dat->wStatus != ID_STATUS_OFFLINE && xStatus > 0 && xStatus <= 31) {
DBVARIANT dbv = {0};
@@ -380,10 +374,8 @@ const TCHAR* Utils::FormatTitleBar(const TWindowData *dat, const TCHAR *szFormat
title.erase(tempmark, 2);
break;
}
- /*
- * status message (%T will skip the "No status message" for empty
- * messages)
- */
+
+ // status message (%T will skip the "No status message" for empty messages)
case 't':
case 'T': {
TCHAR *tszStatusMsg = dat->cache->getNormalizedStatusMsg(dat->cache->getStatusMsg(), true);
@@ -432,7 +424,7 @@ char* Utils::FilterEventMarkers(char *szText)
}
break;
}
- //mad
+
while (true) {
if ((beginmark = text.find( "\xAA")) != text.npos) {
endmark = beginmark+2;
@@ -468,13 +460,13 @@ const TCHAR* Utils::DoubleAmpersands(TCHAR *pszText)
return pszText;
}
-/**
- * Get a preview of the text with an ellipsis appended (...)
- *
- * @param szText source text
- * @param iMaxLen max length of the preview
- * @return TCHAR* result (caller must mir_free() it)
- */
+/////////////////////////////////////////////////////////////////////////////////////////
+// Get a preview of the text with an ellipsis appended(...)
+//
+// @param szText source text
+// @param iMaxLen max length of the preview
+// @return TCHAR* result (caller must mir_free() it)
+
TCHAR* Utils::GetPreviewWithEllipsis(TCHAR *szText, size_t iMaxLen)
{
size_t uRequired;
@@ -505,10 +497,9 @@ TCHAR* Utils::GetPreviewWithEllipsis(TCHAR *szText, size_t iMaxLen)
return szResult;
}
-/*
- * returns != 0 when one of the installed keyboard layouts belongs to an rtl language
- * used to find out whether we need to configure the message input box for bidirectional mode
- */
+/////////////////////////////////////////////////////////////////////////////////////////
+// returns != 0 when one of the installed keyboard layouts belongs to an rtl language
+// used to find out whether we need to configure the message input box for bidirectional mode
int Utils::FindRTLLocale(TWindowData *dat)
{
@@ -533,9 +524,8 @@ int Utils::FindRTLLocale(TWindowData *dat)
return result;
}
-/*
- * init default color table. the table may grow when using custom colors via bbcodes
- */
+/////////////////////////////////////////////////////////////////////////////////////////
+// init default color table. the table may grow when using custom colors via bbcodes
void Utils::RTF_CTableInit()
{
@@ -547,9 +537,8 @@ void Utils::RTF_CTableInit()
rtf_ctable_size = RTF_CTABLE_DEFSIZE;
}
-/*
- * add a color to the global rtf color table
- */
+/////////////////////////////////////////////////////////////////////////////////////////
+// add a color to the global rtf color table
void Utils::RTF_ColorAdd(const TCHAR *tszColname, size_t length)
{
@@ -612,9 +601,9 @@ int Utils::RTFColorToIndex(int iCol)
return 0;
}
-/**
- * generic error popup dialog procedure
- */
+/////////////////////////////////////////////////////////////////////////////////////////
+// generic error popup dialog procedure
+
INT_PTR CALLBACK Utils::PopupDlgProcError(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
MCONTACT hContact = (MCONTACT)PUGetPluginData(hWnd);
@@ -636,12 +625,12 @@ INT_PTR CALLBACK Utils::PopupDlgProcError(HWND hWnd, UINT message, WPARAM wParam
return DefWindowProc(hWnd, message, wParam, lParam);
}
-/**
- * read a blob from db into the container settings structure
- * @param hContact: contact handle (0 = read global)
- * @param cs TContainerSettings* target structure
- * @return 0 on success, 1 failure (blob does not exist OR is not a valid private setting structure
- */
+/////////////////////////////////////////////////////////////////////////////////////////
+// read a blob from db into the container settings structure
+// @param hContact: contact handle (0 = read global)
+// @param cs TContainerSettings* target structure
+// @return 0 on success, 1 failure (blob does not exist OR is not a valid private setting structure
+
int Utils::ReadContainerSettingsFromDB(const MCONTACT hContact, TContainerSettings *cs, const char *szKey)
{
CopyMemory(cs, &PluginConfig.globalContainerSettings, sizeof(TContainerSettings));
@@ -686,12 +675,12 @@ void Utils::ContainerToSettings(TContainerData *pContainer)
pContainer->settings->ownAvatarMode = pContainer->ownAvatarMode;
}
-/**
- * read settings for a container with private settings enabled.
- *
- * @param pContainer container window info struct
- * @param fForce true -> force them private, even if they were not marked as private in the db
- */
+/////////////////////////////////////////////////////////////////////////////////////////
+// read settings for a container with private settings enabled.
+//
+// @param pContainer container window info struct
+// @param fForce true -> force them private, even if they were not marked as private in the db
+
void Utils::ReadPrivateContainerSettings(TContainerData *pContainer, bool fForce)
{
char szCname[50];
@@ -731,12 +720,12 @@ void Utils::SaveContainerSettings(TContainerData *pContainer, const char *szSett
}
}
-/**
- * calculate new width and height values for a user picture (avatar)
- *
- * @param: maxHeight - determines maximum height for the picture, width will
- * be scaled accordingly.
- */
+/////////////////////////////////////////////////////////////////////////////////////////
+// calculate new width and height values for a user picture (avatar)
+//
+// @param: maxHeight - determines maximum height for the picture, width will
+// be scaled accordingly.
+
void Utils::scaleAvatarHeightLimited(const HBITMAP hBm, double& dNewWidth, double& dNewHeight, LONG maxHeight)
{
BITMAP bm;
@@ -762,13 +751,13 @@ void Utils::scaleAvatarHeightLimited(const HBITMAP hBm, double& dNewWidth, doubl
}
}
-/**
- * convert the avatar bitmap to icon format so that it can be used on the task bar
- * tries to keep correct aspect ratio of the avatar image
- *
- * @param dat: _MessageWindowData* pointer to the window data
- * @return HICON: the icon handle
- */
+/////////////////////////////////////////////////////////////////////////////////////////
+// convert the avatar bitmap to icon format so that it can be used on the task bar
+// tries to keep correct aspect ratio of the avatar image
+//
+// @param dat: _MessageWindowData* pointer to the window data
+// @return HICON: the icon handle
+
HICON Utils::iconFromAvatar(const TWindowData *dat)
{
if (!ServiceExists(MS_AV_GETAVATARBITMAP) || dat == NULL)
@@ -781,11 +770,9 @@ HICON Utils::iconFromAvatar(const TWindowData *dat)
LONG lIconSize = Win7Taskbar->getIconSize();
double dNewWidth, dNewHeight;
scaleAvatarHeightLimited(ace->hbmPic, dNewWidth, dNewHeight, lIconSize);
- /*
- * resize picture to fit it on the task bar, use an image list for converting it to
- * 32bpp icon format
- * dat->hTaskbarIcon will cache it until avatar is changed
- */
+
+ // resize picture to fit it on the task bar, use an image list for converting it to
+ // 32bpp icon format. dat->hTaskbarIcon will cache it until avatar is changed
bool fFree = false;
HBITMAP hbmResized = CSkin::ResizeBitmap(ace->hbmPic, (LONG)dNewWidth, (LONG)dNewHeight, fFree);
HIMAGELIST hIml_c = ::ImageList_Create(lIconSize, lIconSize, ILC_COLOR32 | ILC_MASK, 1, 0);
@@ -850,16 +837,16 @@ void Utils::getIconSize(HICON hIcon, int& sizeX, int& sizeY)
::DeleteObject(ii.hbmColor);
}
-/**
- * add a menu item to a ownerdrawn menu. mii must be pre-initialized
- *
- * @param m menu handle
- * @param mii menu item info structure
- * @param hIcon the icon (0 allowed -> no icon)
- * @param szText menu item text (must NOT be 0)
- * @param uID the item command id
- * @param pos zero-based position index
- */
+/////////////////////////////////////////////////////////////////////////////////////////
+// add a menu item to a ownerdrawn menu. mii must be pre-initialized
+//
+// @param m menu handle
+// @param mii menu item info structure
+// @param hIcon the icon (0 allowed -> no icon)
+// @param szText menu item text (must NOT be 0)
+// @param uID the item command id
+// @param pos zero-based position index
+
void Utils::addMenuItem(const HMENU& m, MENUITEMINFO& mii, HICON hIcon, const TCHAR *szText, UINT uID, UINT pos)
{
mii.wID = uID;
@@ -870,10 +857,10 @@ void Utils::addMenuItem(const HMENU& m, MENUITEMINFO& mii, HICON hIcon, const TC
::InsertMenuItem(m, pos, TRUE, &mii);
}
-/**
- * return != 0 when the sound effect must be played for the given
- * session. Uses container sound settings
- */
+/////////////////////////////////////////////////////////////////////////////////////////
+// return != 0 when the sound effect must be played for the given
+// session. Uses container sound settings
+
int Utils::mustPlaySound(const TWindowData *dat)
{
if (!dat)
@@ -889,15 +876,11 @@ int Utils::mustPlaySound(const TWindowData *dat)
bool fActiveTab = (dat->pContainer->hwndActive == dat->hwnd ? true : false);
bool fIconic = (::IsIconic(dat->pContainer->hwnd) ? true : false);
- /*
- * window minimized, check if sound has to be played
- */
+ // window minimized, check if sound has to be played
if (fIconic)
return(dat->pContainer->dwFlagsEx & CNT_EX_SOUNDS_MINIMIZED ? 1 : 0);
- /*
- * window in foreground
- */
+ // window in foreground
if (fActiveWindow) {
if (fActiveTab)
return(dat->pContainer->dwFlagsEx & CNT_EX_SOUNDS_FOCUSED ? 1 : 0);
@@ -910,25 +893,25 @@ int Utils::mustPlaySound(const TWindowData *dat)
return 1;
}
-/**
- * enable or disable a dialog control
- */
+/////////////////////////////////////////////////////////////////////////////////////////
+// enable or disable a dialog control
+
void Utils::enableDlgControl(const HWND hwnd, UINT id, BOOL fEnable)
{
::EnableWindow(::GetDlgItem(hwnd, id), fEnable);
}
-/**
- * show or hide a dialog control
- */
+/////////////////////////////////////////////////////////////////////////////////////////
+// show or hide a dialog control
+
void Utils::showDlgControl(const HWND hwnd, UINT id, int showCmd)
{
::ShowWindow(::GetDlgItem(hwnd, id), showCmd);
}
-/*
- * stream function to write the contents of the message log to an rtf file
- */
+/////////////////////////////////////////////////////////////////////////////////////////
+// stream function to write the contents of the message log to an rtf file
+
DWORD CALLBACK Utils::StreamOut(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG * pcb)
{
HANDLE hFile;
@@ -944,10 +927,10 @@ DWORD CALLBACK Utils::StreamOut(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG
return 1;
}
-/**
- * extract a resource from the given module
- * tszPath must end with \
- */
+/////////////////////////////////////////////////////////////////////////////////////////
+// extract a resource from the given module
+// tszPath must end with \
+
bool Utils::extractResource(const HMODULE h, const UINT uID, const TCHAR *tszName, const TCHAR *tszPath,
const TCHAR *tszFilename, bool fForceOverwrite)
{
@@ -975,12 +958,12 @@ bool Utils::extractResource(const HMODULE h, const UINT uID, const TCHAR *tszNam
return true;
}
-/**
- * extract the clicked URL from a rich edit control. Return the URL as TCHAR*
- * caller MUST mir_free() the returned string
- * @param hwndRich - rich edit window handle
- * @return wchar_t* extracted URL
- */
+/////////////////////////////////////////////////////////////////////////////////////////
+// extract the clicked URL from a rich edit control. Return the URL as TCHAR*
+// caller MUST mir_free() the returned string
+// @param hwndRich - rich edit window handle
+// @return wchar_t* extracted URL
+
const wchar_t* Utils::extractURLFromRichEdit(const ENLINK* _e, const HWND hwndRich)
{
TEXTRANGEW tr = {0};
@@ -1000,10 +983,10 @@ const wchar_t* Utils::extractURLFromRichEdit(const ENLINK* _e, const HWND hwndRi
return(tr.lpstrText);
}
-/**
- * generic command dispatcher
- * used in various places (context menus, info panel menus etc.)
- */
+/////////////////////////////////////////////////////////////////////////////////////////
+// generic command dispatcher
+// used in various places (context menus, info panel menus etc.)
+
LRESULT Utils::CmdDispatcher(UINT uType, HWND hwndDlg, UINT cmd, WPARAM wParam, LPARAM lParam, TWindowData *dat, TContainerData *pContainer)
{
switch (uType) {
@@ -1025,12 +1008,12 @@ LRESULT Utils::CmdDispatcher(UINT uType, HWND hwndDlg, UINT cmd, WPARAM wParam,
return 0;
}
-/**
- * filter out invalid characters from a string used as part of a file
- * or folder name. All invalid characters will be replaced by spaces.
- *
- * @param tszFilename - string to filter.
- */
+/////////////////////////////////////////////////////////////////////////////////////////
+// filters out invalid characters from a string used as part of a file
+// or folder name. All invalid characters will be replaced by spaces.
+//
+// @param tszFilename - string to filter.
+
void Utils::sanitizeFilename(wchar_t* tszFilename)
{
static wchar_t *forbiddenCharacters = L"%/\\':|\"<>?";
@@ -1043,22 +1026,22 @@ void Utils::sanitizeFilename(wchar_t* tszFilename)
}
}
-/**
- * ensure that a path name ends on a trailing backslash
- * @param szPathname - pathname to check
- */
+/////////////////////////////////////////////////////////////////////////////////////////
+// ensure that a path name ends on a trailing backslash
+// @param szPathname - pathname to check
+
void Utils::ensureTralingBackslash(wchar_t *szPathname)
{
if (szPathname[lstrlenW(szPathname) - 1] != '\\')
wcscat(szPathname, L"\\");
}
-/**
- * load a system library from the Windows system path and return its module
- * handle.
- *
- * return 0 and throw an exception if something goes wrong.
- */
+/////////////////////////////////////////////////////////////////////////////////////////
+// load a system library from the Windows system path and return its module
+// handle.
+//
+// return 0 and throw an exception if something goes wrong.
+
HMODULE Utils::loadSystemLibrary(const wchar_t* szFilename)
{
wchar_t sysPathName[MAX_PATH + 2];
@@ -1087,6 +1070,56 @@ void Utils::setAvatarContact(HWND hWnd, MCONTACT hContact)
}
/////////////////////////////////////////////////////////////////////////////////////////
+// stub for copying data to clipboard
+
+size_t Utils::CopyToClipBoard(const wchar_t *str, const HWND hwndOwner)
+{
+ if (!OpenClipboard(hwndOwner) || str == 0)
+ return 0;
+
+ size_t i = sizeof(TCHAR) * (lstrlen(str) + 1);
+
+ EmptyClipboard();
+ HGLOBAL hData = ::GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, i);
+
+ CopyMemory((void*)GlobalLock(hData), str, i);
+ GlobalUnlock(hData);
+ SetClipboardData(CF_UNICODETEXT, hData);
+ CloseClipboard();
+ return i;
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
+// file list handler
+
+void Utils::AddToFileList(TCHAR ***pppFiles, int *totalCount, LPCTSTR szFilename)
+{
+ *pppFiles = (TCHAR**)mir_realloc(*pppFiles, (++*totalCount + 1) * sizeof(TCHAR*));
+ (*pppFiles)[*totalCount] = NULL;
+ (*pppFiles)[*totalCount - 1] = mir_tstrdup(szFilename);
+
+ if (GetFileAttributes(szFilename) & FILE_ATTRIBUTE_DIRECTORY) {
+ WIN32_FIND_DATA fd;
+ HANDLE hFind;
+ TCHAR szPath[MAX_PATH];
+ lstrcpy(szPath, szFilename);
+ lstrcat(szPath, _T("\\*"));
+ if ((hFind = FindFirstFile(szPath, &fd)) != INVALID_HANDLE_VALUE) {
+ do {
+ if (!lstrcmp(fd.cFileName, _T(".")) || !lstrcmp(fd.cFileName, _T("..")))
+ continue;
+ lstrcpy(szPath, szFilename);
+ lstrcat(szPath, _T("\\"));
+ lstrcat(szPath, fd.cFileName);
+ AddToFileList(pppFiles, totalCount, szPath);
+ }
+ while (FindNextFile(hFind, &fd));
+ FindClose(hFind);
+ }
+ }
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
// implementation of the CWarning class
/** IMPORTANT note to translators for translation of the warning dialogs:
diff --git a/plugins/TabSRMM/src/utils.h b/plugins/TabSRMM/src/utils.h
index fec8ab9db2..e50d56af96 100644
--- a/plugins/TabSRMM/src/utils.h
+++ b/plugins/TabSRMM/src/utils.h
@@ -107,61 +107,12 @@ public:
static HMODULE loadSystemLibrary(const wchar_t* szFilename);
- static INT_PTR CALLBACK PopupDlgProcError(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
- static LPCTSTR extractURLFromRichEdit(const ENLINK* _e, const HWND hwndRich);
+ static INT_PTR CALLBACK PopupDlgProcError(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
+ static LPCTSTR extractURLFromRichEdit(const ENLINK* _e, const HWND hwndRich);
- template<typename T> static size_t CopyToClipBoard(T* _t, const HWND hwndOwner)
- {
- if (!OpenClipboard(hwndOwner) || _t == 0)
- return 0;
-
- std::basic_string<T> *s = new std::basic_string<T>(_t);
- size_t _s = sizeof(T);
- size_t i = _s * (s->length() + 1);
-
- EmptyClipboard();
- HGLOBAL hData = ::GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, i);
-
- CopyMemory((void*)GlobalLock(hData), (void*)_t, i);
- GlobalUnlock(hData);
- SetClipboardData(_s == sizeof(char) ? CF_TEXT : CF_UNICODETEXT, hData);
- CloseClipboard();
- delete s;
- return(i);
- }
-
- template<typename T> static void AddToFileList(T ***pppFiles, int *totalCount, LPCTSTR szFilename)
- {
- size_t _s = sizeof(T);
-
- *pppFiles = (T**)mir_realloc(*pppFiles, (++*totalCount + 1) * sizeof(T*));
- (*pppFiles)[*totalCount] = NULL;
-
- if (_s == 1)
- (*pppFiles)[*totalCount-1] = reinterpret_cast<T *>(mir_t2a(szFilename));
- else
- (*pppFiles)[*totalCount-1] = reinterpret_cast<T *>(mir_tstrdup(szFilename));
-
- if (GetFileAttributes(szFilename) & FILE_ATTRIBUTE_DIRECTORY) {
- WIN32_FIND_DATA fd;
- HANDLE hFind;
- TCHAR szPath[MAX_PATH];
-
- lstrcpy(szPath, szFilename);
- lstrcat(szPath, _T("\\*"));
- if ((hFind = FindFirstFile(szPath, &fd)) != INVALID_HANDLE_VALUE) {
- do {
- if (!lstrcmp(fd.cFileName, _T(".")) || !lstrcmp(fd.cFileName, _T("..")))
- continue;
- lstrcpy(szPath, szFilename);
- lstrcat(szPath, _T("\\"));
- lstrcat(szPath, fd.cFileName);
- AddToFileList(pppFiles, totalCount, szPath);
- } while (FindNextFile(hFind, &fd));
- FindClose(hFind);
- }
- }
- }
+ static size_t CopyToClipBoard(const wchar_t *str, const HWND hwndOwner);
+
+ static void AddToFileList(TCHAR ***pppFiles, int *totalCount, LPCTSTR szFilename);
/**
* safe strlen function - do not overflow the given buffer length
diff --git a/plugins/TabSRMM/src/version.h b/plugins/TabSRMM/src/version.h
index 10609f7680..ee9d6cde47 100644
--- a/plugins/TabSRMM/src/version.h
+++ b/plugins/TabSRMM/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 3
#define __MINOR_VERSION 4
#define __RELEASE_NUM 0
-#define __BUILD_NUM 3
+#define __BUILD_NUM 4
#include <stdver.h>