summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2014-12-01 21:43:00 +0000
committerGeorge Hazan <george.hazan@gmail.com>2014-12-01 21:43:00 +0000
commita4570b58a7efb3b61db6d03b86d51d7be85a5f03 (patch)
tree059840bb704c9553a3c1c94514359b431231fcb3
parent585bd37dd3830d07c1d20b492fe0d4a84201b09a (diff)
code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@11204 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--plugins/Scriver/src/Version.h2
-rw-r--r--plugins/Scriver/src/chat/log.cpp20
-rw-r--r--plugins/Scriver/src/chat/options.cpp4
-rw-r--r--plugins/Scriver/src/chat/window.cpp6
-rw-r--r--plugins/Scriver/src/globals.cpp2
-rw-r--r--plugins/Scriver/src/input.cpp2
-rw-r--r--plugins/Scriver/src/msgdialog.cpp663
-rw-r--r--plugins/Scriver/src/msglog.cpp71
-rw-r--r--plugins/Scriver/src/msgoptions.cpp4
-rw-r--r--plugins/Scriver/src/msgs.cpp2
-rw-r--r--plugins/Scriver/src/msgs.h1
-rw-r--r--plugins/Scriver/src/msgwindow.cpp329
-rw-r--r--plugins/Scriver/src/sendqueue.cpp11
-rw-r--r--plugins/Scriver/src/srmm.cpp4
-rw-r--r--plugins/Scriver/src/statusicon.cpp2
-rw-r--r--plugins/Scriver/src/utils.cpp166
-rw-r--r--plugins/Scriver/src/utils.h2
17 files changed, 634 insertions, 657 deletions
diff --git a/plugins/Scriver/src/Version.h b/plugins/Scriver/src/Version.h
index 18d5a1a47d..b67ff7e7ac 100644
--- a/plugins/Scriver/src/Version.h
+++ b/plugins/Scriver/src/Version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 2
#define __MINOR_VERSION 11
#define __RELEASE_NUM 1
-#define __BUILD_NUM 1
+#define __BUILD_NUM 2
#include <stdver.h>
diff --git a/plugins/Scriver/src/chat/log.cpp b/plugins/Scriver/src/chat/log.cpp
index 225945e3d7..3a616bff6e 100644
--- a/plugins/Scriver/src/chat/log.cpp
+++ b/plugins/Scriver/src/chat/log.cpp
@@ -33,11 +33,11 @@ static DWORD CALLBACK Log_StreamCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG
if (lstrdat->buffer == NULL) {
lstrdat->bufferOffset = 0;
lstrdat->buffer = pci->Log_CreateRTF(lstrdat);
- lstrdat->bufferLen = mir_strlen(lstrdat->buffer);
+ lstrdat->bufferLen = (int)mir_strlen(lstrdat->buffer);
}
// give the RTF to the RE control
- *pcb = min(cb, lstrdat->bufferLen - lstrdat->bufferOffset);
+ *pcb = min(cb, LONG(lstrdat->bufferLen - lstrdat->bufferOffset));
CopyMemory(pbBuff, lstrdat->buffer + lstrdat->bufferOffset, *pcb);
lstrdat->bufferOffset += *pcb;
@@ -56,6 +56,11 @@ void Log_StreamInEvent(HWND hwndDlg, LOGINFO* lin, SESSION_INFO *si, BOOL bRedra
if (hwndDlg == 0 || lin == 0 || si == 0)
return;
+ if (!bRedraw && (si->iType == GCW_CHATROOM || si->iType == GCW_PRIVMESS) && si->bFilterEnabled && !(si->iLogFilterFlags & lin->iType))
+ return;
+
+ BOOL bFlag = FALSE;
+
HWND hwndRich = GetDlgItem(hwndDlg, IDC_CHAT_LOG);
LOGSTREAMDATA streamData;
@@ -66,14 +71,9 @@ void Log_StreamInEvent(HWND hwndDlg, LOGINFO* lin, SESSION_INFO *si, BOOL bRedra
streamData.bStripFormat = FALSE;
streamData.isFirst = bRedraw ? 1 : (GetRichTextLength(hwndRich, CP_ACP, FALSE) == 0);
- if (!bRedraw && (si->iType == GCW_CHATROOM || si->iType == GCW_PRIVMESS) && si->bFilterEnabled && !(si->iLogFilterFlags & lin->iType))
- return;
-
- BOOL bFlag = FALSE;
-
EDITSTREAM stream = { 0 };
stream.pfnCallback = Log_StreamCallback;
- stream.dwCookie = (DWORD_PTR)& streamData;
+ stream.dwCookie = (DWORD_PTR)&streamData;
SCROLLINFO scroll;
scroll.cbSize = sizeof(SCROLLINFO);
@@ -113,8 +113,8 @@ void Log_StreamInEvent(HWND hwndDlg, LOGINFO* lin, SESSION_INFO *si, BOOL bRedra
SendMessage(hwndRich, EM_STREAMIN, wp, (LPARAM)&stream);
// do smileys
- if (g_dat.smileyAddInstalled && (bRedraw || (lin->ptszText && lin->iType != GC_EVENT_JOIN
- && lin->iType != GC_EVENT_NICK && lin->iType != GC_EVENT_ADDSTATUS && lin->iType != GC_EVENT_REMOVESTATUS)))
+ if (g_dat.smileyAddInstalled && (bRedraw || (lin->ptszText &&
+ lin->iType != GC_EVENT_JOIN && lin->iType != GC_EVENT_NICK && lin->iType != GC_EVENT_ADDSTATUS && lin->iType != GC_EVENT_REMOVESTATUS)))
{
newsel.cpMax = -1;
newsel.cpMin = sel.cpMin;
diff --git a/plugins/Scriver/src/chat/options.cpp b/plugins/Scriver/src/chat/options.cpp
index d06a6a8c50..09b24b9483 100644
--- a/plugins/Scriver/src/chat/options.cpp
+++ b/plugins/Scriver/src/chat/options.cpp
@@ -520,7 +520,7 @@ INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lPa
iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_CHAT_HIGHLIGHTWORDS));
if (iLen > 0) {
- TCHAR *ptszText = (TCHAR *)mir_alloc((iLen + 2) * sizeof(TCHAR));
+ TCHAR *ptszText = (TCHAR*)mir_alloc((iLen + 2) * sizeof(TCHAR));
TCHAR *p2 = NULL;
if (ptszText) {
@@ -538,7 +538,7 @@ INT_PTR CALLBACK DlgProcOptions2(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lPa
iLen = GetWindowTextLength(GetDlgItem(hwndDlg, IDC_CHAT_LOGDIRECTORY));
if (iLen > 0) {
- TCHAR *pszText1 = (TCHAR *)malloc(iLen*sizeof(TCHAR)+2);
+ TCHAR *pszText1 = (TCHAR*)malloc(iLen*sizeof(TCHAR)+2);
GetDlgItemText(hwndDlg, IDC_CHAT_LOGDIRECTORY, pszText1, iLen + 1);
db_set_ts(NULL, CHAT_MODULE, "LogDirectory", pszText1);
free(pszText1);
diff --git a/plugins/Scriver/src/chat/window.cpp b/plugins/Scriver/src/chat/window.cpp
index 0fa3c1485d..833b8acfc1 100644
--- a/plugins/Scriver/src/chat/window.cpp
+++ b/plugins/Scriver/src/chat/window.cpp
@@ -221,7 +221,7 @@ static void TabAutoComplete(HWND hwnd, MESSAGESUBDATA *dat, SESSION_INFO *si)
bool isTopic = false, isRoom = false;
TCHAR *pszName = NULL;
- TCHAR* pszText = (TCHAR *)mir_alloc(iLen + 100 * sizeof(TCHAR));
+ TCHAR* pszText = (TCHAR*)mir_alloc(iLen + 100 * sizeof(TCHAR));
gt.cb = iLen + 99 * sizeof(TCHAR);
gt.flags = GT_DEFAULT;
@@ -285,7 +285,7 @@ LBL_SkipEnd:
if (end != start) {
ptrT szReplace;
if (!isRoom && !isTopic && g_Settings.bAddColonToAutoComplete && start == 0) {
- szReplace = (TCHAR *)mir_alloc((_tcslen(pszName) + 4) * sizeof(TCHAR));
+ szReplace = (TCHAR*)mir_alloc((_tcslen(pszName) + 4) * sizeof(TCHAR));
_tcscpy(szReplace, pszName);
_tcscat(szReplace, _T(": "));
pszName = szReplace;
@@ -1441,7 +1441,7 @@ static INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPAR
}
SetTextColor(dis->hDC, ui->iStatusEx == 0 ? g_Settings.crUserListColor : g_Settings.crUserListHeadingsColor);
- TextOut(dis->hDC, dis->rcItem.left + x_offset, dis->rcItem.top, ui->pszNick, mir_tstrlen(ui->pszNick));
+ TextOut(dis->hDC, dis->rcItem.left + x_offset, dis->rcItem.top, ui->pszNick, (int)mir_tstrlen(ui->pszNick));
SelectObject(dis->hDC, hOldFont);
}
return TRUE;
diff --git a/plugins/Scriver/src/globals.cpp b/plugins/Scriver/src/globals.cpp
index 719d5a5b69..ca0174e65e 100644
--- a/plugins/Scriver/src/globals.cpp
+++ b/plugins/Scriver/src/globals.cpp
@@ -150,7 +150,7 @@ static int ackevent(WPARAM wParam, LPARAM lParam)
dbei.flags |= DBEF_UTF;
dbei.szModule = GetContactProto(hContact);
dbei.timestamp = time(NULL);
- dbei.cbBlob = mir_strlen(item->sendBuffer) + 1;
+ dbei.cbBlob = (int)mir_strlen(item->sendBuffer) + 1;
if (!(item->flags & PREF_UTF))
dbei.cbBlob *= sizeof(TCHAR) + 1;
dbei.pBlob = (PBYTE)item->sendBuffer;
diff --git a/plugins/Scriver/src/input.cpp b/plugins/Scriver/src/input.cpp
index 8c07b4dd28..bfbacffcf0 100644
--- a/plugins/Scriver/src/input.cpp
+++ b/plugins/Scriver/src/input.cpp
@@ -385,7 +385,7 @@ BOOL HandleLinkClick(HINSTANCE hInstance, HWND hwndDlg, HWND hwndFocus, ENLINK *
SendMessage(lParam->nmhdr.hwndFrom, EM_GETTEXTRANGE, 0, (LPARAM)&tr);
if (_tcschr(tr.lpstrText, _T('@')) != NULL && _tcschr(tr.lpstrText, _T(':')) == NULL && _tcschr(tr.lpstrText, _T('/')) == NULL) {
MoveMemory(tr.lpstrText + 7, tr.lpstrText, sizeof(TCHAR)*(tr.chrg.cpMax - tr.chrg.cpMin + 1));
- CopyMemory(tr.lpstrText, _T("mailto:"), sizeof(TCHAR)* 7);
+ CopyMemory(tr.lpstrText, _T("mailto:"), sizeof(TCHAR) * 7);
}
BOOL bOpenLink = TRUE;
diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp
index 0ee6d0c7d5..9997b84b2c 100644
--- a/plugins/Scriver/src/msgdialog.cpp
+++ b/plugins/Scriver/src/msgdialog.cpp
@@ -47,32 +47,30 @@ static ToolbarButton toolbarButtons[] = {
static DWORD CALLBACK StreamOutCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG * pcb)
{
- MessageSendQueueItem * msi = (MessageSendQueueItem *) dwCookie;
+ MessageSendQueueItem *msi = (MessageSendQueueItem *) dwCookie;
msi->sendBuffer = (char*)mir_realloc(msi->sendBuffer, msi->sendBufferSize + cb + 2);
memcpy (msi->sendBuffer + msi->sendBufferSize, pbBuff, cb);
msi->sendBufferSize += cb;
- *((TCHAR *)(msi->sendBuffer+msi->sendBufferSize)) = '\0';
+ *((TCHAR*)(msi->sendBuffer+msi->sendBufferSize)) = '\0';
*pcb = cb;
return 0;
}
-static TCHAR *GetIEViewSelection(SrmmWindowData *dat)
+static TCHAR* GetIEViewSelection(SrmmWindowData *dat)
{
IEVIEWEVENT evt = { sizeof(evt) };
evt.codepage = dat->windowData.codePage;
evt.hwnd = dat->windowData.hwndLog;
evt.hContact = dat->windowData.hContact;
evt.iType = IEE_GET_SELECTION;
- return mir_tstrdup((TCHAR *)CallService(MS_IEVIEW_EVENT, 0, (LPARAM)&evt));
+ return mir_tstrdup((TCHAR*)CallService(MS_IEVIEW_EVENT, 0, (LPARAM)&evt));
}
-static TCHAR *GetQuotedTextW(TCHAR * text)
+static TCHAR* GetQuotedTextW(TCHAR *text)
{
- int i, j, l, newLine, wasCR;
- TCHAR *out;
- l = (int)wcslen(text);
- newLine = 1;
- wasCR = 0;
+ size_t i, j, l = wcslen(text);
+ int newLine = 1;
+ int wasCR = 0;
for (i = j = 0; i < l; i++) {
if (text[i] == '\r') {
wasCR = 1;
@@ -95,7 +93,8 @@ static TCHAR *GetQuotedTextW(TCHAR * text)
}
}
j += 3;
- out = (TCHAR *)mir_alloc(sizeof(TCHAR)* j);
+
+ TCHAR *out = (TCHAR*)mir_alloc(sizeof(TCHAR)* j);
newLine = 1;
wasCR = 0;
for (i = j = 0; i < l; i++) {
@@ -161,26 +160,21 @@ void NotifyLocalWinEvent(MCONTACT hContact, HWND hwnd, unsigned int type)
static BOOL IsUtfSendAvailable(MCONTACT hContact)
{
char* szProto = GetContactProto(hContact);
- if ( szProto == NULL )
+ if (szProto == NULL)
return FALSE;
- return ( CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_IMSENDUTF ) ? TRUE : FALSE;
+ return (CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_IMSENDUTF) ? TRUE : FALSE;
}
int RTL_Detect(WCHAR *pszwText)
{
- WORD *infoTypeC2;
- int i;
- int iLen = mir_wstrlen(pszwText);
-
- infoTypeC2 = (WORD *)mir_alloc(sizeof(WORD) * (iLen + 2));
+ size_t iLen = mir_wstrlen(pszwText);
+ WORD *infoTypeC2 = (WORD *)mir_calloc(sizeof(WORD) * (iLen + 2));
if (infoTypeC2) {
- memset(infoTypeC2, 0, (sizeof(WORD) * (iLen + 2)));
+ GetStringTypeW(CT_CTYPE2, pszwText, (int)iLen, infoTypeC2);
- GetStringTypeW(CT_CTYPE2, pszwText, iLen, infoTypeC2);
-
- for(i = 0; i < iLen; i++) {
+ for (size_t i = 0; i < iLen; i++) {
if (infoTypeC2[i] == C2_RIGHTTOLEFT) {
mir_free(infoTypeC2);
return 1;
@@ -191,34 +185,35 @@ int RTL_Detect(WCHAR *pszwText)
return 0;
}
-static void AddToFileList(TCHAR ***pppFiles,int *totalCount,const TCHAR* szFilename)
+static void AddToFileList(TCHAR ***pppFiles, int *totalCount, const TCHAR* szFilename)
{
- *pppFiles=(TCHAR**)mir_realloc(*pppFiles,(++*totalCount+1)*sizeof(TCHAR*));
+ *pppFiles = (TCHAR**)mir_realloc(*pppFiles, (++*totalCount + 1)*sizeof(TCHAR*));
(*pppFiles)[*totalCount] = NULL;
- (*pppFiles)[*totalCount-1] = mir_tstrdup( szFilename );
+ (*pppFiles)[*totalCount - 1] = mir_tstrdup(szFilename);
- if ( GetFileAttributes(szFilename) & FILE_ATTRIBUTE_DIRECTORY ) {
+ if (GetFileAttributes(szFilename) & FILE_ATTRIBUTE_DIRECTORY) {
WIN32_FIND_DATA fd;
HANDLE hFind;
TCHAR szPath[MAX_PATH];
- mir_tstrcpy(szPath,szFilename);
- mir_tstrcat(szPath,_T("\\*"));
- if (( hFind = FindFirstFile( szPath, &fd )) != INVALID_HANDLE_VALUE ) {
+ mir_tstrcpy(szPath, szFilename);
+ mir_tstrcat(szPath, _T("\\*"));
+ if ((hFind = FindFirstFile(szPath, &fd)) != INVALID_HANDLE_VALUE) {
do {
- if ( !mir_tstrcmp(fd.cFileName,_T(".")) || !mir_tstrcmp(fd.cFileName,_T(".."))) continue;
- mir_tstrcpy(szPath,szFilename);
- mir_tstrcat(szPath,_T("\\"));
- mir_tstrcat(szPath,fd.cFileName);
- AddToFileList(pppFiles,totalCount,szPath);
- }
- while( FindNextFile( hFind,&fd ));
- FindClose( hFind );
-} } }
+ if (!mir_tstrcmp(fd.cFileName, _T(".")) || !mir_tstrcmp(fd.cFileName, _T(".."))) continue;
+ mir_tstrcpy(szPath, szFilename);
+ mir_tstrcat(szPath, _T("\\"));
+ mir_tstrcat(szPath, fd.cFileName);
+ AddToFileList(pppFiles, totalCount, szPath);
+ } while (FindNextFile(hFind, &fd));
+ FindClose(hFind);
+ }
+ }
+}
static void SetDialogToType(HWND hwndDlg)
{
BOOL showToolbar = SendMessage(GetParent(hwndDlg), CM_GETTOOLBARSTATUS, 0, 0);
- SrmmWindowData *dat = (SrmmWindowData *) GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ SrmmWindowData *dat = (SrmmWindowData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
ParentWindowData *pdat = dat->parent;
if (pdat->flags2 & SMF2_SHOWINFOBAR)
@@ -238,13 +233,13 @@ static void SetDialogToType(HWND hwndDlg)
ShowWindow(GetDlgItem(hwndDlg, IDC_MESSAGE), SW_SHOW);
if (dat->windowData.hwndLog != NULL)
- ShowWindow (GetDlgItem(hwndDlg, IDC_LOG), SW_HIDE);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_LOG), SW_HIDE);
else
- ShowWindow (GetDlgItem(hwndDlg, IDC_LOG), SW_SHOW);
+ ShowWindow(GetDlgItem(hwndDlg, IDC_LOG), SW_SHOW);
ShowWindow(GetDlgItem(hwndDlg, IDC_SPLITTER), SW_SHOW);
UpdateReadChars(hwndDlg, dat);
- EnableWindow(GetDlgItem(hwndDlg, IDOK), GetRichTextLength(GetDlgItem(hwndDlg, IDC_MESSAGE), dat->windowData.codePage, FALSE)?TRUE:FALSE);
+ EnableWindow(GetDlgItem(hwndDlg, IDOK), GetRichTextLength(GetDlgItem(hwndDlg, IDC_MESSAGE), dat->windowData.codePage, FALSE) ? TRUE : FALSE);
SendMessage(hwndDlg, DM_CLISTSETTINGSCHANGED, 0, 0);
SendMessage(hwndDlg, WM_SIZE, 0, 0);
}
@@ -268,10 +263,10 @@ void SetStatusIcon(SrmmWindowData *dat)
dat->statusIconBig = NULL;
if (dat->statusIconOverlay != NULL)
- DestroyIcon(dat->statusIconOverlay);
+ DestroyIcon(dat->statusIconOverlay);
int index = ImageList_ReplaceIcon(g_dat.hHelperIconList, 0, dat->statusIcon);
- dat->statusIconOverlay = ImageList_GetIcon(g_dat.hHelperIconList, index, ILD_TRANSPARENT|INDEXTOOVERLAYMASK(1));
+ dat->statusIconOverlay = ImageList_GetIcon(g_dat.hHelperIconList, index, ILD_TRANSPARENT | INDEXTOOVERLAYMASK(1));
}
void GetTitlebarIcon(SrmmWindowData *dat, TitleBarData *tbd)
@@ -296,7 +291,7 @@ HICON GetTabIcon(SrmmWindowData *dat)
if (dat->showUnread != 0)
return dat->statusIconOverlay;
-
+
return dat->statusIcon;
}
@@ -334,20 +329,20 @@ static LRESULT CALLBACK LogEditSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
ClientToScreen(hwnd, &pt);
}
else {
- pt.x = (short) LOWORD(lParam);
- pt.y = (short) HIWORD(lParam);
+ pt.x = (short)LOWORD(lParam);
+ pt.y = (short)HIWORD(lParam);
}
POINTL ptl = { (LONG)pt.x, (LONG)pt.y };
ScreenToClient(hwnd, (LPPOINT)&ptl);
- ptrT pszWord( GetRichTextWord(hwnd, &ptl));
- if ( pszWord && pszWord[0] ) {
+ ptrT pszWord(GetRichTextWord(hwnd, &ptl));
+ if (pszWord && pszWord[0]) {
TCHAR szMenuText[4096];
- mir_sntprintf( szMenuText, 4096, TranslateT("Look up '%s':"), pszWord );
- ModifyMenu( hSubMenu, 5, MF_STRING|MF_BYPOSITION, 5, szMenuText );
+ mir_sntprintf(szMenuText, 4096, TranslateT("Look up '%s':"), pszWord);
+ ModifyMenu(hSubMenu, 5, MF_STRING | MF_BYPOSITION, 5, szMenuText);
SetSearchEngineIcons(hMenu, g_dat.hSearchEngineIconList);
}
- else ModifyMenu( hSubMenu, 5, MF_STRING|MF_GRAYED|MF_BYPOSITION, 5, TranslateT( "No word to look up" ));
+ else ModifyMenu(hSubMenu, 5, MF_STRING | MF_GRAYED | MF_BYPOSITION, 5, TranslateT("No word to look up"));
inMenu = TRUE;
int uID = TrackPopupMenu(hSubMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwnd, NULL);
@@ -377,7 +372,7 @@ static LRESULT CALLBACK LogEditSubclassProc(HWND hwnd, UINT msg, WPARAM wParam,
case IDM_SEARCH_GOOGLE_MAPS:
case IDM_SEARCH_GOOGLE_TRANSLATE:
SearchWord(pszWord, uID - IDM_SEARCH_GOOGLE + SEARCHENGINE_GOOGLE);
- PostMessage(GetParent(hwnd), WM_MOUSEACTIVATE, 0, 0 );
+ PostMessage(GetParent(hwnd), WM_MOUSEACTIVATE, 0, 0);
break;
}
DestroyMenu(hMenu);
@@ -409,7 +404,7 @@ static LRESULT CALLBACK MessageEditSubclassProc(HWND hwnd, UINT msg, WPARAM wPar
switch (msg) {
case EM_SUBCLASSED:
dat = (MsgEditSubclassData*)mir_alloc(sizeof(MsgEditSubclassData));
- SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR) dat);
+ SetWindowLongPtr(hwnd, GWLP_USERDATA, (LONG_PTR)dat);
DragAcceptFiles(hwnd, TRUE);
dat->lastEnterTime = 0;
return 0;
@@ -493,7 +488,8 @@ static void SubclassMessageEdit(HWND hwnd)
SendMessage(hwnd, EM_SUBCLASSED, 0, 0);
}
-static void SubclassLogEdit(HWND hwnd) {
+static void SubclassLogEdit(HWND hwnd)
+{
RichUtil_SubClass(hwnd);
mir_subclassWindow(hwnd, LogEditSubclassProc);
SendMessage(hwnd, EM_SUBCLASSED, 0, 0);
@@ -520,9 +516,9 @@ static void MessageDialogResize(HWND hwndDlg, SrmmWindowData *dat, int w, int h)
}
hSplitterPos = dat->desiredInputAreaHeight + SPLITTER_HEIGHT + 3;
- if (hSplitterPos > ( h - toolbarHeight - infobarHeight + SPLITTER_HEIGHT + 1 ) / 2)
- hSplitterPos = ( h - toolbarHeight - infobarHeight + SPLITTER_HEIGHT + 1 ) / 2;
-
+ if (hSplitterPos > (h - toolbarHeight - infobarHeight + SPLITTER_HEIGHT + 1) / 2)
+ hSplitterPos = (h - toolbarHeight - infobarHeight + SPLITTER_HEIGHT + 1) / 2;
+
if (h - hSplitterPos - infobarHeight < hSplitterMinTop)
hSplitterPos = h - hSplitterMinTop - infobarHeight;
@@ -543,8 +539,8 @@ static void MessageDialogResize(HWND hwndDlg, SrmmWindowData *dat, int w, int h)
else avatarHeight = BOTTOM_RIGHT_AVATAR_HEIGHT;
avatarWidth = avatarHeight;
- if (avatarWidth > BOTTOM_RIGHT_AVATAR_HEIGHT && avatarWidth > w/4)
- avatarWidth = w /4;
+ if (avatarWidth > BOTTOM_RIGHT_AVATAR_HEIGHT && avatarWidth > w / 4)
+ avatarWidth = w / 4;
if ((toolbarWidth - avatarWidth - 2) < dat->toolbarSize.cx)
avatarWidth = toolbarWidth - dat->toolbarSize.cx - 2;
@@ -557,15 +553,15 @@ static void MessageDialogResize(HWND hwndDlg, SrmmWindowData *dat, int w, int h)
dat->splitterPos = hSplitterPos;
logY = infobarInnerHeight;
- logH = h-hSplitterPos-toolbarHeight - infobarInnerHeight;
+ logH = h - hSplitterPos - toolbarHeight - infobarInnerHeight;
HDWP hdwp = BeginDeferWindowPos(15);
hdwp = DeferWindowPos(hdwp, dat->infobarData->hWnd, 0, 1, 0, w - 2, infobarInnerHeight - 2, SWP_NOZORDER);
- hdwp = DeferWindowPos(hdwp, GetDlgItem(hwndDlg, IDC_LOG), 0, 1, logY, w-2, logH, SWP_NOZORDER);
+ hdwp = DeferWindowPos(hdwp, GetDlgItem(hwndDlg, IDC_LOG), 0, 1, logY, w - 2, logH, SWP_NOZORDER);
hdwp = DeferWindowPos(hdwp, GetDlgItem(hwndDlg, IDC_MESSAGE), 0, 1, h - hSplitterPos + SPLITTER_HEIGHT, messageEditWidth, hSplitterPos - SPLITTER_HEIGHT - 1, SWP_NOZORDER);
- hdwp = DeferWindowPos(hdwp, GetDlgItem(hwndDlg, IDC_AVATAR), 0, w-avatarWidth - 1, h - (avatarHeight + avatarWidth) / 2 - 1, avatarWidth, avatarWidth, SWP_NOZORDER);
+ hdwp = DeferWindowPos(hdwp, GetDlgItem(hwndDlg, IDC_AVATAR), 0, w - avatarWidth - 1, h - (avatarHeight + avatarWidth) / 2 - 1, avatarWidth, avatarWidth, SWP_NOZORDER);
- hdwp = DeferWindowPos(hdwp, GetDlgItem(hwndDlg, IDC_SPLITTER), 0, 0, h - hSplitterPos-1, toolbarWidth, SPLITTER_HEIGHT, SWP_NOZORDER);
+ hdwp = DeferWindowPos(hdwp, GetDlgItem(hwndDlg, IDC_SPLITTER), 0, 0, h - hSplitterPos - 1, toolbarWidth, SPLITTER_HEIGHT, SWP_NOZORDER);
hdwp = ResizeToolbar(hwndDlg, hdwp, toolbarWidth, h - hSplitterPos - toolbarHeight + 1, toolbarHeight, SIZEOF(toolbarButtons), toolbarButtons, g_dat.buttonVisibility);
EndDeferWindowPos(hdwp);
@@ -676,19 +672,17 @@ static INT_PTR CALLBACK ConfirmSendAllDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa
{
switch (msg) {
case WM_INITDIALOG:
- {
- RECT rcParent, rcChild;
- TranslateDialogDefault( hwndDlg );
- GetWindowRect(GetParent(hwndDlg), &rcParent);
- GetWindowRect(hwndDlg, &rcChild);
- rcChild.bottom -= rcChild.top;
- rcChild.right -= rcChild.left;
- rcParent.bottom -= rcParent.top;
- rcParent.right -= rcParent.left;
- rcChild.left = rcParent.left + (rcParent.right - rcChild.right) / 2;
- rcChild.top = rcParent.top + (rcParent.bottom - rcChild.bottom) / 2;
- MoveWindow(hwndDlg, rcChild.left, rcChild.top, rcChild.right, rcChild.bottom, FALSE);
- }
+ RECT rcParent, rcChild;
+ TranslateDialogDefault(hwndDlg);
+ GetWindowRect(GetParent(hwndDlg), &rcParent);
+ GetWindowRect(hwndDlg, &rcChild);
+ rcChild.bottom -= rcChild.top;
+ rcChild.right -= rcChild.left;
+ rcParent.bottom -= rcParent.top;
+ rcParent.right -= rcParent.left;
+ rcChild.left = rcParent.left + (rcParent.right - rcChild.right) / 2;
+ rcChild.top = rcParent.top + (rcParent.bottom - rcChild.bottom) / 2;
+ MoveWindow(hwndDlg, rcChild.left, rcChild.top, rcChild.right, rcChild.bottom, FALSE);
return TRUE;
case WM_COMMAND:
@@ -710,7 +704,12 @@ static INT_PTR CALLBACK ConfirmSendAllDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa
INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
{
+ PARAFORMAT2 pf2;
+ CHARFORMAT2 cf2;
+ LPNMHDR pNmhdr;
+
static HMENU hToolbarMenu;
+
SrmmWindowData *dat = (SrmmWindowData*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
if (!dat && msg != WM_INITDIALOG)
return FALSE;
@@ -723,13 +722,13 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
RECT minEditInit;
NewMessageWindowLParam *newData = (NewMessageWindowLParam*)lParam;
dat = (SrmmWindowData*)mir_calloc(sizeof(SrmmWindowData));
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR) dat);
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat);
dat->windowData.hContact = newData->hContact;
NotifyLocalWinEvent(dat->windowData.hContact, hwndDlg, MSG_WINDOW_EVT_OPENING);
dat->hwnd = hwndDlg;
dat->hwndParent = GetParent(hwndDlg);
- dat->parent = (ParentWindowData *) GetWindowLongPtr(dat->hwndParent, GWLP_USERDATA);
+ dat->parent = (ParentWindowData *)GetWindowLongPtr(dat->hwndParent, GWLP_USERDATA);
dat->windowData.hwndLog = NULL;
dat->szProto = GetContactProto(dat->windowData.hContact);
dat->avatarPic = 0;
@@ -753,22 +752,21 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
dat->lastEventTime = time(NULL);
dat->startTime = time(NULL);
dat->flags = 0;
- if (db_get_b(dat->windowData.hContact, SRMMMOD, "UseRTL", (BYTE) 0))
+ if (db_get_b(dat->windowData.hContact, SRMMMOD, "UseRTL", (BYTE)0))
dat->flags |= SMF_RTL;
dat->flags |= g_dat.ieviewInstalled ? g_dat.flags & SMF_USEIEVIEW : 0;
{
- PARAFORMAT2 pf2;
memset(&pf2, 0, sizeof(pf2));
pf2.cbSize = sizeof(pf2);
pf2.dwMask = PFM_RTLPARA;
if (!(dat->flags & SMF_RTL)) {
pf2.wEffects = 0;
- SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_MESSAGE),GWL_EXSTYLE,GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_MESSAGE),GWL_EXSTYLE) & ~(WS_EX_RIGHT | WS_EX_RTLREADING | WS_EX_LEFTSCROLLBAR));
+ SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_MESSAGE), GWL_EXSTYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_MESSAGE), GWL_EXSTYLE) & ~(WS_EX_RIGHT | WS_EX_RTLREADING | WS_EX_LEFTSCROLLBAR));
}
else {
pf2.wEffects = PFE_RTLPARA;
- SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_MESSAGE),GWL_EXSTYLE,GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_MESSAGE),GWL_EXSTYLE) | WS_EX_RIGHT | WS_EX_RTLREADING | WS_EX_LEFTSCROLLBAR);
+ SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_MESSAGE), GWL_EXSTYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_MESSAGE), GWL_EXSTYLE) | WS_EX_RIGHT | WS_EX_RTLREADING | WS_EX_LEFTSCROLLBAR);
}
SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SETPARAFORMAT, 0, (LPARAM)&pf2);
/* Workaround to make Richedit display RTL messages correctly */
@@ -783,11 +781,11 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
pf2.wEffects = 0;
SendDlgItemMessage(hwndDlg, IDC_LOG, EM_SETPARAFORMAT, 0, (LPARAM)&pf2);
if (dat->flags & SMF_RTL)
- SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_LOG),GWL_EXSTYLE,GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_LOG),GWL_EXSTYLE) | WS_EX_LEFTSCROLLBAR);
+ SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_LOG), GWL_EXSTYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_LOG), GWL_EXSTYLE) | WS_EX_LEFTSCROLLBAR);
else
- SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_LOG),GWL_EXSTYLE,GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_LOG),GWL_EXSTYLE) & ~WS_EX_LEFTSCROLLBAR);
+ SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_LOG), GWL_EXSTYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_LOG), GWL_EXSTYLE) & ~WS_EX_LEFTSCROLLBAR);
}
- dat->windowData.codePage = db_get_w(dat->windowData.hContact, SRMMMOD, "CodePage", (WORD) CP_ACP);
+ dat->windowData.codePage = db_get_w(dat->windowData.hContact, SRMMMOD, "CodePage", (WORD)CP_ACP);
dat->ace = NULL;
GetWindowRect(GetDlgItem(hwndDlg, IDC_MESSAGE), &minEditInit);
dat->windowData.minEditBoxHeight = minEditInit.bottom - minEditInit.top;
@@ -800,7 +798,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
if (newData->szInitialText) {
if (newData->isWchar)
- SetDlgItemText(hwndDlg, IDC_MESSAGE, (TCHAR *)newData->szInitialText);
+ SetDlgItemText(hwndDlg, IDC_MESSAGE, (TCHAR*)newData->szInitialText);
else
SetDlgItemTextA(hwndDlg, IDC_MESSAGE, newData->szInitialText);
}
@@ -813,25 +811,25 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
SendMessage(hwndDlg, DM_CHANGEICONS, 0, 0);
// Make them flat buttons
- for (int i = 0; i < SIZEOF(toolbarButtons) ; i++)
+ for (int i = 0; i < SIZEOF(toolbarButtons); i++)
SendDlgItemMessage(hwndDlg, toolbarButtons[i].controlId, BUTTONSETASFLATBTN, TRUE, 0);
- SendDlgItemMessage(hwndDlg, IDC_ADD, BUTTONADDTOOLTIP, (WPARAM) LPGEN("Add Contact Permanently to List"), 0);
- SendDlgItemMessage(hwndDlg, IDC_USERMENU, BUTTONADDTOOLTIP, (WPARAM) LPGEN("User Menu"), 0);
- SendDlgItemMessage(hwndDlg, IDC_DETAILS, BUTTONADDTOOLTIP, (WPARAM) LPGEN("View User's Details"), 0);
- SendDlgItemMessage(hwndDlg, IDC_HISTORY, BUTTONADDTOOLTIP, (WPARAM) LPGEN("View User's History"), 0);
+ SendDlgItemMessage(hwndDlg, IDC_ADD, BUTTONADDTOOLTIP, (WPARAM)LPGEN("Add Contact Permanently to List"), 0);
+ SendDlgItemMessage(hwndDlg, IDC_USERMENU, BUTTONADDTOOLTIP, (WPARAM)LPGEN("User Menu"), 0);
+ SendDlgItemMessage(hwndDlg, IDC_DETAILS, BUTTONADDTOOLTIP, (WPARAM)LPGEN("View User's Details"), 0);
+ SendDlgItemMessage(hwndDlg, IDC_HISTORY, BUTTONADDTOOLTIP, (WPARAM)LPGEN("View User's History"), 0);
- SendDlgItemMessage(hwndDlg, IDC_QUOTE, BUTTONADDTOOLTIP, (WPARAM) LPGEN("Quote Text"), 0);
- SendDlgItemMessage(hwndDlg, IDC_SMILEYS, BUTTONADDTOOLTIP, (WPARAM) LPGEN("Insert Emoticon"), 0);
- SendDlgItemMessage(hwndDlg, IDOK, BUTTONADDTOOLTIP, (WPARAM) LPGEN("Send Message"), 0);
+ SendDlgItemMessage(hwndDlg, IDC_QUOTE, BUTTONADDTOOLTIP, (WPARAM)LPGEN("Quote Text"), 0);
+ SendDlgItemMessage(hwndDlg, IDC_SMILEYS, BUTTONADDTOOLTIP, (WPARAM)LPGEN("Insert Emoticon"), 0);
+ SendDlgItemMessage(hwndDlg, IDOK, BUTTONADDTOOLTIP, (WPARAM)LPGEN("Send Message"), 0);
SendDlgItemMessage(hwndDlg, IDC_LOG, EM_SETOLECALLBACK, 0, (LPARAM)&reOleCallback);
SendDlgItemMessage(hwndDlg, IDC_LOG, EM_SETEVENTMASK, 0, ENM_MOUSEEVENTS | ENM_LINK | ENM_KEYEVENTS);
SendDlgItemMessage(hwndDlg, IDC_LOG, EM_SETEDITSTYLE, SES_EXTENDBACKCOLOR, SES_EXTENDBACKCOLOR);
SendDlgItemMessage(hwndDlg, IDC_LOG, EM_SETLANGOPTIONS, 0, (LPARAM)SendDlgItemMessage(hwndDlg, IDC_LOG, EM_GETLANGOPTIONS, 0, 0) & ~(IMF_AUTOKEYBOARD | IMF_AUTOFONTSIZEADJUST));
- SendDlgItemMessage(hwndDlg, IDC_LOG, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(0,0));
+ SendDlgItemMessage(hwndDlg, IDC_LOG, EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN, MAKELONG(0, 0));
/* duh, how come we didnt use this from the start? */
- SendDlgItemMessage(hwndDlg, IDC_LOG, EM_AUTOURLDETECT, (WPARAM) TRUE, 0);
+ SendDlgItemMessage(hwndDlg, IDC_LOG, EM_AUTOURLDETECT, (WPARAM)TRUE, 0);
SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SETLANGOPTIONS, 0, (LPARAM)SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_GETLANGOPTIONS, 0, 0) & ~IMF_AUTOKEYBOARD);
SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SETOLECALLBACK, 0, (LPARAM)&reOleCallback2);
@@ -839,7 +837,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
if (dat->windowData.hContact && dat->szProto) {
int nMax = CallProtoService(dat->szProto, PS_GETCAPS, PFLAG_MAXLENOFMESSAGE, dat->windowData.hContact);
if (nMax)
- SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_LIMITTEXT, (WPARAM) nMax, 0);
+ SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_LIMITTEXT, (WPARAM)nMax, 0);
}
/* get around a lame bug in the Windows template resource code where richedits are limited to 0x7FFF */
SendDlgItemMessage(hwndDlg, IDC_LOG, EM_LIMITTEXT, (WPARAM) sizeof(TCHAR) * 0x7FFFFFFF, 0);
@@ -925,12 +923,11 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
dat->lastMessage = dbei.timestamp;
break;
}
- }
- while ((hdbEvent = db_event_prev(dat->windowData.hContact, hdbEvent)));
+ } while ((hdbEvent = db_event_prev(dat->windowData.hContact, hdbEvent)));
}
}
SendMessage(hwndDlg, DM_OPTIONSAPPLIED, 0, 0);
- SendMessage(GetParent(hwndDlg), CM_POPUPWINDOW, (WPARAM) (newData->flags & NMWLP_INCOMING), (LPARAM)hwndDlg);
+ SendMessage(GetParent(hwndDlg), CM_POPUPWINDOW, (WPARAM)(newData->flags & NMWLP_INCOMING), (LPARAM)hwndDlg);
if (notifyUnread) {
if (GetForegroundWindow() != dat->hwndParent || dat->parent->hwndActive != hwndDlg) {
dat->showUnread = 1;
@@ -949,15 +946,15 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
case DM_GETCONTEXTMENU:
{
- HMENU hMenu = (HMENU) CallService(MS_CLIST_MENUBUILDCONTACT, dat->windowData.hContact, 0);
+ HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, dat->windowData.hContact, 0);
SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, (LONG_PTR)hMenu);
}
return TRUE;
case WM_CONTEXTMENU:
- if (dat->hwndParent == (HWND) wParam) {
+ if (dat->hwndParent == (HWND)wParam) {
POINT pt;
- HMENU hMenu = (HMENU) CallService(MS_CLIST_MENUBUILDCONTACT, dat->windowData.hContact, 0);
+ HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, dat->windowData.hContact, 0);
GetCursorPos(&pt);
TrackPopupMenu(hMenu, 0, pt.x, pt.y, 0, hwndDlg, NULL);
DestroyMenu(hMenu);
@@ -969,46 +966,45 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
break;
case WM_RBUTTONUP:
+ hToolbarMenu = CreatePopupMenu();
+ for (int i = 0; i < SIZEOF(toolbarButtons); i++) {
+ MENUITEMINFO mii = { sizeof(mii) };
+ mii.fMask = MIIM_ID | MIIM_STRING | MIIM_STATE | MIIM_DATA | MIIM_BITMAP;
+ mii.fType = MFT_STRING;
+ mii.fState = (g_dat.buttonVisibility & (1 << i)) ? MFS_CHECKED : MFS_UNCHECKED;
+ mii.wID = i + 1;
+ mii.dwItemData = (ULONG_PTR)g_dat.hButtonIconList;
+ mii.hbmpItem = HBMMENU_CALLBACK;
+ mii.dwTypeData = TranslateTS((toolbarButtons[i].name));
+ InsertMenuItem(hToolbarMenu, i, TRUE, &mii);
+ }
{
- int i;
- hToolbarMenu = CreatePopupMenu();
- for (i = 0; i < SIZEOF(toolbarButtons); i++) {
- MENUITEMINFO mii = { sizeof(mii) };
- mii.fMask = MIIM_ID | MIIM_STRING | MIIM_STATE | MIIM_DATA | MIIM_BITMAP;
- mii.fType = MFT_STRING;
- mii.fState = (g_dat.buttonVisibility & (1<< i)) ? MFS_CHECKED : MFS_UNCHECKED;
- mii.wID = i + 1;
- mii.dwItemData = (ULONG_PTR)g_dat.hButtonIconList;
- mii.hbmpItem = HBMMENU_CALLBACK;
- mii.dwTypeData = TranslateTS((toolbarButtons[i].name));
- InsertMenuItem(hToolbarMenu, i, TRUE, &mii);
- }
- POINT pt = { (short)LOWORD(GetMessagePos()), (short) HIWORD(GetMessagePos()) };
- i = TrackPopupMenu(hToolbarMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL);
+ POINT pt = { (short)LOWORD(GetMessagePos()), (short)HIWORD(GetMessagePos()) };
+ int i = TrackPopupMenu(hToolbarMenu, TPM_RETURNCMD, pt.x, pt.y, 0, hwndDlg, NULL);
if (i > 0) {
g_dat.buttonVisibility ^= (1 << (i - 1));
db_set_dw(NULL, SRMMMOD, SRMSGSET_BUTTONVISIBILITY, g_dat.buttonVisibility);
WindowList_Broadcast(g_dat.hMessageWindowList, DM_OPTIONSAPPLIED, 0, 0);
}
- DestroyMenu(hToolbarMenu);
}
+ DestroyMenu(hToolbarMenu);
return TRUE;
case WM_DROPFILES:
if (dat->szProto == NULL) break;
- if (!(CallProtoService(dat->szProto, PS_GETCAPS, PFLAGNUM_1,0)&PF1_FILESEND)) break;
+ if (!(CallProtoService(dat->szProto, PS_GETCAPS, PFLAGNUM_1, 0)&PF1_FILESEND)) break;
if (dat->wStatus == ID_STATUS_OFFLINE) break;
if (dat->windowData.hContact != NULL) {
TCHAR szFilename[MAX_PATH];
HDROP hDrop = (HDROP)wParam;
- int fileCount = DragQueryFile(hDrop,-1,NULL,0), totalCount = 0, i;
+ int fileCount = DragQueryFile(hDrop, -1, NULL, 0), totalCount = 0, i;
TCHAR** ppFiles = NULL;
- for ( i=0; i < fileCount; i++ ) {
+ for (i = 0; i < fileCount; i++) {
DragQueryFile(hDrop, i, szFilename, SIZEOF(szFilename));
AddToFileList(&ppFiles, &totalCount, szFilename);
}
CallServiceSync(MS_FILE_SENDSPECIFICFILEST, dat->windowData.hContact, (LPARAM)ppFiles);
- for(i=0;ppFiles[i];i++) mir_free(ppFiles[i]);
+ for (i = 0; ppFiles[i]; i++) mir_free(ppFiles[i]);
mir_free(ppFiles);
}
break;
@@ -1026,7 +1022,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
break;
case DM_TYPING:
- dat->nTypeSecs = (int) lParam > 0 ? (int) lParam : 0;
+ dat->nTypeSecs = (int)lParam > 0 ? (int)lParam : 0;
break;
case DM_CHANGEICONS:
@@ -1041,7 +1037,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
case DM_UPDATEICON:
{
- TitleBarData tbd = {0};
+ TitleBarData tbd = { 0 };
tbd.iFlags = TBDF_ICON;
GetTitlebarIcon(dat, &tbd);
SendMessage(dat->hwndParent, CM_UPDATETITLEBAR, (WPARAM)&tbd, (LPARAM)hwndDlg);
@@ -1052,19 +1048,19 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
SendDlgItemMessage(hwndDlg, IDC_USERMENU, BM_SETIMAGE, IMAGE_ICON, (LPARAM)dat->statusIcon);
}
break;
+
case DM_UPDATETABCONTROL:
- {
- TabControlData tcd;
- tcd.iFlags = TCDF_TEXT | TCDF_ICON;
- tcd.hIcon = GetTabIcon(dat);
- tcd.pszText = GetTabName(dat->windowData.hContact);
- SendMessage(dat->hwndParent, CM_UPDATETABCONTROL, (WPARAM)&tcd, (LPARAM)hwndDlg);
- mir_free(tcd.pszText);
- }
+ TabControlData tcd;
+ tcd.iFlags = TCDF_TEXT | TCDF_ICON;
+ tcd.hIcon = GetTabIcon(dat);
+ tcd.pszText = GetTabName(dat->windowData.hContact);
+ SendMessage(dat->hwndParent, CM_UPDATETABCONTROL, (WPARAM)&tcd, (LPARAM)hwndDlg);
+ mir_free(tcd.pszText);
break;
+
case DM_UPDATETITLEBAR:
{
- TitleBarData tbd = {0};
+ TitleBarData tbd = { 0 };
tbd.iFlags = TBDF_TEXT | TBDF_ICON;
GetTitlebarIcon(dat, &tbd);
tbd.pszText = GetWindowTitle(dat->windowData.hContact, dat->szProto);
@@ -1076,11 +1072,11 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
case DM_CLISTSETTINGSCHANGED:
if (wParam == dat->windowData.hContact) {
if (dat->windowData.hContact && dat->szProto) {
- DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *) lParam;
+ DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *)lParam;
char idbuf[128], buf[128];
GetContactUniqueId(dat, idbuf, sizeof(idbuf));
mir_snprintf(buf, SIZEOF(buf), Translate("User Menu - %s"), idbuf);
- SendMessage(GetDlgItem(hwndDlg, IDC_USERMENU), BUTTONADDTOOLTIP, (WPARAM) buf, 0);
+ SendMessage(GetDlgItem(hwndDlg, IDC_USERMENU), BUTTONADDTOOLTIP, (WPARAM)buf, 0);
if (!cws || (!strcmp(cws->szModule, dat->szProto) && !strcmp(cws->szSetting, "Status")))
dat->wStatus = cws->value.wVal;
@@ -1095,72 +1091,68 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
break;
case DM_OPTIONSAPPLIED:
- {
- PARAFORMAT2 pf2;
- memset(&pf2, 0, sizeof(pf2));
- CHARFORMAT2 cf2;
- memset(&cf2, 0, sizeof(cf2));
- LOGFONT lf;
- COLORREF colour;
- dat->flags &= ~SMF_USEIEVIEW;
- dat->flags |= g_dat.ieviewInstalled ? g_dat.flags & SMF_USEIEVIEW : 0;
- if (dat->flags & SMF_USEIEVIEW && dat->windowData.hwndLog == NULL) {
+ memset(&pf2, 0, sizeof(pf2));
+ memset(&cf2, 0, sizeof(cf2));
+ LOGFONT lf;
+ COLORREF colour;
+ dat->flags &= ~SMF_USEIEVIEW;
+ dat->flags |= g_dat.ieviewInstalled ? g_dat.flags & SMF_USEIEVIEW : 0;
+ if (dat->flags & SMF_USEIEVIEW && dat->windowData.hwndLog == NULL) {
+ IEVIEWWINDOW ieWindow = { sizeof(ieWindow) };
+ ieWindow.iType = IEW_CREATE;
+ ieWindow.dwMode = IEWM_SCRIVER;
+ ieWindow.parent = hwndDlg;
+ ieWindow.cx = 200;
+ ieWindow.cy = 300;
+ CallService(MS_IEVIEW_WINDOW, 0, (LPARAM)&ieWindow);
+ dat->windowData.hwndLog = ieWindow.hwnd;
+ if (dat->windowData.hwndLog == NULL)
+ dat->flags ^= SMF_USEIEVIEW;
+ }
+ else if (!(dat->flags & SMF_USEIEVIEW) && dat->windowData.hwndLog != NULL) {
+ if (dat->windowData.hwndLog != NULL) {
IEVIEWWINDOW ieWindow = { sizeof(ieWindow) };
- ieWindow.iType = IEW_CREATE;
- ieWindow.dwMode = IEWM_SCRIVER;
- ieWindow.parent = hwndDlg;
- ieWindow.cx = 200;
- ieWindow.cy = 300;
+ ieWindow.iType = IEW_DESTROY;
+ ieWindow.hwnd = dat->windowData.hwndLog;
CallService(MS_IEVIEW_WINDOW, 0, (LPARAM)&ieWindow);
- dat->windowData.hwndLog = ieWindow.hwnd;
- if (dat->windowData.hwndLog == NULL)
- dat->flags ^= SMF_USEIEVIEW;
- }
- else if (!(dat->flags & SMF_USEIEVIEW) && dat->windowData.hwndLog != NULL) {
- if (dat->windowData.hwndLog != NULL) {
- IEVIEWWINDOW ieWindow = { sizeof(ieWindow) };
- ieWindow.iType = IEW_DESTROY;
- ieWindow.hwnd = dat->windowData.hwndLog;
- CallService(MS_IEVIEW_WINDOW, 0, (LPARAM)&ieWindow);
- }
- dat->windowData.hwndLog = NULL;
}
+ dat->windowData.hwndLog = NULL;
+ }
- SendMessage(hwndDlg, DM_GETAVATAR, 0, 0);
- SetDialogToType(hwndDlg);
-
- colour = db_get_dw(NULL, SRMMMOD, SRMSGSET_BKGCOLOUR, SRMSGDEFSET_BKGCOLOUR);
- SendDlgItemMessage(hwndDlg, IDC_LOG, EM_SETBKGNDCOLOR, 0, colour);
- colour = db_get_dw(NULL, SRMMMOD, SRMSGSET_INPUTBKGCOLOUR, SRMSGDEFSET_INPUTBKGCOLOUR);
- SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SETBKGNDCOLOR, 0, colour);
- InvalidateRect(GetDlgItem(hwndDlg, IDC_MESSAGE), NULL, FALSE);
- LoadMsgDlgFont(MSGFONTID_MESSAGEAREA, &lf, &colour);
- cf2.cbSize = sizeof(cf2);
- cf2.dwMask = CFM_COLOR | CFM_FACE | CFM_CHARSET | CFM_SIZE | CFM_WEIGHT | CFM_BOLD | CFM_ITALIC;
- cf2.crTextColor = colour;
- cf2.bCharSet = lf.lfCharSet;
- _tcsncpy(cf2.szFaceName, lf.lfFaceName, LF_FACESIZE);
- cf2.dwEffects = ((lf.lfWeight >= FW_BOLD) ? CFE_BOLD : 0) | (lf.lfItalic ? CFE_ITALIC : 0);
- cf2.wWeight = (WORD)lf.lfWeight;
- cf2.bPitchAndFamily = lf.lfPitchAndFamily;
- cf2.yHeight = abs(lf.lfHeight) * 1440 / g_dat.logPixelSY;
- SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SETCHARFORMAT, (WPARAM)SCF_ALL, (LPARAM)&cf2);
- SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SETLANGOPTIONS, 0, (LPARAM)SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_GETLANGOPTIONS, 0, 0) & ~IMF_AUTOKEYBOARD);
+ SendMessage(hwndDlg, DM_GETAVATAR, 0, 0);
+ SetDialogToType(hwndDlg);
- pf2.cbSize = sizeof(pf2);
- pf2.dwMask = PFM_OFFSET;
- pf2.dxOffset = (g_dat.flags & SMF_INDENTTEXT) ? g_dat.indentSize * 1440 / g_dat.logPixelSX : 0;
- SetDlgItemText(hwndDlg, IDC_LOG, _T(""));
- SendDlgItemMessage(hwndDlg, IDC_LOG, EM_SETPARAFORMAT, 0, (LPARAM)&pf2);
- SendDlgItemMessage(hwndDlg, IDC_LOG, EM_SETLANGOPTIONS, 0, (LPARAM)SendDlgItemMessage(hwndDlg, IDC_LOG, EM_GETLANGOPTIONS, 0, 0) & ~(IMF_AUTOKEYBOARD | IMF_AUTOFONTSIZEADJUST));
+ colour = db_get_dw(NULL, SRMMMOD, SRMSGSET_BKGCOLOUR, SRMSGDEFSET_BKGCOLOUR);
+ SendDlgItemMessage(hwndDlg, IDC_LOG, EM_SETBKGNDCOLOR, 0, colour);
+ colour = db_get_dw(NULL, SRMMMOD, SRMSGSET_INPUTBKGCOLOUR, SRMSGDEFSET_INPUTBKGCOLOUR);
+ SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SETBKGNDCOLOR, 0, colour);
+ InvalidateRect(GetDlgItem(hwndDlg, IDC_MESSAGE), NULL, FALSE);
+ LoadMsgDlgFont(MSGFONTID_MESSAGEAREA, &lf, &colour);
+ cf2.cbSize = sizeof(cf2);
+ cf2.dwMask = CFM_COLOR | CFM_FACE | CFM_CHARSET | CFM_SIZE | CFM_WEIGHT | CFM_BOLD | CFM_ITALIC;
+ cf2.crTextColor = colour;
+ cf2.bCharSet = lf.lfCharSet;
+ _tcsncpy(cf2.szFaceName, lf.lfFaceName, LF_FACESIZE);
+ cf2.dwEffects = ((lf.lfWeight >= FW_BOLD) ? CFE_BOLD : 0) | (lf.lfItalic ? CFE_ITALIC : 0);
+ cf2.wWeight = (WORD)lf.lfWeight;
+ cf2.bPitchAndFamily = lf.lfPitchAndFamily;
+ cf2.yHeight = abs(lf.lfHeight) * 1440 / g_dat.logPixelSY;
+ SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SETCHARFORMAT, (WPARAM)SCF_ALL, (LPARAM)&cf2);
+ SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SETLANGOPTIONS, 0, (LPARAM)SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_GETLANGOPTIONS, 0, 0) & ~IMF_AUTOKEYBOARD);
+
+ pf2.cbSize = sizeof(pf2);
+ pf2.dwMask = PFM_OFFSET;
+ pf2.dxOffset = (g_dat.flags & SMF_INDENTTEXT) ? g_dat.indentSize * 1440 / g_dat.logPixelSX : 0;
+ SetDlgItemText(hwndDlg, IDC_LOG, _T(""));
+ SendDlgItemMessage(hwndDlg, IDC_LOG, EM_SETPARAFORMAT, 0, (LPARAM)&pf2);
+ SendDlgItemMessage(hwndDlg, IDC_LOG, EM_SETLANGOPTIONS, 0, (LPARAM)SendDlgItemMessage(hwndDlg, IDC_LOG, EM_GETLANGOPTIONS, 0, 0) & ~(IMF_AUTOKEYBOARD | IMF_AUTOFONTSIZEADJUST));
- SendMessage(hwndDlg, DM_REMAKELOG, 0, 0);
- SendMessage(hwndDlg, DM_UPDATETITLEBAR, 0, 0);
- SendMessage(hwndDlg, DM_UPDATETABCONTROL, 0, 0);
- SendMessage(hwndDlg, DM_UPDATESTATUSBAR, 0, 0);
- SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_REQUESTRESIZE, 0, 0);
- SetupInfobar(dat->infobarData);
- }
+ SendMessage(hwndDlg, DM_REMAKELOG, 0, 0);
+ SendMessage(hwndDlg, DM_UPDATETITLEBAR, 0, 0);
+ SendMessage(hwndDlg, DM_UPDATETABCONTROL, 0, 0);
+ SendMessage(hwndDlg, DM_UPDATESTATUSBAR, 0, 0);
+ SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_REQUESTRESIZE, 0, 0);
+ SetupInfobar(dat->infobarData);
break;
case DM_USERNAMETOCLIP:
@@ -1189,7 +1181,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
return TRUE;
case DM_SETCODEPAGE:
- dat->windowData.codePage = (int) lParam;
+ dat->windowData.codePage = (int)lParam;
SendMessage(hwndDlg, DM_REMAKELOG, 0, 0);
break;
@@ -1208,24 +1200,21 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
break;
case DM_SWITCHRTL:
- {
- PARAFORMAT2 pf2;
- memset(&pf2, 0, sizeof(pf2));
- pf2.cbSize = sizeof(pf2);
- pf2.dwMask = PFM_RTLPARA;
- dat->flags ^= SMF_RTL;
- if (dat->flags&SMF_RTL) {
- pf2.wEffects = PFE_RTLPARA;
- SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_MESSAGE),GWL_EXSTYLE,GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_MESSAGE),GWL_EXSTYLE) | WS_EX_RIGHT | WS_EX_RTLREADING | WS_EX_LEFTSCROLLBAR);
- SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_LOG),GWL_EXSTYLE,GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_LOG),GWL_EXSTYLE) | WS_EX_LEFTSCROLLBAR);
- }
- else {
- pf2.wEffects = 0;
- SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_MESSAGE),GWL_EXSTYLE,GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_MESSAGE),GWL_EXSTYLE) &~ (WS_EX_RIGHT | WS_EX_RTLREADING | WS_EX_LEFTSCROLLBAR));
- SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_LOG),GWL_EXSTYLE,GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_LOG),GWL_EXSTYLE) &~ (WS_EX_LEFTSCROLLBAR));
- }
- SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SETPARAFORMAT, 0, (LPARAM)&pf2);
+ memset(&pf2, 0, sizeof(pf2));
+ pf2.cbSize = sizeof(pf2);
+ pf2.dwMask = PFM_RTLPARA;
+ dat->flags ^= SMF_RTL;
+ if (dat->flags&SMF_RTL) {
+ pf2.wEffects = PFE_RTLPARA;
+ SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_MESSAGE), GWL_EXSTYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_MESSAGE), GWL_EXSTYLE) | WS_EX_RIGHT | WS_EX_RTLREADING | WS_EX_LEFTSCROLLBAR);
+ SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_LOG), GWL_EXSTYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_LOG), GWL_EXSTYLE) | WS_EX_LEFTSCROLLBAR);
}
+ else {
+ pf2.wEffects = 0;
+ SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_MESSAGE), GWL_EXSTYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_MESSAGE), GWL_EXSTYLE) &~(WS_EX_RIGHT | WS_EX_RTLREADING | WS_EX_LEFTSCROLLBAR));
+ SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_LOG), GWL_EXSTYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_LOG), GWL_EXSTYLE) &~(WS_EX_LEFTSCROLLBAR));
+ }
+ SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_SETPARAFORMAT, 0, (LPARAM)&pf2);
SendMessage(hwndDlg, DM_REMAKELOG, 0, 0);
break;
@@ -1234,7 +1223,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
UINT state = MSG_WINDOW_STATE_EXISTS;
if (IsWindowVisible(hwndDlg))
state |= MSG_WINDOW_STATE_VISIBLE;
- if (GetForegroundWindow()==dat->hwndParent)
+ if (GetForegroundWindow() == dat->hwndParent)
state |= MSG_WINDOW_STATE_FOCUS;
if (IsIconic(dat->hwndParent))
state |= MSG_WINDOW_STATE_ICONIC;
@@ -1280,10 +1269,10 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
hLog = dat->windowData.hwndLog;
else
hLog = GetDlgItem(hwndDlg, IDC_LOG);
-
+
RECT rc;
GetWindowRect(hLog, &rc);
- if (pt.x >= rc.left && pt.x <= rc.right && pt.y >= rc.top && pt.y <=rc.bottom)
+ if (pt.x >= rc.left && pt.x <= rc.right && pt.y >= rc.top && pt.y <= rc.bottom)
return TRUE;
}
if (g_dat.hFocusWnd == hwndDlg)
@@ -1297,14 +1286,14 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
return TRUE;
case DM_SETPARENT:
- dat->hwndParent = (HWND) lParam;
- dat->parent = (ParentWindowData *) GetWindowLongPtr(dat->hwndParent, GWLP_USERDATA);
+ dat->hwndParent = (HWND)lParam;
+ dat->parent = (ParentWindowData *)GetWindowLongPtr(dat->hwndParent, GWLP_USERDATA);
SetParent(hwndDlg, dat->hwndParent);
return TRUE;
case WM_GETMINMAXINFO:
{
- MINMAXINFO *mmi = (MINMAXINFO *) lParam;
+ MINMAXINFO *mmi = (MINMAXINFO *)lParam;
mmi->ptMinTrackSize.x = dat->toolbarSize.cx + BOTTOM_RIGHT_AVATAR_HEIGHT;
mmi->ptMinTrackSize.y = dat->windowData.minLogBoxHeight + dat->toolbarSize.cy + dat->windowData.minEditBoxHeight + max(INFO_BAR_HEIGHT, BOTTOM_RIGHT_AVATAR_HEIGHT - dat->toolbarSize.cy) + 5;
}
@@ -1410,7 +1399,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
case DM_UPDATESTATUSBAR:
if (dat->parent->hwndActive == hwndDlg) {
TCHAR szText[256];
- StatusBarData sbd= {0};
+ StatusBarData sbd = { 0 };
sbd.iFlags = SBDF_TEXT | SBDF_ICON;
if (dat->messagesInProgress && (g_dat.flags & SMF_SHOWPROGRESS)) {
sbd.hIcon = GetCachedIcon("scriver_DELIVERING");
@@ -1428,11 +1417,11 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
else if (dat->lastMessage) {
TCHAR date[64], time[64];
tmi.printTimeStamp(NULL, dat->lastMessage, _T("d"), date, SIZEOF(date), 0);
- tmi.printTimeStamp(NULL, dat->lastMessage, _T("t"), time, SIZEOF(time), 0);
+ tmi.printTimeStamp(NULL, dat->lastMessage, _T("t"), time, SIZEOF(time), 0);
mir_sntprintf(szText, SIZEOF(szText), TranslateT("Last message received on %s at %s."), date, time);
sbd.pszText = szText;
}
- else sbd.pszText = _T("");
+ else sbd.pszText = _T("");
SendMessage(dat->hwndParent, CM_UPDATESTATUSBAR, (WPARAM)&sbd, (LPARAM)hwndDlg);
UpdateReadChars(hwndDlg, dat);
@@ -1444,7 +1433,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
sid.dwId = 1;
if (IsTypingNotificationSupported(dat) && g_dat.flags2 & SMF2_SHOWTYPINGSWITCH)
sid.flags = (db_get_b(dat->windowData.hContact, SRMMMOD, SRMSGSET_TYPING,
- db_get_b(NULL, SRMMMOD, SRMSGSET_TYPINGNEW, SRMSGDEFSET_TYPINGNEW))) ? 0 : MBF_DISABLED;
+ db_get_b(NULL, SRMMMOD, SRMSGSET_TYPINGNEW, SRMSGDEFSET_TYPINGNEW))) ? 0 : MBF_DISABLED;
else
sid.flags = MBF_HIDDEN;
@@ -1512,8 +1501,8 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
item->proto = mir_strdup(dat->szProto);
item->flags = msi->flags;
item->codepage = dat->windowData.codePage;
- if ( IsUtfSendAvailable( dat->windowData.hContact )) {
- char *szMsgUtf = mir_utf8encodeW( (TCHAR *)&msi->sendBuffer[strlen(msi->sendBuffer) + 1] );
+ if (IsUtfSendAvailable(dat->windowData.hContact)) {
+ char *szMsgUtf = mir_utf8encodeW((TCHAR*)&msi->sendBuffer[strlen(msi->sendBuffer) + 1]);
item->flags &= ~PREF_UNICODE;
if (!szMsgUtf)
break;
@@ -1528,7 +1517,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
}
else {
item->sendBufferSize = msi->sendBufferSize;
- item->sendBuffer = (char*) mir_alloc(msi->sendBufferSize);
+ item->sendBuffer = (char*)mir_alloc(msi->sendBufferSize);
memcpy(item->sendBuffer, msi->sendBuffer, msi->sendBufferSize);
}
SendMessage(hwndDlg, DM_STARTMESSAGESENDING, 0, 0);
@@ -1556,7 +1545,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
case DM_SHOWERRORMESSAGE:
if (lParam) {
- ErrorWindowData *ewd = (ErrorWindowData *) lParam;
+ ErrorWindowData *ewd = (ErrorWindowData *)lParam;
SendMessage(hwndDlg, DM_STOPMESSAGESENDING, 0, 0);
ewd->queueItem->hwndErrorDlg = CreateDialogParam(g_hInst, MAKEINTRESOURCE(IDD_MSGSENDERROR), hwndDlg, ErrorDlgProc, (LPARAM)ewd);//hwndDlg
}
@@ -1564,7 +1553,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
case DM_ERRORDECIDED:
{
- MessageSendQueueItem *item = (MessageSendQueueItem *) lParam;
+ MessageSendQueueItem *item = (MessageSendQueueItem *)lParam;
item->hwndErrorDlg = NULL;
switch (wParam) {
case MSGERROR_CANCEL:
@@ -1586,13 +1575,13 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
case WM_DRAWITEM:
if (!DrawMenuItem(wParam, lParam)) {
- LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT) lParam;
+ LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lParam;
if (dis->hwndItem == GetDlgItem(hwndDlg, IDC_AVATAR)) {
int avatarWidth = 0, avatarHeight = 0;
int itemWidth = dis->rcItem.right - dis->rcItem.left + 1, itemHeight = dis->rcItem.bottom - dis->rcItem.top + 1;
HDC hdcMem = CreateCompatibleDC(dis->hDC);
HBITMAP hbmMem = CreateCompatibleBitmap(dis->hDC, itemWidth, itemHeight);
- hbmMem = (HBITMAP) SelectObject(hdcMem, hbmMem);
+ hbmMem = (HBITMAP)SelectObject(hdcMem, hbmMem);
RECT rect;
rect.top = 0;
rect.left = 0;
@@ -1603,7 +1592,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
if (dat->avatarPic && (g_dat.flags&SMF_AVATAR)) {
BITMAP bminfo;
GetObject(dat->avatarPic, sizeof(bminfo), &bminfo);
- if ( bminfo.bmWidth != 0 && bminfo.bmHeight != 0 ) {
+ if (bminfo.bmWidth != 0 && bminfo.bmHeight != 0) {
avatarHeight = itemHeight;
avatarWidth = bminfo.bmWidth * avatarHeight / bminfo.bmHeight;
if (avatarWidth > itemWidth) {
@@ -1623,7 +1612,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
}
}
BitBlt(dis->hDC, 0, 0, itemWidth, itemHeight, hdcMem, 0, 0, SRCCOPY);
- hbmMem = (HBITMAP) SelectObject(hdcMem, hbmMem);
+ hbmMem = (HBITMAP)SelectObject(hdcMem, hbmMem);
DeleteObject(hbmMem);
DeleteDC(hdcMem);
return TRUE;
@@ -1637,18 +1626,16 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
switch (LOWORD(wParam)) {
case IDC_SENDALL:
- {
- int result;
- if (dat->sendAllConfirm == 0) {
- result = DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_CONFIRM_SENDALL), hwndDlg, ConfirmSendAllDlgProc, (LPARAM)hwndDlg);
- if (result & 0x10000)
- dat->sendAllConfirm = result;
- }
- else result = dat->sendAllConfirm;
-
- if (LOWORD(result) != IDYES)
- break;
+ int result;
+ if (dat->sendAllConfirm == 0) {
+ result = DialogBoxParam(g_hInst, MAKEINTRESOURCE(IDD_CONFIRM_SENDALL), hwndDlg, ConfirmSendAllDlgProc, (LPARAM)hwndDlg);
+ if (result & 0x10000)
+ dat->sendAllConfirm = result;
}
+ else result = dat->sendAllConfirm;
+
+ if (LOWORD(result) != IDYES)
+ break;
case IDOK:
//this is a 'send' button
@@ -1659,7 +1646,6 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
int ansiBufSize = GetRichTextLength(GetDlgItem(hwndDlg, IDC_MESSAGE), dat->windowData.codePage, TRUE) + 1;
int bufSize = ansiBufSize + GetRichTextLength(GetDlgItem(hwndDlg, IDC_MESSAGE), 1200, TRUE) + 2;
- PARAFORMAT2 pf2;
memset(&pf2, 0, sizeof(pf2));
pf2.cbSize = sizeof(pf2);
pf2.dwMask = PFM_RTLPARA;
@@ -1676,15 +1662,15 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
gt.flags = GT_USECRLF;
gt.cb = ansiBufSize;
gt.codepage = dat->windowData.codePage;
- SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_GETTEXTEX, (WPARAM) &gt, (LPARAM)msi.sendBuffer);
+ SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_GETTEXTEX, (WPARAM)&gt, (LPARAM)msi.sendBuffer);
gt.cb = bufSize - ansiBufSize;
gt.codepage = 1200;
- SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_GETTEXTEX, (WPARAM) &gt, (LPARAM)&msi.sendBuffer[ansiBufSize]);
- if ( RTL_Detect((wchar_t*)&msi.sendBuffer[ansiBufSize] ))
+ SendDlgItemMessage(hwndDlg, IDC_MESSAGE, EM_GETTEXTEX, (WPARAM)&gt, (LPARAM)&msi.sendBuffer[ansiBufSize]);
+ if (RTL_Detect((wchar_t*)&msi.sendBuffer[ansiBufSize]))
msi.flags |= PREF_RTL;
if (msi.sendBuffer[0] == 0) {
- mir_free (msi.sendBuffer);
+ mir_free(msi.sendBuffer);
break;
}
@@ -1712,7 +1698,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
SendMessage(dat->hwndParent, DM_SENDMESSAGE, 0, (LPARAM)&msi);
else
SendMessage(hwndDlg, DM_SENDMESSAGE, 0, (LPARAM)&msi);
- mir_free (msi.sendBuffer);
+ mir_free(msi.sendBuffer);
}
return TRUE;
@@ -1725,7 +1711,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
SendMessage(hwndDlg, DM_USERNAMETOCLIP, 0, 0);
else {
RECT rc;
- HMENU hMenu = (HMENU) CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM) dat->windowData.hContact, 0);
+ HMENU hMenu = (HMENU)CallService(MS_CLIST_MENUBUILDCONTACT, (WPARAM)dat->windowData.hContact, 0);
GetWindowRect(GetDlgItem(hwndDlg, LOWORD(wParam)), &rc);
TrackPopupMenu(hMenu, 0, rc.left, rc.bottom, 0, hwndDlg, NULL);
DestroyMenu(hMenu);
@@ -1733,11 +1719,11 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
break;
case IDC_HISTORY:
- CallService(MS_HISTORY_SHOWCONTACTHISTORY, (WPARAM) dat->windowData.hContact, 0);
+ CallService(MS_HISTORY_SHOWCONTACTHISTORY, (WPARAM)dat->windowData.hContact, 0);
break;
case IDC_DETAILS:
- CallService(MS_USERINFO_SHOWDIALOG, (WPARAM) dat->windowData.hContact, 0);
+ CallService(MS_USERINFO_SHOWDIALOG, (WPARAM)dat->windowData.hContact, 0);
break;
case IDC_SMILEYS:
@@ -1751,7 +1737,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
MCONTACT hContact = db_mc_getSrmmSub(dat->windowData.hContact);
smaddInfo.Protocolname = (hContact != NULL) ? GetContactProto(hContact) : dat->szProto;
-
+
RECT rc;
GetWindowRect(GetDlgItem(hwndDlg, IDC_SMILEYS), &rc);
smaddInfo.Direction = 0;
@@ -1774,9 +1760,9 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
else
buffer = GetRichEditSelection(GetDlgItem(hwndDlg, IDC_LOG));
- if (buffer!=NULL) {
+ if (buffer != NULL) {
TCHAR *quotedBuffer = GetQuotedTextW(buffer);
- SendMessage(GetDlgItem(hwndDlg, IDC_MESSAGE), EM_SETTEXTEX, (WPARAM) &st, (LPARAM)quotedBuffer);
+ SendMessage(GetDlgItem(hwndDlg, IDC_MESSAGE), EM_SETTEXTEX, (WPARAM)&st, (LPARAM)quotedBuffer);
mir_free(quotedBuffer);
mir_free(buffer);
}
@@ -1785,7 +1771,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
dbei.cbBlob = db_event_getBlobSize(dat->hDbEventLast);
if (dbei.cbBlob == 0xFFFFFFFF)
break;
- dbei.pBlob = (PBYTE) mir_alloc(dbei.cbBlob);
+ dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob);
db_event_get(dat->hDbEventLast, &dbei);
if (DbEventIsMessageOrCustom(&dbei)) {
TCHAR *buffer = DbGetEventTextT(&dbei, CP_ACP);
@@ -1808,7 +1794,7 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
acs.hContact = dat->windowData.hContact;
acs.handleType = HANDLE_CONTACT;
acs.szProto = 0;
- CallService(MS_ADDCONTACT_SHOW, (WPARAM) hwndDlg, (LPARAM)&acs);
+ CallService(MS_ADDCONTACT_SHOW, (WPARAM)hwndDlg, (LPARAM)&acs);
}
if (!db_get_b(dat->windowData.hContact, "CList", "NotOnList", 0))
ShowWindow(GetDlgItem(hwndDlg, IDC_ADD), SW_HIDE);
@@ -1832,93 +1818,90 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
break;
}
break;
+
case WM_NOTIFY:
- {
- LPNMHDR pNmhdr = (LPNMHDR)lParam;
- switch (pNmhdr->idFrom) {
- case IDC_LOG:
- switch (pNmhdr->code) {
- case EN_MSGFILTER:
- {
- int result = InputAreaShortcuts(GetDlgItem(hwndDlg, IDC_MESSAGE), ((MSGFILTER *) lParam)->msg, ((MSGFILTER *) lParam)->wParam, ((MSGFILTER *) lParam)->lParam, &dat->windowData);
- if (result != -1) {
- SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, TRUE);
- return TRUE;
- }
- }
- switch (((MSGFILTER *) lParam)->msg) {
- case WM_CHAR:
- if (!(GetKeyState(VK_CONTROL) & 0x8000)) {
- SetFocus(GetDlgItem(hwndDlg, IDC_MESSAGE));
- SendMessage(GetDlgItem(hwndDlg, IDC_MESSAGE), ((MSGFILTER *) lParam)->msg, ((MSGFILTER *) lParam)->wParam, ((MSGFILTER *) lParam)->lParam);
- SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, TRUE);
- }
- return TRUE;
- case WM_LBUTTONDOWN:
- {
- HCURSOR hCur = GetCursor();
- if (hCur == LoadCursor(NULL, IDC_SIZENS) || hCur == LoadCursor(NULL, IDC_SIZEWE)
- || hCur == LoadCursor(NULL, IDC_SIZENESW) || hCur == LoadCursor(NULL, IDC_SIZENWSE)) {
- SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, TRUE);
- return TRUE;
- }
- break;
- }
- case WM_MOUSEMOVE:
- {
- HCURSOR hCur = GetCursor();
- if (hCur == LoadCursor(NULL, IDC_SIZENS) || hCur == LoadCursor(NULL, IDC_SIZEWE)
- || hCur == LoadCursor(NULL, IDC_SIZENESW) || hCur == LoadCursor(NULL, IDC_SIZENWSE))
- SetCursor(LoadCursor(NULL, IDC_ARROW));
- break;
- }
- case WM_RBUTTONUP:
- SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, TRUE);
- return TRUE;
- }
- break;
- case EN_LINK:
- switch (((ENLINK *) lParam)->msg) {
- case WM_SETCURSOR:
- SetCursor(hCurHyperlinkHand);
- SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, TRUE);
- return TRUE;
-
- case WM_RBUTTONDOWN:
- case WM_LBUTTONUP:
- if (HandleLinkClick(g_hInst, hwndDlg, GetDlgItem(hwndDlg, IDC_MESSAGE),(ENLINK*)lParam)) {
- SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, TRUE);
- return TRUE;
- }
- break;
- }
+ pNmhdr = (LPNMHDR)lParam;
+ switch (pNmhdr->idFrom) {
+ case IDC_LOG:
+ switch (pNmhdr->code) {
+ case EN_MSGFILTER:
+ {
+ int result = InputAreaShortcuts(GetDlgItem(hwndDlg, IDC_MESSAGE), ((MSGFILTER *)lParam)->msg, ((MSGFILTER *)lParam)->wParam, ((MSGFILTER *)lParam)->lParam, &dat->windowData);
+ if (result != -1) {
+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, TRUE);
+ return TRUE;
+ }
+ }
+ switch (((MSGFILTER *)lParam)->msg) {
+ case WM_CHAR:
+ if (!(GetKeyState(VK_CONTROL) & 0x8000)) {
+ SetFocus(GetDlgItem(hwndDlg, IDC_MESSAGE));
+ SendMessage(GetDlgItem(hwndDlg, IDC_MESSAGE), ((MSGFILTER *)lParam)->msg, ((MSGFILTER *)lParam)->wParam, ((MSGFILTER *)lParam)->lParam);
+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, TRUE);
+ }
+ return TRUE;
+ case WM_LBUTTONDOWN:
+ {
+ HCURSOR hCur = GetCursor();
+ if (hCur == LoadCursor(NULL, IDC_SIZENS) || hCur == LoadCursor(NULL, IDC_SIZEWE)
+ || hCur == LoadCursor(NULL, IDC_SIZENESW) || hCur == LoadCursor(NULL, IDC_SIZENWSE)) {
+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, TRUE);
+ return TRUE;
}
break;
- case IDC_MESSAGE:
- switch (((NMHDR *) lParam)->code) {
- case EN_MSGFILTER:
- switch (((MSGFILTER *) lParam)->msg) {
- case WM_RBUTTONUP:
+ }
+ case WM_MOUSEMOVE:
+ {
+ HCURSOR hCur = GetCursor();
+ if (hCur == LoadCursor(NULL, IDC_SIZENS) || hCur == LoadCursor(NULL, IDC_SIZEWE)
+ || hCur == LoadCursor(NULL, IDC_SIZENESW) || hCur == LoadCursor(NULL, IDC_SIZENWSE))
+ SetCursor(LoadCursor(NULL, IDC_ARROW));
+ break;
+ }
+ case WM_RBUTTONUP:
+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, TRUE);
+ return TRUE;
+ }
+ break;
+ case EN_LINK:
+ switch (((ENLINK *)lParam)->msg) {
+ case WM_SETCURSOR:
+ SetCursor(hCurHyperlinkHand);
+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, TRUE);
+ return TRUE;
+
+ case WM_RBUTTONDOWN:
+ case WM_LBUTTONUP:
+ if (HandleLinkClick(g_hInst, hwndDlg, GetDlgItem(hwndDlg, IDC_MESSAGE), (ENLINK*)lParam)) {
SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, TRUE);
return TRUE;
}
break;
- case EN_REQUESTRESIZE:
- {
- REQRESIZE *rr = (REQRESIZE *)lParam;
- int height = rr->rc.bottom - rr->rc.top + 1;
- if (height < g_dat.minInputAreaHeight)
- height = g_dat.minInputAreaHeight;
-
- if (dat->desiredInputAreaHeight != height) {
- dat->desiredInputAreaHeight = height;
- SendMessage(hwndDlg, WM_SIZE, 0, 0);
- PostMessage(hwndDlg, DM_SCROLLLOGTOBOTTOM, 0, 0);
- }
- }
- break;
}
}
+ break;
+ case IDC_MESSAGE:
+ switch (((NMHDR *)lParam)->code) {
+ case EN_MSGFILTER:
+ switch (((MSGFILTER *)lParam)->msg) {
+ case WM_RBUTTONUP:
+ SetWindowLongPtr(hwndDlg, DWLP_MSGRESULT, TRUE);
+ return TRUE;
+ }
+ break;
+ case EN_REQUESTRESIZE:
+ REQRESIZE *rr = (REQRESIZE *)lParam;
+ int height = rr->rc.bottom - rr->rc.top + 1;
+ if (height < g_dat.minInputAreaHeight)
+ height = g_dat.minInputAreaHeight;
+
+ if (dat->desiredInputAreaHeight != height) {
+ dat->desiredInputAreaHeight = height;
+ SendMessage(hwndDlg, WM_SIZE, 0, 0);
+ PostMessage(hwndDlg, DM_SCROLLLOGTOBOTTOM, 0, 0);
+ }
+ break;
+ }
}
break;
@@ -1947,11 +1930,11 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP
WindowList_Remove(g_dat.hMessageWindowList, hwndDlg);
HFONT hFont = (HFONT)SendDlgItemMessage(hwndDlg, IDC_MESSAGE, WM_GETFONT, 0, 0);
- if (hFont != NULL && hFont != (HFONT) SendDlgItemMessage(hwndDlg, IDOK, WM_GETFONT, 0, 0))
+ if (hFont != NULL && hFont != (HFONT)SendDlgItemMessage(hwndDlg, IDOK, WM_GETFONT, 0, 0))
DeleteObject(hFont);
- db_set_b(dat->windowData.hContact, SRMMMOD, "UseRTL", (BYTE) ((dat->flags & SMF_RTL) ? 1 : 0));
- db_set_w(dat->windowData.hContact, SRMMMOD, "CodePage", (WORD) dat->windowData.codePage);
+ db_set_b(dat->windowData.hContact, SRMMMOD, "UseRTL", (BYTE)((dat->flags & SMF_RTL) ? 1 : 0));
+ db_set_w(dat->windowData.hContact, SRMMMOD, "CodePage", (WORD)dat->windowData.codePage);
if (dat->windowData.hContact && (g_dat.flags & SMF_DELTEMP))
if (db_get_b(dat->windowData.hContact, "CList", "NotOnList", 0))
CallService(MS_DB_CONTACT_DELETE, (WPARAM)dat->windowData.hContact, 0);
diff --git a/plugins/Scriver/src/msglog.cpp b/plugins/Scriver/src/msglog.cpp
index afd2b0f479..fb75558751 100644
--- a/plugins/Scriver/src/msglog.cpp
+++ b/plugins/Scriver/src/msglog.cpp
@@ -50,19 +50,19 @@ struct EventData
int fontStyle;
COLORREF color;
union {
- char *pszNick; // Nick, usage depends on type of event
- wchar_t *pszNickW; // Nick - Unicode
+ char *pszNick; // Nick, usage depends on type of event
TCHAR *pszNickT;
+ wchar_t *pszNickW; // Nick - Unicode
};
union {
- char *pszText; // Text, usage depends on type of event
- wchar_t *pszTextW; // Text - Unicode
+ char *pszText; // Text, usage depends on type of event
TCHAR *pszTextT;
+ wchar_t *pszTextW; // Text - Unicode
};
union {
- char *pszText2; // Text, usage depends on type of event
- wchar_t *pszText2W; // Text - Unicode
+ char *pszText2; // Text, usage depends on type of event
TCHAR *pszText2T;
+ wchar_t *pszText2W; // Text - Unicode
};
DWORD time;
DWORD eventType;
@@ -73,19 +73,19 @@ struct EventData
struct LogStreamData
{
- int stage;
+ int stage;
MCONTACT hContact;
- HANDLE hDbEvent, hDbEventLast;
- char *buffer;
- int bufferOffset, bufferLen;
- int eventsToInsert;
- int isFirst;
+ HANDLE hDbEvent, hDbEventLast;
+ char *buffer;
+ size_t bufferOffset, bufferLen;
+ int eventsToInsert;
+ int isFirst;
SrmmWindowData *dlgDat;
GlobalMessageData *gdat;
EventData *events;
};
-TCHAR *GetNickname(MCONTACT hContact, const char* szProto)
+TCHAR* GetNickname(MCONTACT hContact, const char *szProto)
{
CONTACTINFO ci = { sizeof(ci) };
ci.hContact = hContact;
@@ -99,12 +99,12 @@ TCHAR *GetNickname(MCONTACT hContact, const char* szProto)
if (ci.type == CNFT_ASCIIZ) {
if (ci.pszVal) {
if (IsUnicodeMIM()) {
- if (!_tcscmp((TCHAR *)ci.pszVal, TranslateW(_T("'(Unknown Contact)'")))) {
+ if (!_tcscmp((TCHAR*)ci.pszVal, TranslateW(_T("'(Unknown Contact)'")))) {
ci.dwFlag &= ~CNF_UNICODE;
if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci))
szName = mir_a2t((char*)ci.pszVal);
}
- else szName = mir_tstrdup((TCHAR *)ci.pszVal);
+ else szName = mir_tstrdup((TCHAR*)ci.pszVal);
}
else szName = mir_a2t((char*)ci.pszVal);
@@ -251,7 +251,7 @@ static void freeEvent(EventData *evt)
mir_free(evt);
}
-static int AppendUnicodeOrAnsiiToBufferL(char **buffer, int *cbBufferEnd, int *cbBufferAlloced, WCHAR * line, int maxLen, BOOL isAnsii)
+static int AppendUnicodeOrAnsiiToBufferL(char **buffer, int *cbBufferEnd, int *cbBufferAlloced, WCHAR *line, size_t maxLen, BOOL isAnsii)
{
int textCharsCount = 0;
int wasEOL = 0;
@@ -297,10 +297,10 @@ static int AppendUnicodeOrAnsiiToBufferL(char **buffer, int *cbBufferEnd, int *c
*d++ = (char)*line;
}
else if (isAnsii) {
- d += sprintf(d, "\\'%02x", (*line) & 0xFF); //!!!!!!!!!!
+ d += sprintf(d, "\\'%02x", (*line) & 0xFF);
}
else {
- d += sprintf(d, "\\u%d ?", *line); //!!!!!!!!!!
+ d += sprintf(d, "\\u%d ?", *line);
}
}
if (wasEOL) {
@@ -314,30 +314,27 @@ static int AppendUnicodeOrAnsiiToBufferL(char **buffer, int *cbBufferEnd, int *c
return textCharsCount;
}
-static int AppendAnsiToBufferL(char **buffer, int *cbBufferEnd, int *cbBufferAlloced, const char * line, int maxLen)
+static int AppendAnsiToBufferL(char **buffer, int *cbBufferEnd, int *cbBufferAlloced, const char *line)
{
- WCHAR *wline = a2w(line, maxLen);
- int i = AppendUnicodeOrAnsiiToBufferL(buffer, cbBufferEnd, cbBufferAlloced, wline, maxLen, TRUE);
- mir_free(wline);
- return i;
+ return AppendUnicodeOrAnsiiToBufferL(buffer, cbBufferEnd, cbBufferAlloced, _A2T(line), -1, TRUE);
}
-static int AppendUnicodeToBufferL(char **buffer, int *cbBufferEnd, int *cbBufferAlloced, WCHAR * line, int maxLen)
+static int AppendUnicodeToBufferL(char **buffer, int *cbBufferEnd, int *cbBufferAlloced, WCHAR *line, size_t maxLen)
{
return AppendUnicodeOrAnsiiToBufferL(buffer, cbBufferEnd, cbBufferAlloced, line, maxLen, FALSE);
}
-static int AppendAnsiToBuffer(char **buffer, int *cbBufferEnd, int *cbBufferAlloced, const char * line)
+static int AppendAnsiToBuffer(char **buffer, int *cbBufferEnd, int *cbBufferAlloced, const char *line)
{
- return AppendAnsiToBufferL(buffer, cbBufferEnd, cbBufferAlloced, line, -1);
+ return AppendAnsiToBufferL(buffer, cbBufferEnd, cbBufferAlloced, line);
}
-static int AppendUnicodeToBuffer(char **buffer, int *cbBufferEnd, int *cbBufferAlloced, WCHAR * line)
+static int AppendUnicodeToBuffer(char **buffer, int *cbBufferEnd, int *cbBufferAlloced, WCHAR *line)
{
return AppendUnicodeToBufferL(buffer, cbBufferEnd, cbBufferAlloced, line, -1);
}
-static int AppendTToBuffer(char **buffer, int *cbBufferEnd, int *cbBufferAlloced, TCHAR * line)
+static int AppendTToBuffer(char **buffer, int *cbBufferEnd, int *cbBufferAlloced, TCHAR *line)
{
return AppendUnicodeToBuffer(buffer, cbBufferEnd, cbBufferAlloced, line);
}
@@ -513,24 +510,22 @@ static int DetectURL(wchar_t *text, BOOL firstChar) {
static void AppendWithCustomLinks(EventData *evt, int style, char **buffer, int *bufferEnd, int *bufferAlloced)
{
- int lasttoken = 0;
- int laststart = 0;
- int j, len;
- WCHAR *wText;
- BOOL isAnsii = (evt->dwFlags & IEEDF_UNICODE_TEXT) == 0;
-
if (evt->pszText == NULL)
return;
+ BOOL isAnsii = (evt->dwFlags & IEEDF_UNICODE_TEXT) == 0;
+ WCHAR *wText;
+ int lasttoken = 0;
+ size_t len, laststart = 0;
if (isAnsii) {
- len = (int)strlen(evt->pszText);
- wText = a2w(evt->pszText, len);
+ len = strlen(evt->pszText);
+ wText = mir_a2u(evt->pszText);
}
else {
wText = evt->pszTextW;
len = (int)wcslen(evt->pszTextW);
}
- for (j = 0; j < len; j++) {
+ for (size_t j = 0; j < len; j++) {
int newtoken = 0;
int l = DetectURL(wText + j, j == 0);
if (l > 0)
@@ -814,7 +809,7 @@ static DWORD CALLBACK LogStreamInEvents(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG
}
dat->bufferLen = mir_strlen(dat->buffer);
}
- *pcb = min(cb, dat->bufferLen - dat->bufferOffset);
+ *pcb = min(cb, LONG(dat->bufferLen - dat->bufferOffset));
CopyMemory(pbBuff, dat->buffer + dat->bufferOffset, *pcb);
dat->bufferOffset += *pcb;
if (dat->bufferOffset == dat->bufferLen) {
diff --git a/plugins/Scriver/src/msgoptions.cpp b/plugins/Scriver/src/msgoptions.cpp
index 54b39dc590..0f0a8d85a4 100644
--- a/plugins/Scriver/src/msgoptions.cpp
+++ b/plugins/Scriver/src/msgoptions.cpp
@@ -868,9 +868,9 @@ static INT_PTR CALLBACK DlgProcTypeOptions(HWND hwndDlg, UINT msg, WPARAM wParam
{
CLCINFOITEM cii = { sizeof(cii) };
cii.flags = CLCIIF_GROUPFONT | CLCIIF_CHECKBOX;
- cii.pszText = (TCHAR *)TranslateT("** New contacts **");
+ cii.pszText = (TCHAR*)TranslateT("** New contacts **");
hItemNew = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_ADDINFOITEM, 0, (LPARAM)&cii);
- cii.pszText = (TCHAR *)TranslateT("** Unknown contacts **");
+ cii.pszText = (TCHAR*)TranslateT("** Unknown contacts **");
hItemUnknown = (HANDLE)SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_ADDINFOITEM, 0, (LPARAM)&cii);
}
SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_CLIST), GWL_STYLE, GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_CLIST), GWL_STYLE) | CLS_SHOWHIDDEN | CLS_NOHIDEOFFLINE);
diff --git a/plugins/Scriver/src/msgs.cpp b/plugins/Scriver/src/msgs.cpp
index 0b9262c7ec..b194f65386 100644
--- a/plugins/Scriver/src/msgs.cpp
+++ b/plugins/Scriver/src/msgs.cpp
@@ -207,7 +207,7 @@ static int TypingMessage(WPARAM hContact, LPARAM lParam)
else if (lParam && (g_dat.flags2 & SMF2_SHOWTYPINGTRAY)) {
TCHAR szTip[256];
- mir_sntprintf(szTip, SIZEOF(szTip), TranslateT("%s is typing a message"), (TCHAR *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, GCDNF_TCHAR));
+ mir_sntprintf(szTip, SIZEOF(szTip), TranslateT("%s is typing a message"), (TCHAR*) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, hContact, GCDNF_TCHAR));
if ( ServiceExists(MS_CLIST_SYSTRAY_NOTIFY) && !(g_dat.flags2 & SMF2_SHOWTYPINGCLIST)) {
MIRANDASYSTRAYNOTIFY tn;
tn.szProto = NULL;
diff --git a/plugins/Scriver/src/msgs.h b/plugins/Scriver/src/msgs.h
index c4ee89001c..aa2fcda2f9 100644
--- a/plugins/Scriver/src/msgs.h
+++ b/plugins/Scriver/src/msgs.h
@@ -226,7 +226,6 @@ INT_PTR CALLBACK ErrorDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPar
int DbEventIsShown(DBEVENTINFO *dbei, SrmmWindowData *dat);
int DbEventIsCustomForMsgWindow(DBEVENTINFO *dbei);
int DbEventIsMessageOrCustom(DBEVENTINFO *dbei);
-int safe_wcslen(wchar_t *msg, int maxLen);
void StreamInEvents(HWND hwndDlg, HANDLE hDbEventFirst, int count, int fAppend);
void LoadMsgLogIcons(void);
void FreeMsgLogIcons(void);
diff --git a/plugins/Scriver/src/msgwindow.cpp b/plugins/Scriver/src/msgwindow.cpp
index 66a387739c..1504e4a8e5 100644
--- a/plugins/Scriver/src/msgwindow.cpp
+++ b/plugins/Scriver/src/msgwindow.cpp
@@ -40,9 +40,9 @@ static const TCHAR *titleTokenNames[] = {_T("%name%"), _T("%status%"), _T("%stat
TCHAR* GetWindowTitle(MCONTACT hContact, const char *szProto)
{
int isTemplate;
- int i, j, len;
- TCHAR* tokens[4] = {0};
- int tokenLen[4] = {0};
+ int i, j;
+ TCHAR* tokens[4] = { 0 };
+ size_t tokenLen[4] = { 0 };
TCHAR *p, *tmplt, *title;
char *accModule;
TCHAR *pszNewTitleEnd = mir_tstrdup(TranslateT("Message Session"));
@@ -87,6 +87,7 @@ TCHAR* GetWindowTitle(MCONTACT hContact, const char *szProto)
}
else tmplt = _T("");
+ size_t len;
for (len = 0, p = tmplt; *p; p++, len++) {
if (*p == '%') {
for (i = 0; i < SIZEOF(titleTokenNames); i++) {
@@ -102,14 +103,14 @@ TCHAR* GetWindowTitle(MCONTACT hContact, const char *szProto)
if (!isTemplate)
len += mir_tstrlen(pszNewTitleEnd);
- title = (TCHAR *)mir_alloc(sizeof(TCHAR) * (len + 1));
+ title = (TCHAR*)mir_alloc(sizeof(TCHAR) * (len + 1));
for (len = 0, p = tmplt; *p; p++) {
if (*p == '%') {
- for (i = 0; i < SIZEOF(titleTokenNames); i ++) {
- int tnlen = mir_tstrlen(titleTokenNames[i]);
+ for (i = 0; i < SIZEOF(titleTokenNames); i++) {
+ size_t tnlen = mir_tstrlen(titleTokenNames[i]);
if (!_tcsncmp(p, titleTokenNames[i], tnlen)) {
if (tokens[i] != NULL) {
- memcpy(title+len, tokens[i], sizeof(TCHAR) * tokenLen[i]);
+ memcpy(title + len, tokens[i], sizeof(TCHAR) * tokenLen[i]);
len += tokenLen[i];
}
p += tnlen - 1;
@@ -121,7 +122,7 @@ TCHAR* GetWindowTitle(MCONTACT hContact, const char *szProto)
title[len++] = *p;
}
if (!isTemplate) {
- memcpy(title+len, pszNewTitleEnd, sizeof(TCHAR) * mir_tstrlen(pszNewTitleEnd));
+ memcpy(title + len, pszNewTitleEnd, sizeof(TCHAR) * mir_tstrlen(pszNewTitleEnd));
len += mir_tstrlen(pszNewTitleEnd);
}
title[len] = '\0';
@@ -196,7 +197,7 @@ static MessageWindowTabData * GetChildFromTab(HWND hwndTabs, int tabId)
TCITEM tci = { 0 };
tci.mask = TCIF_PARAM;
if (TabCtrl_GetItem(hwndTabs, tabId, &tci))
- return (MessageWindowTabData *) tci.lParam;
+ return (MessageWindowTabData *)tci.lParam;
return NULL;
}
@@ -222,7 +223,7 @@ static void GetMinimunWindowSize(ParentWindowData *dat, SIZE *size)
int minW = 216, minH = 80;
GetWindowRect(dat->hwnd, &rcWindow);
GetChildWindowRect(dat, &rc);
- for (int i = 0; i<dat->childrenCount; i++) {
+ for (int i = 0; i < dat->childrenCount; i++) {
MessageWindowTabData * mwtd = GetChildFromTab(dat->hwndTabs, i);
SendMessage(mwtd->hwnd, WM_GETMINMAXINFO, 0, (LPARAM)&mmi);
if (i == 0 || mmi.ptMinTrackSize.x > minW) minW = mmi.ptMinTrackSize.x;
@@ -288,7 +289,7 @@ static void ActivateChild(ParentWindowData *dat, HWND child)
{
RECT rcChild;
GetChildWindowRect(dat, &rcChild);
- SetWindowPos(child, HWND_TOP, rcChild.left, rcChild.top, rcChild.right-rcChild.left, rcChild.bottom - rcChild.top, SWP_NOSIZE);
+ SetWindowPos(child, HWND_TOP, rcChild.left, rcChild.top, rcChild.right - rcChild.left, rcChild.bottom - rcChild.top, SWP_NOSIZE);
int i = GetTabFromHWND(dat, child);
if (i == -1)
@@ -375,7 +376,7 @@ static void ActivateNextChild(ParentWindowData *dat, HWND child)
{
int i = GetTabFromHWND(dat, child);
int l = TabCtrl_GetItemCount(dat->hwndTabs);
- i = (i+1) % l;
+ i = (i + 1) % l;
ActivateChild(dat, GetChildFromTab(dat->hwndTabs, i)->hwnd);
}
@@ -383,7 +384,7 @@ static void ActivatePrevChild(ParentWindowData *dat, HWND child)
{
int i = GetTabFromHWND(dat, child);
int l = TabCtrl_GetItemCount(dat->hwndTabs);
- i = (i+l-1) % l;
+ i = (i + l - 1) % l;
ActivateChild(dat, GetChildFromTab(dat->hwndTabs, i)->hwnd);
}
@@ -733,15 +734,15 @@ INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
{
DWORD ws;
ParentWindowData *dat;
- dat = (ParentWindowData *) GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
- if (!dat && msg!=WM_INITDIALOG) return FALSE;
+ dat = (ParentWindowData *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
+ if (!dat && msg != WM_INITDIALOG) return FALSE;
switch (msg) {
case WM_INITDIALOG:
+ HMENU hMenu;
{
- HMENU hMenu;
int savePerContact = db_get_b(NULL, SRMMMOD, SRMSGSET_SAVEPERCONTACT, SRMSGDEFSET_SAVEPERCONTACT);
- NewMessageWindowLParam *newData = (NewMessageWindowLParam *) lParam;
- dat = (ParentWindowData *) mir_alloc(sizeof(ParentWindowData));
+ NewMessageWindowLParam *newData = (NewMessageWindowLParam *)lParam;
+ dat = (ParentWindowData *)mir_alloc(sizeof(ParentWindowData));
dat->hContact = newData->hContact;
dat->nFlash = 0;
dat->nFlashMax = db_get_b(NULL, SRMMMOD, SRMSGSET_FLASHCOUNT, SRMSGDEFSET_FLASHCOUNT);
@@ -758,7 +759,7 @@ INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
//SetupStatusBar(dat);
dat->hwndTabs = GetDlgItem(hwndDlg, IDC_TABS);
dat->hwndActive = NULL;
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR) dat);
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)dat);
if (g_dat.hTabIconList != NULL)
TabCtrl_SetImageList(dat->hwndTabs, g_dat.hTabIconList);
@@ -785,15 +786,15 @@ INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
SetWindowPos(hwndDlg, 0, 0, 0, 450, 300, SWP_NOZORDER | SWP_NOMOVE | SWP_HIDEWINDOW);
if (!savePerContact && db_get_b(NULL, SRMMMOD, SRMSGSET_CASCADE, SRMSGDEFSET_CASCADE))
- WindowList_Broadcast(g_dat.hParentWindowList, DM_CASCADENEWWINDOW, (WPARAM) hwndDlg, (LPARAM)&dat->windowWasCascaded);
+ WindowList_Broadcast(g_dat.hParentWindowList, DM_CASCADENEWWINDOW, (WPARAM)hwndDlg, (LPARAM)&dat->windowWasCascaded);
- hMenu = GetSystemMenu( hwndDlg, FALSE );
- InsertMenu( hMenu, 0, MF_BYPOSITION | MF_SEPARATOR, 0, NULL );
+ hMenu = GetSystemMenu(hwndDlg, FALSE);
+ InsertMenu(hMenu, 0, MF_BYPOSITION | MF_SEPARATOR, 0, NULL);
if (dat->bTopmost) {
- InsertMenu( hMenu, 0, MF_BYPOSITION | MF_ENABLED | MF_CHECKED | MF_STRING, IDM_TOPMOST, TranslateT("Always On Top"));
+ InsertMenu(hMenu, 0, MF_BYPOSITION | MF_ENABLED | MF_CHECKED | MF_STRING, IDM_TOPMOST, TranslateT("Always On Top"));
SetWindowPos(hwndDlg, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
}
- else InsertMenu( hMenu, 0, MF_BYPOSITION | MF_ENABLED | MF_UNCHECKED | MF_STRING, IDM_TOPMOST, TranslateT("Always On Top"));
+ else InsertMenu(hMenu, 0, MF_BYPOSITION | MF_ENABLED | MF_UNCHECKED | MF_STRING, IDM_TOPMOST, TranslateT("Always On Top"));
}
return TRUE;
@@ -831,8 +832,8 @@ INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
if (wParam == SIZE_MINIMIZED)
dat->bMinimized = 1;
- if ( IsIconic(hwndDlg))
- MoveWindow(dat->hwndActive, dat->childRect.left, dat->childRect.top, dat->childRect.right-dat->childRect.left, dat->childRect.bottom - dat->childRect.top, TRUE);
+ if (IsIconic(hwndDlg))
+ MoveWindow(dat->hwndActive, dat->childRect.left, dat->childRect.top, dat->childRect.right - dat->childRect.left, dat->childRect.bottom - dat->childRect.top, TRUE);
else {
RECT rc, rcStatus, rcChild, rcWindow;
SIZE size;
@@ -844,19 +845,19 @@ INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
GetWindowRect(dat->hwndStatus, &rcStatus);
SetupStatusBar(dat);
}
- MoveWindow(dat->hwndTabs, 0, 2, (rc.right - rc.left), (rc.bottom - rc.top) - (rcStatus.bottom - rcStatus.top) - 2, FALSE);
+ MoveWindow(dat->hwndTabs, 0, 2, (rc.right - rc.left), (rc.bottom - rc.top) - (rcStatus.bottom - rcStatus.top) - 2, FALSE);
RedrawWindow(dat->hwndTabs, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_ERASE);
GetMinimunWindowSize(dat, &size);
- if ((rcWindow.bottom-rcWindow.top) < size.cy || (rcWindow.right-rcWindow.left) < size.cx) {
- if ((rcWindow.bottom-rcWindow.top) < size.cy)
+ if ((rcWindow.bottom - rcWindow.top) < size.cy || (rcWindow.right - rcWindow.left) < size.cx) {
+ if ((rcWindow.bottom - rcWindow.top) < size.cy)
rcWindow.bottom = rcWindow.top + size.cy;
- if ((rcWindow.right-rcWindow.left) < size.cx)
+ if ((rcWindow.right - rcWindow.left) < size.cx)
rcWindow.right = rcWindow.left + size.cx;
- MoveWindow(hwndDlg, rcWindow.left, rcWindow.top, rcWindow.right - rcWindow.left, rcWindow.bottom - rcWindow.top, TRUE);
+ MoveWindow(hwndDlg, rcWindow.left, rcWindow.top, rcWindow.right - rcWindow.left, rcWindow.bottom - rcWindow.top, TRUE);
}
GetChildWindowRect(dat, &rcChild);
memcpy(&dat->childRect, &rcChild, sizeof(RECT));
- MoveWindow(dat->hwndActive, rcChild.left, rcChild.top, rcChild.right-rcChild.left, rcChild.bottom - rcChild.top, TRUE);
+ MoveWindow(dat->hwndActive, rcChild.left, rcChild.top, rcChild.right - rcChild.left, rcChild.bottom - rcChild.top, TRUE);
RedrawWindow(GetDlgItem(dat->hwndActive, IDC_LOG), NULL, NULL, RDW_INVALIDATE);
if (dat->flags2 & SMF2_SHOWSTATUSBAR) {
SendMessage(dat->hwndStatus, WM_SIZE, 0, 0);
@@ -882,7 +883,7 @@ INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
case WM_DRAWITEM:
{
- LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT) lParam;
+ LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lParam;
if (dat && dat->hwndActive && dis->hwndItem == dat->hwndStatus) {
MessageWindowTabData *mwtd = GetChildFromHWND(dat, dat->hwndActive);
if (mwtd != NULL)
@@ -906,62 +907,62 @@ INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
case WM_NOTIFY:
{
- NMHDR* pNMHDR = (NMHDR*) lParam;
+ NMHDR *pNMHDR = (NMHDR*)lParam;
if (pNMHDR->hwndFrom == dat->hwndTabs) {
switch (pNMHDR->code) {
case TCN_SELCHANGE:
- {
- TCITEM tci = {0};
- int iSel = TabCtrl_GetCurSel(dat->hwndTabs);
- tci.mask = TCIF_PARAM;
- if (TabCtrl_GetItem(dat->hwndTabs, iSel, &tci)) {
- MessageWindowTabData * mwtd = (MessageWindowTabData *) tci.lParam;
- ActivateChild(dat, mwtd->hwnd);
- SetFocus(dat->hwndActive);
- }
+ {
+ TCITEM tci = { 0 };
+ int iSel = TabCtrl_GetCurSel(dat->hwndTabs);
+ tci.mask = TCIF_PARAM;
+ if (TabCtrl_GetItem(dat->hwndTabs, iSel, &tci)) {
+ MessageWindowTabData * mwtd = (MessageWindowTabData *)tci.lParam;
+ ActivateChild(dat, mwtd->hwnd);
+ SetFocus(dat->hwndActive);
}
- break;
+ }
+ break;
case NM_RCLICK:
- {
- TCHITTESTINFO thinfo;
- GetCursorPos(&thinfo.pt);
-
- int x = thinfo.pt.x;
- int y = thinfo.pt.y;
- ScreenToClient(dat->hwndTabs, &thinfo.pt);
- int tabId = TabCtrl_HitTest(dat->hwndTabs, &thinfo);
- if (tabId != -1) {
- HMENU hMenu, hSubMenu, hUserMenu;
- BOOL menuResult;
- MessageWindowTabData * mwtd = GetChildFromTab(dat->hwndTabs, tabId);
- hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_CONTEXT));
- hSubMenu = GetSubMenu(hMenu, 3);
- TranslateMenu(hSubMenu);
- hUserMenu = (HMENU) SendMessage(mwtd->hwnd, DM_GETCONTEXTMENU, 0, 0);
- if (hUserMenu != NULL) {
- InsertMenu(hSubMenu, 0, MF_POPUP | MF_BYPOSITION, (UINT_PTR)hUserMenu, TranslateT("User Menu"));
- InsertMenu(hSubMenu, 1, MF_SEPARATOR | MF_BYPOSITION, 0, 0);
- }
- menuResult = TrackPopupMenu(hSubMenu, TPM_RETURNCMD, x, y, 0, hwndDlg, NULL);
- switch (menuResult) {
- case IDM_CLOSETAB:
- SendMessage(mwtd->hwnd, WM_CLOSE, 0, 0);
- break;
- case IDM_CLOSEOTHERTABS:
- CloseOtherChilden(dat, mwtd->hwnd);
- break;
- default:
- CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(menuResult), MPCF_CONTACTMENU), (LPARAM)mwtd->hContact);
- }
- if (hUserMenu != NULL)
- DestroyMenu(hUserMenu);
- DestroyMenu(hMenu);
+ {
+ TCHITTESTINFO thinfo;
+ GetCursorPos(&thinfo.pt);
+
+ int x = thinfo.pt.x;
+ int y = thinfo.pt.y;
+ ScreenToClient(dat->hwndTabs, &thinfo.pt);
+ int tabId = TabCtrl_HitTest(dat->hwndTabs, &thinfo);
+ if (tabId != -1) {
+ HMENU hMenu, hSubMenu, hUserMenu;
+ BOOL menuResult;
+ MessageWindowTabData * mwtd = GetChildFromTab(dat->hwndTabs, tabId);
+ hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_CONTEXT));
+ hSubMenu = GetSubMenu(hMenu, 3);
+ TranslateMenu(hSubMenu);
+ hUserMenu = (HMENU)SendMessage(mwtd->hwnd, DM_GETCONTEXTMENU, 0, 0);
+ if (hUserMenu != NULL) {
+ InsertMenu(hSubMenu, 0, MF_POPUP | MF_BYPOSITION, (UINT_PTR)hUserMenu, TranslateT("User Menu"));
+ InsertMenu(hSubMenu, 1, MF_SEPARATOR | MF_BYPOSITION, 0, 0);
+ }
+ menuResult = TrackPopupMenu(hSubMenu, TPM_RETURNCMD, x, y, 0, hwndDlg, NULL);
+ switch (menuResult) {
+ case IDM_CLOSETAB:
+ SendMessage(mwtd->hwnd, WM_CLOSE, 0, 0);
+ break;
+ case IDM_CLOSEOTHERTABS:
+ CloseOtherChilden(dat, mwtd->hwnd);
+ break;
+ default:
+ CallService(MS_CLIST_MENUPROCESSCOMMAND, MAKEWPARAM(LOWORD(menuResult), MPCF_CONTACTMENU), (LPARAM)mwtd->hContact);
}
+ if (hUserMenu != NULL)
+ DestroyMenu(hUserMenu);
+ DestroyMenu(hMenu);
}
- break;
+ }
+ break;
}
}
- else if (pNMHDR->hwndFrom == dat->hwndStatus) {
+ else if (pNMHDR->hwndFrom == dat->hwndStatus) {
switch (pNMHDR->code) {
case NM_CLICK:
NMMOUSE *nm = (NMMOUSE*)lParam;
@@ -1035,9 +1036,9 @@ INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
}
ws = GetWindowLongPtr(hwndDlg, GWL_EXSTYLE) & ~WS_EX_LAYERED;
ws |= dat->flags2 & SMF2_USETRANSPARENCY ? WS_EX_LAYERED : 0;
- SetWindowLongPtr(hwndDlg , GWL_EXSTYLE , ws);
+ SetWindowLongPtr(hwndDlg, GWL_EXSTYLE, ws);
if (dat->flags2 & SMF2_USETRANSPARENCY)
- SetLayeredWindowAttributes(hwndDlg, RGB(255,255,255), (BYTE)(255-g_dat.activeAlpha), LWA_ALPHA);
+ SetLayeredWindowAttributes(hwndDlg, RGB(255, 255, 255), (BYTE)(255 - g_dat.activeAlpha), LWA_ALPHA);
break;
case WM_LBUTTONDOWN:
@@ -1056,29 +1057,29 @@ INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
POINT pt;
MONITORINFO mi;
HMONITOR hMonitor = MonitorFromRect(pRect, MONITOR_DEFAULTTONEAREST);
- SIZE szSize = {pRect->right-pRect->left,pRect->bottom-pRect->top};
+ SIZE szSize = { pRect->right - pRect->left, pRect->bottom - pRect->top };
mi.cbSize = sizeof(mi);
GetMonitorInfo(hMonitor, &mi);
GetCursorPos(&pt);
rcDesktop = mi.rcWork;
- pRect->left = pt.x-dat->mouseLBDownPos.x;
- pRect->top = pt.y-dat->mouseLBDownPos.y;
- pRect->right = pRect->left+szSize.cx;
- pRect->bottom = pRect->top+szSize.cy;
- if (pRect->top < rcDesktop.top+snapPixels && pRect->top > rcDesktop.top-snapPixels) {
+ pRect->left = pt.x - dat->mouseLBDownPos.x;
+ pRect->top = pt.y - dat->mouseLBDownPos.y;
+ pRect->right = pRect->left + szSize.cx;
+ pRect->bottom = pRect->top + szSize.cy;
+ if (pRect->top < rcDesktop.top + snapPixels && pRect->top > rcDesktop.top - snapPixels) {
pRect->top = rcDesktop.top;
pRect->bottom = rcDesktop.top + szSize.cy;
}
- if (pRect->left < rcDesktop.left+snapPixels && pRect->left > rcDesktop.left-snapPixels) {
+ if (pRect->left < rcDesktop.left + snapPixels && pRect->left > rcDesktop.left - snapPixels) {
pRect->left = rcDesktop.left;
pRect->right = rcDesktop.left + szSize.cx;
}
- if (pRect->right < rcDesktop.right+snapPixels && pRect->right > rcDesktop.right-snapPixels) {
+ if (pRect->right < rcDesktop.right + snapPixels && pRect->right > rcDesktop.right - snapPixels) {
pRect->right = rcDesktop.right;
pRect->left = rcDesktop.right - szSize.cx;
}
- if (pRect->bottom < rcDesktop.bottom+snapPixels && pRect->bottom > rcDesktop.bottom-snapPixels) {
+ if (pRect->bottom < rcDesktop.bottom + snapPixels && pRect->bottom > rcDesktop.bottom - snapPixels) {
pRect->bottom = rcDesktop.bottom;
pRect->top = rcDesktop.bottom - szSize.cy;
}
@@ -1100,7 +1101,7 @@ INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
}
else if (wParam == IDM_TOPMOST) {
HMENU hMenu = GetSystemMenu(hwndDlg, FALSE);
- if (dat->bTopmost) {
+ if (dat->bTopmost) {
CheckMenuItem(hMenu, IDM_TOPMOST, MF_BYCOMMAND | MF_UNCHECKED);
SetWindowPos(hwndDlg, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
dat->bTopmost = FALSE;
@@ -1113,20 +1114,20 @@ INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
}
break;
case WM_DESTROY:
- {
- char szSettingName[64];
- for (int i = dat->childrenCount; i >= 0; i--) {
- TCITEM tci;
- tci.mask = TCIF_PARAM | TCIF_IMAGE;
- if (TabCtrl_GetItem(dat->hwndTabs, i, &tci)) {
- mir_free((MessageWindowTabData *)tci.lParam);
- ReleaseIcon(tci.iImage);
- TabCtrl_DeleteItem(dat->hwndTabs, i);
- }
- }
- SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0);
- WindowList_Remove(g_dat.hParentWindowList, hwndDlg);
+ char szSettingName[64];
+ for (int i = dat->childrenCount; i >= 0; i--) {
+ TCITEM tci;
+ tci.mask = TCIF_PARAM | TCIF_IMAGE;
+ if (TabCtrl_GetItem(dat->hwndTabs, i, &tci)) {
+ mir_free((MessageWindowTabData *)tci.lParam);
+ ReleaseIcon(tci.iImage);
+ TabCtrl_DeleteItem(dat->hwndTabs, i);
+ }
+ }
+ SetWindowLongPtr(hwndDlg, GWLP_USERDATA, 0);
+ WindowList_Remove(g_dat.hParentWindowList, hwndDlg);
+ {
int savePerContact = db_get_b(NULL, SRMMMOD, SRMSGSET_SAVEPERCONTACT, SRMSGDEFSET_SAVEPERCONTACT);
MCONTACT hContact = (savePerContact) ? dat->hContact : NULL;
@@ -1297,43 +1298,43 @@ INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
break;
case CM_UPDATETABCONTROL:
- {
- TCHAR *ptszTemp = NULL;
- TabControlData *tcd = (TabControlData *) wParam;
- int tabId = GetTabFromHWND(dat, (HWND) lParam);
- if (tabId >= 0 && tcd != NULL) {
- TCITEM tci;
- tci.mask = 0;
- if (tcd->iFlags & TCDF_TEXT) {
- tci.mask |= TCIF_TEXT;
- tci.pszText = tcd->pszText;
- if (g_dat.flags2 & SMF2_LIMITNAMES) {
- TCHAR * ltext = limitText(tcd->pszText, g_dat.limitNamesLength);
- if (ltext != tcd->pszText)
- tci.pszText = ptszTemp = ltext;
- }
+ {
+ TCHAR *ptszTemp = NULL;
+ TabControlData *tcd = (TabControlData *)wParam;
+ int tabId = GetTabFromHWND(dat, (HWND)lParam);
+ if (tabId >= 0 && tcd != NULL) {
+ TCITEM tci;
+ tci.mask = 0;
+ if (tcd->iFlags & TCDF_TEXT) {
+ tci.mask |= TCIF_TEXT;
+ tci.pszText = tcd->pszText;
+ if (g_dat.flags2 & SMF2_LIMITNAMES) {
+ TCHAR * ltext = limitText(tcd->pszText, g_dat.limitNamesLength);
+ if (ltext != tcd->pszText)
+ tci.pszText = ptszTemp = ltext;
}
- if (tcd->iFlags & TCDF_ICON) {
- int iconIdx = -1;
- if (tcd->hIcon != NULL) {
- TCITEM tci2;
- tci2.mask = TCIF_IMAGE;
- TabCtrl_GetItem(dat->hwndTabs, tabId, &tci2);
- iconIdx = AddOrReplaceIcon(g_dat.hTabIconList, tci2.iImage, tcd->hIcon);
- }
- tci.mask |= TCIF_IMAGE;
- tci.iImage = iconIdx;
+ }
+ if (tcd->iFlags & TCDF_ICON) {
+ int iconIdx = -1;
+ if (tcd->hIcon != NULL) {
+ TCITEM tci2;
+ tci2.mask = TCIF_IMAGE;
+ TabCtrl_GetItem(dat->hwndTabs, tabId, &tci2);
+ iconIdx = AddOrReplaceIcon(g_dat.hTabIconList, tci2.iImage, tcd->hIcon);
}
- TabCtrl_SetItem(dat->hwndTabs, tabId, &tci);
+ tci.mask |= TCIF_IMAGE;
+ tci.iImage = iconIdx;
}
- mir_free(ptszTemp);
+ TabCtrl_SetItem(dat->hwndTabs, tabId, &tci);
}
- break;
+ mir_free(ptszTemp);
+ }
+ break;
case DM_SWITCHINFOBAR:
dat->flags2 ^= SMF2_SHOWINFOBAR;
{
- for (int i=0; i < dat->childrenCount; i++) {
+ for (int i = 0; i < dat->childrenCount; i++) {
MessageWindowTabData * mwtd = GetChildFromTab(dat->hwndTabs, i);
SendMessage(mwtd->hwnd, DM_SWITCHINFOBAR, 0, 0);
}
@@ -1350,7 +1351,7 @@ INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
case DM_SWITCHTOOLBAR:
dat->flags2 ^= SMF2_SHOWTOOLBAR;
{
- for (int i=0; i < dat->childrenCount; i++) {
+ for (int i = 0; i < dat->childrenCount; i++) {
MessageWindowTabData * mwtd = GetChildFromTab(dat->hwndTabs, i);
SendMessage(mwtd->hwnd, DM_SWITCHTOOLBAR, 0, 0);
}
@@ -1359,30 +1360,30 @@ INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
break;
case DM_SWITCHTITLEBAR:
- {
- RECT rc;
- dat->flags2 ^= SMF2_SHOWTITLEBAR;
- ws = GetWindowLongPtr(hwndDlg, GWL_STYLE) & ~(WS_CAPTION);
- if (dat->flags2 & SMF2_SHOWTITLEBAR)
- ws |= WS_CAPTION;
-
- SetWindowLongPtr(hwndDlg, GWL_STYLE, ws);
- GetWindowRect(hwndDlg, &rc);
- SetWindowPos(hwndDlg, 0, 0, 0, rc.right - rc.left, rc.bottom - rc.top,
- SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOSENDCHANGING);
- RedrawWindow(hwndDlg, NULL, NULL, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN);
- }
- break;
+ {
+ RECT rc;
+ dat->flags2 ^= SMF2_SHOWTITLEBAR;
+ ws = GetWindowLongPtr(hwndDlg, GWL_STYLE) & ~(WS_CAPTION);
+ if (dat->flags2 & SMF2_SHOWTITLEBAR)
+ ws |= WS_CAPTION;
+
+ SetWindowLongPtr(hwndDlg, GWL_STYLE, ws);
+ GetWindowRect(hwndDlg, &rc);
+ SetWindowPos(hwndDlg, 0, 0, 0, rc.right - rc.left, rc.bottom - rc.top,
+ SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOSENDCHANGING);
+ RedrawWindow(hwndDlg, NULL, NULL, RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN);
+ }
+ break;
case DM_CASCADENEWWINDOW:
if ((HWND)wParam != hwndDlg) {
RECT rcThis, rcNew;
GetWindowRect(hwndDlg, &rcThis);
- GetWindowRect((HWND) wParam, &rcNew);
+ GetWindowRect((HWND)wParam, &rcNew);
if (abs(rcThis.left - rcNew.left) < 3 && abs(rcThis.top - rcNew.top) < 3) {
int offset = GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYFRAME);
- SetWindowPos((HWND) wParam, 0, rcNew.left + offset, rcNew.top + offset, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
- *(int *) lParam = 1;
+ SetWindowPos((HWND)wParam, 0, rcNew.left + offset, rcNew.top + offset, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
+ *(int *)lParam = 1;
}
}
break;
@@ -1392,11 +1393,11 @@ INT_PTR CALLBACK DlgProcParentWindow(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
static void DrawTab(ParentWindowData *dat, HWND hwnd, WPARAM wParam, LPARAM lParam)
{
- LPDRAWITEMSTRUCT lpDIS = (LPDRAWITEMSTRUCT) lParam;
+ LPDRAWITEMSTRUCT lpDIS = (LPDRAWITEMSTRUCT)lParam;
int iTabIndex = lpDIS->itemID;
if (iTabIndex < 0)
return;
-
+
TabCtrlData *tcdat = (TabCtrlData*)GetWindowLongPtr(hwnd, GWLP_USERDATA);
HANDLE hTheme = NULL;
int tstate;
@@ -1473,7 +1474,7 @@ static void DrawTab(ParentWindowData *dat, HWND hwnd, WPARAM wParam, LPARAM lPar
if (hTheme)
DrawThemeText(hTheme, lpDIS->hDC, TABP_TABITEM, tstate, szLabel, -1, dwFormat, 0, &rect);
- else
+ else
DrawText(lpDIS->hDC, szLabel, -1, &rect, dwFormat);
if (tcdat->bDragged && iTabIndex == tcdat->destTab && iTabIndex != tcdat->srcTab) {
@@ -1506,7 +1507,7 @@ static void DrawTab(ParentWindowData *dat, HWND hwnd, WPARAM wParam, LPARAM lPar
}
}
-int ScriverRestoreWindowPosition(HWND hwnd, MCONTACT hContact, const char *szModule,const char *szNamePrefix, int flags, int showCmd)
+int ScriverRestoreWindowPosition(HWND hwnd, MCONTACT hContact, const char *szModule, const char *szNamePrefix, int flags, int showCmd)
{
WINDOWPLACEMENT wp;
wp.length = sizeof(wp);
@@ -1514,21 +1515,21 @@ int ScriverRestoreWindowPosition(HWND hwnd, MCONTACT hContact, const char *szMod
char szSettingName[64];
mir_snprintf(szSettingName, SIZEOF(szSettingName), "%sx", szNamePrefix);
- int x = db_get_dw(hContact,szModule,szSettingName,-1);
+ int x = db_get_dw(hContact, szModule, szSettingName, -1);
mir_snprintf(szSettingName, SIZEOF(szSettingName), "%sy", szNamePrefix);
- int y = db_get_dw(hContact,szModule,szSettingName,-1);
+ int y = db_get_dw(hContact, szModule, szSettingName, -1);
if (x == -1)
return 1;
if (flags & RWPF_NOSIZE)
- OffsetRect(&wp.rcNormalPosition,x-wp.rcNormalPosition.left,y-wp.rcNormalPosition.top);
+ OffsetRect(&wp.rcNormalPosition, x - wp.rcNormalPosition.left, y - wp.rcNormalPosition.top);
else {
wp.rcNormalPosition.left = x;
wp.rcNormalPosition.top = y;
mir_snprintf(szSettingName, SIZEOF(szSettingName), "%swidth", szNamePrefix);
- wp.rcNormalPosition.right = wp.rcNormalPosition.left + db_get_dw(hContact,szModule,szSettingName,-1);
+ wp.rcNormalPosition.right = wp.rcNormalPosition.left + db_get_dw(hContact, szModule, szSettingName, -1);
mir_snprintf(szSettingName, SIZEOF(szSettingName), "%sheight", szNamePrefix);
- wp.rcNormalPosition.bottom = wp.rcNormalPosition.top + db_get_dw(hContact,szModule,szSettingName,-1);
+ wp.rcNormalPosition.bottom = wp.rcNormalPosition.top + db_get_dw(hContact, szModule, szSettingName, -1);
}
wp.flags = 0;
wp.showCmd = showCmd;
@@ -1538,9 +1539,9 @@ int ScriverRestoreWindowPosition(HWND hwnd, MCONTACT hContact, const char *szMod
mi.cbSize = sizeof(mi);
GetMonitorInfo(hMonitor, &mi);
RECT rcDesktop = mi.rcWork;
- if (wp.rcNormalPosition.left > rcDesktop.right || wp.rcNormalPosition.top > rcDesktop.bottom
- || wp.rcNormalPosition.right < rcDesktop.left || wp.rcNormalPosition.bottom < rcDesktop.top) return 1;
- SetWindowPlacement(hwnd,&wp);
+ if (wp.rcNormalPosition.left > rcDesktop.right || wp.rcNormalPosition.top > rcDesktop.bottom ||
+ wp.rcNormalPosition.right < rcDesktop.left || wp.rcNormalPosition.bottom < rcDesktop.top) return 1;
+ SetWindowPlacement(hwnd, &wp);
return 0;
}
diff --git a/plugins/Scriver/src/sendqueue.cpp b/plugins/Scriver/src/sendqueue.cpp
index 93deeff0e8..51c6dbb972 100644
--- a/plugins/Scriver/src/sendqueue.cpp
+++ b/plugins/Scriver/src/sendqueue.cpp
@@ -26,7 +26,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static MessageSendQueueItem *global_sendQueue = NULL;
static mir_cs queueMutex;
-TCHAR * GetSendBufferMsg(MessageSendQueueItem *item)
+TCHAR* GetSendBufferMsg(MessageSendQueueItem *item)
{
TCHAR *szMsg = NULL;
size_t len = strlen(item->sendBuffer);
@@ -34,7 +34,7 @@ TCHAR * GetSendBufferMsg(MessageSendQueueItem *item)
if (item->flags & PREF_UTF)
szMsg = mir_utf8decodeW(item->sendBuffer);
else {
- szMsg = (TCHAR *)mir_alloc(item->sendBufferSize - len - 1);
+ szMsg = (TCHAR*)mir_alloc(item->sendBufferSize - len - 1);
memcpy(szMsg, item->sendBuffer + len + 1, item->sendBufferSize - len - 1);
}
@@ -87,7 +87,7 @@ BOOL RemoveSendQueueItem(MessageSendQueueItem* item)
if (item->next != NULL)
item->next->prev = item->prev;
-
+
mir_free(item->sendBuffer);
mir_free(item->proto);
mir_free(item);
@@ -113,14 +113,15 @@ void ReportSendQueueTimeouts(HWND hwndSender)
if (item->timeout >= timeout) {
if (item->hwndSender == hwndSender && item->hwndErrorDlg == NULL) {
if (hwndSender != NULL) {
- ErrorWindowData *ewd = (ErrorWindowData *) mir_alloc(sizeof(ErrorWindowData));
+ ErrorWindowData *ewd = (ErrorWindowData *)mir_alloc(sizeof(ErrorWindowData));
ewd->szName = GetNickname(item->hContact, item->proto);
ewd->szDescription = mir_tstrdup(TranslateT("The message send timed out."));
ewd->szText = GetSendBufferMsg(item);
ewd->hwndParent = hwndSender;
ewd->queueItem = item;
PostMessage(hwndSender, DM_SHOWERRORMESSAGE, 0, (LPARAM)ewd);
- } else {
+ }
+ else {
/* TODO: Handle errors outside messaging window in a better way */
RemoveSendQueueItem(item);
}
diff --git a/plugins/Scriver/src/srmm.cpp b/plugins/Scriver/src/srmm.cpp
index 4dd628a6f8..c36b95736d 100644
--- a/plugins/Scriver/src/srmm.cpp
+++ b/plugins/Scriver/src/srmm.cpp
@@ -44,7 +44,7 @@ PLUGININFOEX pluginInfo = {
__AUTHORWEB,
UNICODE_AWARE,
// {84636F78-2057-4302-8A65-23A16D46844C}
- {0x84636f78, 0x2057, 0x4302, {0x8a, 0x65, 0x23, 0xa1, 0x6d, 0x46, 0x84, 0x4c}}
+ { 0x84636f78, 0x2057, 0x4302, { 0x8a, 0x65, 0x23, 0xa1, 0x6d, 0x46, 0x84, 0x4c } }
};
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
@@ -58,7 +58,7 @@ extern "C" __declspec(dllexport) PLUGININFOEX *MirandaPluginInfoEx(DWORD miranda
return &pluginInfo;
}
-extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = {MIID_SRMM, MIID_CHAT, MIID_LAST};
+extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_SRMM, MIID_CHAT, MIID_LAST };
extern "C" __declspec(dllexport) int Load(void)
{
diff --git a/plugins/Scriver/src/statusicon.cpp b/plugins/Scriver/src/statusicon.cpp
index 2c7ba945a6..3cc0c50df1 100644
--- a/plugins/Scriver/src/statusicon.cpp
+++ b/plugins/Scriver/src/statusicon.cpp
@@ -90,7 +90,7 @@ int DeinitStatusIcons()
int GetStatusIconsCount(MCONTACT hContact)
{
int nIcon = 0;
- while ( Srmm_GetNthIcon(hContact, nIcon) != NULL)
+ while (Srmm_GetNthIcon(hContact, nIcon) != NULL)
nIcon++;
return nIcon;
}
diff --git a/plugins/Scriver/src/utils.cpp b/plugins/Scriver/src/utils.cpp
index 2d17cbef67..96d8e1a2ad 100644
--- a/plugins/Scriver/src/utils.cpp
+++ b/plugins/Scriver/src/utils.cpp
@@ -27,23 +27,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define TTI_NONE 0
#endif
-int safe_wcslen(wchar_t *msg, int maxLen) {
- int i;
- for (i = 0; i < maxLen; i++) {
- if (msg[i] == (wchar_t)0)
- return i;
- }
- return 0;
-}
-
-wchar_t *a2w(const char *src, int len) {
+wchar_t *a2w(const char *src, int len)
+{
wchar_t *wline;
int i;
- if (len <0) {
+ if (len < 0) {
len = (int)strlen(src);
}
wline = (wchar_t*)mir_alloc(2 * (len + 1));
- for (i = 0; i < len; i ++) {
+ for (i = 0; i < len; i++) {
wline[i] = src[i];
}
wline[i] = 0;
@@ -57,7 +49,8 @@ enum MIMFLAGS {
MIM_UNICODE = 2
};
-int IsUnicodeMIM() {
+int IsUnicodeMIM()
+{
if (!(mimFlags & MIM_CHECKED))
mimFlags = MIM_CHECKED | MIM_UNICODE;
@@ -66,57 +59,62 @@ int IsUnicodeMIM() {
const char *filename = "scriver.log";
-void logInfo(const char *fmt, ...) {
+void logInfo(const char *fmt, ...)
+{
SYSTEMTIME time;
char *str;
va_list vararg;
int strsize;
- FILE *flog=fopen(filename,"at");
- if (flog!=NULL) {
+ FILE *flog = fopen(filename, "at");
+ if (flog != NULL) {
GetLocalTime(&time);
- va_start(vararg, fmt);
- str = (char*) malloc(strsize=2048);
- while (mir_vsnprintf(str, strsize, fmt, vararg) == -1)
- str = (char*) realloc(str, strsize+=2048);
- va_end(vararg);
- fprintf(flog,"%04d-%02d-%02d %02d:%02d:%02d,%03d [%s]",time.wYear,time.wMonth,time.wDay,time.wHour,time.wMinute,time.wSecond,time.wMilliseconds, "INFO");
- fprintf(flog," %s\n",str);
- free(str);
+ va_start(vararg, fmt);
+ str = (char*)malloc(strsize = 2048);
+ while (mir_vsnprintf(str, strsize, fmt, vararg) == -1)
+ str = (char*)realloc(str, strsize += 2048);
+ va_end(vararg);
+ fprintf(flog, "%04d-%02d-%02d %02d:%02d:%02d,%03d [%s]", time.wYear, time.wMonth, time.wDay, time.wHour, time.wMinute, time.wSecond, time.wMilliseconds, "INFO");
+ fprintf(flog, " %s\n", str);
+ free(str);
fclose(flog);
}
}
-int GetRichTextLength(HWND hwnd, int codepage, BOOL inBytes) {
+int GetRichTextLength(HWND hwnd, int codepage, BOOL inBytes)
+{
GETTEXTLENGTHEX gtl;
gtl.codepage = codepage;
if (inBytes) {
gtl.flags = GTL_NUMBYTES;
- } else {
+ }
+ else {
gtl.flags = GTL_NUMCHARS;
}
gtl.flags |= GTL_PRECISE | GTL_USECRLF;
- return (int) SendMessage(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)&gtl, 0);
+ return (int)SendMessage(hwnd, EM_GETTEXTLENGTHEX, (WPARAM)&gtl, 0);
}
-TCHAR *GetRichText(HWND hwnd, int codepage) {
- GETTEXTEX gt = {0};
+TCHAR *GetRichText(HWND hwnd, int codepage)
+{
+ GETTEXTEX gt = { 0 };
TCHAR *textBuffer = NULL;
int textBufferSize;
codepage = 1200;
textBufferSize = GetRichTextLength(hwnd, codepage, TRUE);
if (textBufferSize > 0) {
textBufferSize += sizeof(TCHAR);
- textBuffer = (TCHAR *) mir_alloc(textBufferSize);
+ textBuffer = (TCHAR*)mir_alloc(textBufferSize);
gt.cb = textBufferSize;
gt.flags = GT_USECRLF;
gt.codepage = codepage;
- SendMessage(hwnd, EM_GETTEXTEX, (WPARAM) &gt, (LPARAM)textBuffer);
+ SendMessage(hwnd, EM_GETTEXTEX, (WPARAM)&gt, (LPARAM)textBuffer);
}
return textBuffer;
}
-char *GetRichTextEncoded(HWND hwnd, int codepage) {
+char *GetRichTextEncoded(HWND hwnd, int codepage)
+{
TCHAR *textBuffer = GetRichText(hwnd, codepage);
char *textUtf = NULL;
if (textBuffer != NULL) {
@@ -126,29 +124,31 @@ char *GetRichTextEncoded(HWND hwnd, int codepage) {
return textUtf;
}
-int SetRichTextEncoded(HWND hwnd, const char *text, int codepage) {
+int SetRichTextEncoded(HWND hwnd, const char *text, int codepage)
+{
TCHAR *textToSet;
SETTEXTEX st;
st.flags = ST_DEFAULT;
st.codepage = 1200;
textToSet = mir_utf8decodeW(text);
- SendMessage(hwnd, EM_SETTEXTEX, (WPARAM) &st, (LPARAM)textToSet);
+ SendMessage(hwnd, EM_SETTEXTEX, (WPARAM)&st, (LPARAM)textToSet);
mir_free(textToSet);
return GetRichTextLength(hwnd, st.codepage, FALSE);
}
-int SetRichTextRTF(HWND hwnd, const char *text) {
+int SetRichTextRTF(HWND hwnd, const char *text)
+{
SETTEXTEX st;
st.flags = ST_DEFAULT;
st.codepage = CP_ACP;
- SendMessage(hwnd, EM_SETTEXTEX, (WPARAM) &st, (LPARAM)text);
+ SendMessage(hwnd, EM_SETTEXTEX, (WPARAM)&st, (LPARAM)text);
return GetRichTextLength(hwnd, st.codepage, FALSE);
}
static DWORD CALLBACK RichTextStreamCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG * pcb)
{
static DWORD dwRead;
- char ** ppText = (char **) dwCookie;
+ char **ppText = (char**)dwCookie;
if (*ppText == NULL) {
*ppText = (char*)mir_alloc(cb + 1);
@@ -160,7 +160,7 @@ static DWORD CALLBACK RichTextStreamCallback(DWORD_PTR dwCookie, LPBYTE pbBuff,
else {
char *p = (char*)mir_alloc(dwRead + cb + 1);
memcpy(p, *ppText, dwRead);
- memcpy(p+dwRead, pbBuff, cb);
+ memcpy(p + dwRead, pbBuff, cb);
p[dwRead + cb] = 0;
mir_free(*ppText);
*ppText = p;
@@ -176,7 +176,7 @@ char* GetRichTextRTF(HWND hwnd)
if (hwnd == 0)
return NULL;
- char* pszText = NULL;
+ char *pszText = NULL;
EDITSTREAM stream = { 0 };
stream.pfnCallback = RichTextStreamCallback;
stream.dwCookie = (DWORD_PTR)&pszText; // pass pointer to pointer
@@ -187,57 +187,52 @@ char* GetRichTextRTF(HWND hwnd)
void rtrimText(TCHAR *text)
{
static TCHAR szTrimString[] = _T(":;,.!?\'\"><()[]- \r\n");
- int iLen = mir_tstrlen(text)-1;
- while(iLen >= 0 && _tcschr(szTrimString, text[iLen])) {
+ size_t iLen = mir_tstrlen(text) - 1;
+ while (iLen >= 0 && _tcschr(szTrimString, text[iLen])) {
text[iLen] = _T('\0');
iLen--;
}
}
-TCHAR *limitText(TCHAR *text, int limit)
+TCHAR* limitText(TCHAR *text, int limit)
{
- int len = mir_tstrlen(text);
- if (len > g_dat.limitNamesLength)
- {
- TCHAR *ptszTemp = (TCHAR *)mir_alloc(sizeof(TCHAR) * (limit + 4));
+ size_t len = mir_tstrlen(text);
+ if (len > g_dat.limitNamesLength) {
+ TCHAR *ptszTemp = (TCHAR*)mir_alloc(sizeof(TCHAR) * (limit + 4));
_tcsncpy(ptszTemp, text, limit + 1);
_tcsncpy(ptszTemp + limit, _T("..."), 4);
return ptszTemp;
}
return text;
}
-TCHAR *GetRichTextWord(HWND hwnd, POINTL *ptl)
+TCHAR* GetRichTextWord(HWND hwnd, POINTL *ptl)
{
TCHAR* pszWord = NULL;
long iCharIndex, start, end, iRes;
pszWord = GetRichEditSelection(hwnd);
if (pszWord == NULL) {
iCharIndex = SendMessage(hwnd, EM_CHARFROMPOS, 0, (LPARAM)ptl);
- if (iCharIndex >= 0)
- {
+ if (iCharIndex >= 0) {
start = SendMessage(hwnd, EM_FINDWORDBREAK, WB_LEFT, iCharIndex);//-iChars;
end = SendMessage(hwnd, EM_FINDWORDBREAK, WB_RIGHT, iCharIndex);//-iChars;
- if (end - start > 0)
- {
+ if (end - start > 0) {
TEXTRANGE tr;
CHARRANGE cr;
memset(&tr, 0, sizeof(TEXTRANGE));
- pszWord = (TCHAR *)mir_alloc(sizeof(TCHAR) * (end - start + 1));
+ pszWord = (TCHAR*)mir_alloc(sizeof(TCHAR) * (end - start + 1));
cr.cpMin = start;
cr.cpMax = end;
tr.chrg = cr;
tr.lpstrText = pszWord;
iRes = SendMessage(hwnd, EM_GETTEXTRANGE, 0, (LPARAM)&tr);
- if (iRes <= 0)
- {
+ if (iRes <= 0) {
mir_free(pszWord);
pszWord = NULL;
}
}
}
}
- if (pszWord != NULL)
- {
+ if (pszWord != NULL) {
rtrimText(pszWord);
}
return pszWord;
@@ -245,27 +240,27 @@ TCHAR *GetRichTextWord(HWND hwnd, POINTL *ptl)
static DWORD CALLBACK StreamOutCallback(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG * pcb)
{
- MessageSendQueueItem *msi = (MessageSendQueueItem *) dwCookie;
+ MessageSendQueueItem *msi = (MessageSendQueueItem *)dwCookie;
msi->sendBuffer = (char*)mir_realloc(msi->sendBuffer, msi->sendBufferSize + cb + 2);
- memcpy (msi->sendBuffer + msi->sendBufferSize, pbBuff, cb);
+ memcpy(msi->sendBuffer + msi->sendBufferSize, pbBuff, cb);
msi->sendBufferSize += cb;
- *((TCHAR *)(msi->sendBuffer+msi->sendBufferSize)) = '\0';
+ *((TCHAR*)(msi->sendBuffer + msi->sendBufferSize)) = '\0';
*pcb = cb;
- return 0;
+ return 0;
}
TCHAR *GetRichEditSelection(HWND hwnd)
{
CHARRANGE sel;
SendMessage(hwnd, EM_EXGETSEL, 0, (LPARAM)&sel);
- if (sel.cpMin!=sel.cpMax) {
+ if (sel.cpMin != sel.cpMax) {
MessageSendQueueItem msi;
EDITSTREAM stream;
DWORD dwFlags = 0;
memset(&stream, 0, sizeof(stream));
stream.pfnCallback = StreamOutCallback;
- stream.dwCookie = (DWORD_PTR) &msi;
- dwFlags = SF_TEXT|SF_UNICODE|SFF_SELECTION;
+ stream.dwCookie = (DWORD_PTR)&msi;
+ dwFlags = SF_TEXT | SF_UNICODE | SFF_SELECTION;
msi.sendBuffer = NULL;
msi.sendBufferSize = 0;
SendMessage(hwnd, EM_STREAMOUT, (WPARAM)dwFlags, (LPARAM)&stream);
@@ -285,7 +280,7 @@ void AppendToBuffer(char **buffer, int *cbBufferEnd, int *cbBufferAlloced, const
if (charsDone >= 0)
break;
*cbBufferAlloced += 1024;
- *buffer = (char*) mir_realloc(*buffer, *cbBufferAlloced);
+ *buffer = (char*)mir_realloc(*buffer, *cbBufferAlloced);
}
va_end(va);
*cbBufferEnd += charsDone;
@@ -294,8 +289,8 @@ void AppendToBuffer(char **buffer, int *cbBufferEnd, int *cbBufferAlloced, const
int MeasureMenuItem(WPARAM wParam, LPARAM lParam)
{
- LPMEASUREITEMSTRUCT mis = (LPMEASUREITEMSTRUCT) lParam;
- if (mis->itemData != (ULONG_PTR) g_dat.hButtonIconList && mis->itemData != (ULONG_PTR) g_dat.hSearchEngineIconList && mis->itemData != (ULONG_PTR) g_dat.hChatButtonIconList) {
+ LPMEASUREITEMSTRUCT mis = (LPMEASUREITEMSTRUCT)lParam;
+ if (mis->itemData != (ULONG_PTR)g_dat.hButtonIconList && mis->itemData != (ULONG_PTR)g_dat.hSearchEngineIconList && mis->itemData != (ULONG_PTR)g_dat.hChatButtonIconList) {
return FALSE;
}
mis->itemWidth = max(0, GetSystemMetrics(SM_CXSMICON) - GetSystemMetrics(SM_CXMENUCHECK) + 4);
@@ -307,8 +302,8 @@ int DrawMenuItem(WPARAM wParam, LPARAM lParam)
{
int y;
int id;
- LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT) lParam;
- if (dis->itemData != (ULONG_PTR) g_dat.hButtonIconList && dis->itemData != (ULONG_PTR) g_dat.hSearchEngineIconList && dis->itemData != (ULONG_PTR) g_dat.hChatButtonIconList) {
+ LPDRAWITEMSTRUCT dis = (LPDRAWITEMSTRUCT)lParam;
+ if (dis->itemData != (ULONG_PTR)g_dat.hButtonIconList && dis->itemData != (ULONG_PTR)g_dat.hSearchEngineIconList && dis->itemData != (ULONG_PTR)g_dat.hChatButtonIconList) {
return FALSE;
}
id = dis->itemID;
@@ -325,9 +320,11 @@ int DrawMenuItem(WPARAM wParam, LPARAM lParam)
rc.bottom = rc.top + GetSystemMetrics(SM_CYSMICON) + 2;
FillRect(dis->hDC, &rc, GetSysColorBrush(COLOR_HIGHLIGHT));
ImageList_DrawEx((HIMAGELIST)dis->itemData, id, dis->hDC, 2, y, 0, 0, CLR_NONE, CLR_DEFAULT, ILD_SELECTED);
- } else
+ }
+ else
ImageList_DrawEx((HIMAGELIST)dis->itemData, id, dis->hDC, 2, y, 0, 0, CLR_NONE, CLR_DEFAULT, ILD_FOCUS);
- } else {
+ }
+ else {
if (dis->itemState & ODS_CHECKED) {
HBRUSH hBrush;
RECT rc;
@@ -346,7 +343,8 @@ int DrawMenuItem(WPARAM wParam, LPARAM lParam)
FillRect(dis->hDC, &rc, hBrush);
DeleteObject(hBrush);
ImageList_DrawEx((HIMAGELIST)dis->itemData, id, dis->hDC, 2, y, 0, 0, CLR_NONE, GetSysColor(COLOR_MENU), ILD_BLEND25);
- } else
+ }
+ else
ImageList_DrawEx((HIMAGELIST)dis->itemData, id, dis->hDC, 2, y, 0, 0, CLR_NONE, CLR_NONE, ILD_NORMAL);
}
return TRUE;
@@ -355,21 +353,23 @@ int DrawMenuItem(WPARAM wParam, LPARAM lParam)
// Code taken from http://www.geekhideout.com/urlcode.shtml
/* Converts an integer value to its hex character*/
-char to_hex(char code) {
+char to_hex(char code)
+{
static char hex[] = "0123456789abcdef";
return hex[code & 15];
}
/* Returns a url-encoded version of str */
/* IMPORTANT: be sure to free() the returned string after use */
-char *url_encode(char *str) {
+char *url_encode(char *str)
+{
char *pstr = str, *buf = (char*)mir_alloc(strlen(str) * 3 + 1), *pbuf = buf;
while (*pstr) {
- if ( (48 <= *pstr && *pstr <= 57) ||//0-9
- (65 <= *pstr && *pstr <= 90) ||//ABC...XYZ
- (97 <= *pstr && *pstr <= 122) ||//abc...xyz
+ if ((48 <= *pstr && *pstr <= 57) ||//0-9
+ (65 <= *pstr && *pstr <= 90) ||//ABC...XYZ
+ (97 <= *pstr && *pstr <= 122) ||//abc...xyz
*pstr == '-' || *pstr == '_' || *pstr == '.')
- *pbuf++ = *pstr;
+ *pbuf++ = *pstr;
else if (*pstr == ' ')
*pbuf++ = '+';
else
@@ -384,8 +384,8 @@ void SearchWord(TCHAR * word, int engine)
{
char szURL[4096];
if (word && word[0]) {
- ptrA wordUTF( mir_utf8encodeT(word));
- ptrA wordURL( mir_urlEncode(wordUTF));
+ ptrA wordUTF(mir_utf8encodeT(word));
+ ptrA wordURL(mir_urlEncode(wordUTF));
switch (engine) {
case SEARCHENGINE_WIKIPEDIA:
mir_snprintf(szURL, SIZEOF(szURL), "http://en.wikipedia.org/wiki/%s", wordURL);
@@ -420,11 +420,11 @@ void SearchWord(TCHAR * word, int engine)
void SetSearchEngineIcons(HMENU hMenu, HIMAGELIST hImageList)
{
- for (int i=0; i < IDI_LASTICON - IDI_GOOGLE; i++) {
+ for (int i = 0; i < IDI_LASTICON - IDI_GOOGLE; i++) {
MENUITEMINFO minfo = { sizeof(minfo) };
minfo.fMask = MIIM_BITMAP | MIIM_DATA;
minfo.hbmpItem = HBMMENU_CALLBACK;
- minfo.dwItemData = (ULONG_PTR) hImageList;
+ minfo.dwItemData = (ULONG_PTR)hImageList;
SetMenuItemInfo(hMenu, IDM_SEARCH_GOOGLE + i, FALSE, &minfo);
}
}
@@ -500,14 +500,14 @@ HDWP ResizeToolbar(HWND hwnd, HDWP hdwp, int width, int vPos, int height, int cC
int i;
int lPos = 0;
int rPos = width;
- for (i = 0; i < cControls ; i++) {
+ for (i = 0; i < cControls; i++) {
if (!buttons[i].alignment && (controlVisibility & (1 << i))) {
lPos += buttons[i].spacing;
hdwp = DeferWindowPos(hdwp, GetDlgItem(hwnd, buttons[i].controlId), 0, lPos, vPos, buttons[i].width, height, SWP_NOZORDER);
lPos += buttons[i].width;
}
}
- for (i = cControls - 1; i >=0; i--) {
+ for (i = cControls - 1; i >= 0; i--) {
if (buttons[i].alignment && (controlVisibility & (1 << i))) {
rPos -= buttons[i].spacing + buttons[i].width;
hdwp = DeferWindowPos(hdwp, GetDlgItem(hwnd, buttons[i].controlId), 0, rPos, vPos, buttons[i].width, height, SWP_NOZORDER);
diff --git a/plugins/Scriver/src/utils.h b/plugins/Scriver/src/utils.h
index 612c8c77b6..5f9f4afee8 100644
--- a/plugins/Scriver/src/utils.h
+++ b/plugins/Scriver/src/utils.h
@@ -35,8 +35,6 @@ enum SEARCHENGINES {
};
int IsUnicodeMIM();
-wchar_t *a2w(const char *src, int len);
-int safe_wcslen(wchar_t *msg, int maxLen) ;
TCHAR *limitText(TCHAR *text, int limit);
void logInfo(const char *fmt, ...);
int GetRichTextLength(HWND hwnd, int codepage, BOOL inBytes);