diff options
-rw-r--r-- | include/m_chat_int.h | 10 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat/chat.h | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat/log.cpp | 113 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat/main.cpp | 1 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat/window.cpp | 9 | ||||
-rw-r--r-- | src/modules/chat/chat_svc.cpp | 17 | ||||
-rw-r--r-- | src/modules/chat/manager.cpp | 18 |
7 files changed, 111 insertions, 59 deletions
diff --git a/include/m_chat_int.h b/include/m_chat_int.h index 9e2f304cb0..7ebeb02068 100644 --- a/include/m_chat_int.h +++ b/include/m_chat_int.h @@ -88,11 +88,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define ICON_REMSTATUS 12
#define ICON_TOPIC 13
-#define ICON_STATUS1 14
-#define ICON_STATUS2 15
-#define ICON_STATUS3 16
-#define ICON_STATUS4 17
-#define ICON_STATUS0 18
+#define ICON_STATUS0 14
+#define ICON_STATUS1 15
+#define ICON_STATUS2 16
+#define ICON_STATUS3 17
+#define ICON_STATUS4 18
#define ICON_STATUS5 19
//structs
diff --git a/plugins/TabSRMM/src/chat/chat.h b/plugins/TabSRMM/src/chat/chat.h index ecfbf2b503..605e9fefc0 100644 --- a/plugins/TabSRMM/src/chat/chat.h +++ b/plugins/TabSRMM/src/chat/chat.h @@ -132,6 +132,7 @@ INT_PTR CALLBACK DlgProcColorToolWindow(HWND hwndDlg, UINT msg, WPARAM wParam, L // log.c
void Log_StreamInEvent(HWND hwndDlg, LOGINFO* lin, SESSION_INFO *si, bool bRedraw, bool bPhaseTwo);
+char* Log_CreateRtfHeader(MODULEINFO *mi);
TCHAR* GetChatLogsFilename(SESSION_INFO *si, time_t tTime);
void Log_SetStyles();
@@ -180,6 +181,7 @@ TCHAR* Chat_DoRtfToTags(char* pszRtfText, SESSION_INFO *si); #include "chat_resource.h"
extern char *szChatIconString;
+extern char szIndicators[];
#define DEFLOGFILENAME _T("%miranda_logpath%\\%proto%\\%userid%.log")
diff --git a/plugins/TabSRMM/src/chat/log.cpp b/plugins/TabSRMM/src/chat/log.cpp index 424c5526ff..df8875ab11 100644 --- a/plugins/TabSRMM/src/chat/log.cpp +++ b/plugins/TabSRMM/src/chat/log.cpp @@ -739,6 +739,79 @@ static void AddEventToBuffer(char **buffer, int *bufferEnd, int *bufferAlloced, }
}
+char* Log_CreateRtfHeader(MODULEINFO *mi)
+{
+ int bufferAlloced, bufferEnd, i = 0;
+
+ // guesstimate amount of memory for the RTF header
+ bufferEnd = 0;
+ bufferAlloced = 4096;
+ char *buffer = (char *)mir_realloc(mi->pszHeader, bufferAlloced);
+ buffer[0] = '\0';
+
+
+ //get the number of pixels per logical inch
+ if (logPixelSY == 0) {
+ HDC hdc;
+ hdc = GetDC(NULL);
+ logPixelSY = GetDeviceCaps(hdc, LOGPIXELSY);
+ logPixelSX = GetDeviceCaps(hdc, LOGPIXELSX);
+ ReleaseDC(NULL, hdc);
+ }
+
+ // ### RTF HEADER
+
+ // font table
+ Log_Append(&buffer, &bufferEnd, &bufferAlloced, "{\\rtf1\\ansi\\deff0{\\fonttbl");
+ for (i = 0; i < OPTIONS_FONTCOUNT; i++)
+ Log_Append(&buffer, &bufferEnd, &bufferAlloced, "{\\f%u\\fnil\\fcharset%u%S;}", i, pci->aFonts[i].lf.lfCharSet, pci->aFonts[i].lf.lfFaceName);
+
+ // colour table
+ Log_Append(&buffer, &bufferEnd, &bufferAlloced, "}{\\colortbl ;");
+
+ for (i = 0; i < OPTIONS_FONTCOUNT; i++)
+ Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\red%u\\green%u\\blue%u;", GetRValue(pci->aFonts[i].color), GetGValue(pci->aFonts[i].color), GetBValue(pci->aFonts[i].color));
+
+ for (i = 0; i < mi->nColorCount; i++)
+ Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\red%u\\green%u\\blue%u;", GetRValue(mi->crColors[i]), GetGValue(mi->crColors[i]), GetBValue(mi->crColors[i]));
+
+ for (i = 0; i < STATUSICONCOUNT; i++)
+ Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\red%u\\green%u\\blue%u;", GetRValue(g_Settings.nickColors[i]), GetGValue(g_Settings.nickColors[i]), GetBValue(g_Settings.nickColors[i]));
+
+ // new paragraph
+ Log_Append(&buffer, &bufferEnd, &bufferAlloced, "}\\pard\\sl%d", 1000);
+
+ // set tabs and indents
+ int iIndent = 0;
+
+ if (g_Settings.bLogSymbols) {
+ TCHAR szString[2];
+ LOGFONT lf;
+
+ szString[1] = 0;
+ szString[0] = 0x28;
+ pci->LoadMsgDlgFont(17, &lf, NULL);
+ HFONT hFont = CreateFontIndirect(&lf);
+ int iText = GetTextPixelSize(szString, hFont, true) + 3;
+ DeleteObject(hFont);
+ iIndent += (iText * 1440) / logPixelSX;
+ Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\tx%u", iIndent);
+ }
+ else if (g_Settings.dwIconFlags) {
+ iIndent += ((g_Settings.bScaleIcons ? 14 : 20) * 1440) / logPixelSX;
+ Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\tx%u", iIndent);
+ }
+ if (g_Settings.ShowTime) {
+ int iSize = (g_Settings.LogTextIndent * 1440) / logPixelSX;
+ Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\tx%u", iIndent + iSize);
+ if (g_Settings.LogIndentEnabled)
+ iIndent += iSize;
+ }
+ Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\fi-%u\\li%u", iIndent, iIndent);
+
+ return buffer;
+}
+
static char* Log_CreateRTF(LOGSTREAMDATA *streamData)
{
char *buffer, *header;
@@ -755,7 +828,7 @@ static char* Log_CreateRTF(LOGSTREAMDATA *streamData) // ### RTF HEADER
if (0 == mi->pszHeader)
- mi->pszHeader = pci->Log_CreateRtfHeader(mi);
+ mi->pszHeader = Log_CreateRtfHeader(mi);
header = mi->pszHeader;
streamData->crCount = mi->nColorCount;
@@ -838,39 +911,17 @@ static char* Log_CreateRTF(LOGSTREAMDATA *streamData) TCHAR pszTemp[300], *p1;
char pszIndicator[3] = "\0\0";
int crNickIndex = 0;
- //mad
+
if (g_Settings.bLogClassicIndicators || g_Settings.bColorizeNicksInLog) {
USERINFO *ui = streamData->si->pUsers;
while (ui) {
if (!lstrcmp(ui->pszNick, lin->ptszNick)) {
STATUSINFO *ti = pci->TM_FindStatus(streamData->si->pStatuses, pci->TM_WordToString(streamData->si->pStatuses, ui->Status));
- if (ti && (int)ti->hIcon < streamData->si->iStatusCount) {
- int id = streamData->si->iStatusCount - (int)ti->hIcon - 1;
- switch (id) {
- case 1:
- pszIndicator[0] = '+';
- crNickIndex = 2;
- break;
- case 2:
- pszIndicator[0] = '%';
- crNickIndex = 1;
- break;
- case 3:
- pszIndicator[0] = '@';
- crNickIndex = 0;
- break;
- case 4:
- pszIndicator[0] = '!';
- crNickIndex = 3;
- break;
- case 5:
- pszIndicator[0] = '*';
- crNickIndex = 4;
- break;
- default:
- pszIndicator[0] = 0;
- }
+ if (ti && (UINT_PTR)ti->hIcon < streamData->si->iStatusCount) {
+ pszIndicator[0] = szIndicators[(int)ti->hIcon];
+ crNickIndex = streamData->si->iStatusCount - (int)ti->hIcon; // color table's index is not zero-based
}
+ else pszIndicator[0] = 0;
break;
}
ui = ui->next;
@@ -892,11 +943,11 @@ static char* Log_CreateRTF(LOGSTREAMDATA *streamData) _tcsnrplc(pszTemp, 300, _T("%s"), _T("~~++#%s#++~~"));
pszTemp[299] = 0;
}
-
- if (g_Settings.bColorizeNicksInLog && pszIndicator[0])
- Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\cf%u ", OPTIONS_FONTCOUNT + streamData->crCount + crNickIndex + 1);
}
+ if (g_Settings.bColorizeNicksInLog && pszIndicator[0])
+ Log_Append(&buffer, &bufferEnd, &bufferAlloced, "\\cf%u ", OPTIONS_FONTCOUNT + streamData->crCount + crNickIndex);
+
Log_AppendRTF(streamData, TRUE, &buffer, &bufferEnd, &bufferAlloced, pszTemp, lin->ptszNick);
Log_Append(&buffer, &bufferEnd, &bufferAlloced, " ");
}
diff --git a/plugins/TabSRMM/src/chat/main.cpp b/plugins/TabSRMM/src/chat/main.cpp index 3c15eefb0a..c367f9cef0 100644 --- a/plugins/TabSRMM/src/chat/main.cpp +++ b/plugins/TabSRMM/src/chat/main.cpp @@ -273,6 +273,7 @@ int Chat_Load() // this operation is unsafe, that's why we restore the old pci state on exit
pci->DoSoundsFlashPopupTrayStuff = DoSoundsFlashPopupTrayStuff;
pci->IsHighlighted = IsHighlighted;
+ pci->Log_CreateRtfHeader = Log_CreateRtfHeader;
pci->ReloadSettings();
g_hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_MENU));
diff --git a/plugins/TabSRMM/src/chat/window.cpp b/plugins/TabSRMM/src/chat/window.cpp index df7b271eb8..ea559adc64 100644 --- a/plugins/TabSRMM/src/chat/window.cpp +++ b/plugins/TabSRMM/src/chat/window.cpp @@ -45,8 +45,7 @@ extern HMENU g_hMenu; static HKL hkl = NULL;
static HCURSOR hCurHyperlinkHand;
-static char szIndicators[] = { '+', '%', '@', '!', 0, '*' };
-static int nickOrders[] = { 2, 1, 0, 3, 5, 4 };
+char szIndicators[] = { '@', '%', '+', '!', '*', 0 };
struct MESSAGESUBDATA
{
@@ -2271,8 +2270,8 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar int nickIndex = -1;
for (int i = 0; i < STATUSICONCOUNT; i++) {
- if (hIcon == pci->hIcons[ICON_STATUS1 + i]) {
- nickIndex = nickOrders[i];
+ if (hIcon == pci->hIcons[ICON_STATUS0 + i]) {
+ nickIndex = i;
break;
}
}
@@ -2284,7 +2283,7 @@ INT_PTR CALLBACK RoomWndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar else {
FillRect(dis->hDC, &dis->rcItem, pci->hListBkgBrush);
if (g_Settings.bColorizeNicks && nickIndex != -1)
- SetTextColor(dis->hDC, g_Settings.nickColors[nickIndex]);
+ SetTextColor(dis->hDC, g_Settings.nickColors[si->iStatusCount - nickIndex - 1]);
else
SetTextColor(dis->hDC, g_Settings.UserListColors[ui->iStatusEx]);
}
diff --git a/src/modules/chat/chat_svc.cpp b/src/modules/chat/chat_svc.cpp index bfb928ce11..7aefea1e20 100644 --- a/src/modules/chat/chat_svc.cpp +++ b/src/modules/chat/chat_svc.cpp @@ -175,7 +175,7 @@ static INT_PTR Service_Register(WPARAM wParam, LPARAM lParam) memcpy(mi->crColors, gcr->pColors, sizeof(COLORREF)* gcr->nColors);
}
- mi->pszHeader = Log_CreateRtfHeader(mi);
+ mi->pszHeader = ci.Log_CreateRtfHeader(mi);
CheckColorsInModule((char*)gcr->pszModule);
ci.SetAllOffline(TRUE, gcr->pszModule);
@@ -248,6 +248,17 @@ static INT_PTR Service_NewChat(WPARAM wParam, LPARAM lParam) return 0;
}
+static void SetInitDone(SESSION_INFO *si)
+{
+ if (si->bInitDone)
+ return;
+
+ si->bInitDone = true;
+ for (STATUSINFO *p = si->pStatuses; p; p = p->next)
+ if ((UINT_PTR)p->hIcon < STATUSICONCOUNT)
+ p->hIcon = HICON(si->iStatusCount - (int)p->hIcon - 1);
+}
+
static int DoControl(GCEVENT *gce, WPARAM wp)
{
SESSION_INFO *si;
@@ -256,7 +267,7 @@ static int DoControl(GCEVENT *gce, WPARAM wp) switch (wp) {
case WINDOW_HIDDEN:
if (si = ci.SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule)) {
- si->bInitDone = TRUE;
+ SetInitDone(si);
ci.SetActiveSession(si->ptszID, si->pszModule);
if (si->hWnd)
ci.ShowRoom(si, wp, FALSE);
@@ -268,7 +279,7 @@ static int DoControl(GCEVENT *gce, WPARAM wp) case WINDOW_VISIBLE:
case SESSION_INITDONE:
if (si = ci.SM_FindSession(gce->pDest->ptszID, gce->pDest->pszModule)) {
- si->bInitDone = TRUE;
+ SetInitDone(si);
if (wp != SESSION_INITDONE || db_get_b(NULL, "Chat", "PopupOnJoin", 0) == 0)
ci.ShowRoom(si, wp, TRUE);
return 0;
diff --git a/src/modules/chat/manager.cpp b/src/modules/chat/manager.cpp index 6c7b1c6afa..d418b56a24 100644 --- a/src/modules/chat/manager.cpp +++ b/src/modules/chat/manager.cpp @@ -226,22 +226,10 @@ static HICON SM_GetStatusIcon(SESSION_INFO *si, USERINFO * ui) STATUSINFO *ti = ci.TM_FindStatus(si->pStatuses, ci.TM_WordToString(si->pStatuses, ui->Status));
if (ti != NULL) {
- if ((INT_PTR)ti->hIcon >= STATUSICONCOUNT)
+ if ((UINT_PTR)ti->hIcon >= STATUSICONCOUNT)
return ti->hIcon;
- int id = si->iStatusCount - (int)ti->hIcon - 1;
- if (id == 0)
- return ci.hIcons[ICON_STATUS0];
- if (id == 1)
- return ci.hIcons[ICON_STATUS1];
- if (id == 2)
- return ci.hIcons[ICON_STATUS2];
- if (id == 3)
- return ci.hIcons[ICON_STATUS3];
- if (id == 4)
- return ci.hIcons[ICON_STATUS4];
- if (id == 5)
- return ci.hIcons[ICON_STATUS5];
+ return ci.hIcons[ICON_STATUS0 + (int)ti->hIcon];
}
return ci.hIcons[ICON_STATUS0];
}
@@ -898,7 +886,7 @@ static void MM_FontsChanged(void) {
MODULEINFO *pTemp = m_ModList;
while (pTemp != NULL) {
- pTemp->pszHeader = Log_CreateRtfHeader(pTemp);
+ pTemp->pszHeader = ci.Log_CreateRtfHeader(pTemp);
pTemp = pTemp->next;
}
return;
|