diff options
author | George Hazan <ghazan@miranda.im> | 2017-03-09 20:29:02 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-03-09 20:29:02 +0300 |
commit | e5fdfcde3880eb7edaf573fb883dd4ef86972082 (patch) | |
tree | c5d4ee388876f78024a82c4bd8ee9712e3877dbb /src/mir_app | |
parent | 2d737d50469b965c2787823a94757f4c9f0a7107 (diff) |
moving session data into dialog classes
Diffstat (limited to 'src/mir_app')
-rw-r--r-- | src/mir_app/src/chat_log.cpp | 91 | ||||
-rw-r--r-- | src/mir_app/src/chat_svc.cpp | 12 | ||||
-rw-r--r-- | src/mir_app/src/colorchooser.cpp | 10 | ||||
-rw-r--r-- | src/mir_app/src/mir_app.def | 2 | ||||
-rw-r--r-- | src/mir_app/src/mir_app64.def | 2 | ||||
-rw-r--r-- | src/mir_app/src/srmm_base.cpp | 25 |
6 files changed, 77 insertions, 65 deletions
diff --git a/src/mir_app/src/chat_log.cpp b/src/mir_app/src/chat_log.cpp index 9faa8c85a4..2a7ab9234f 100644 --- a/src/mir_app/src/chat_log.cpp +++ b/src/mir_app/src/chat_log.cpp @@ -191,36 +191,38 @@ static int Log_AppendRTF(LOGSTREAMDATA *streamData, bool simpleMode, CMStringA & static void AddEventToBuffer(CMStringA &buf, LOGSTREAMDATA *streamData)
{
+ LOGINFO *lin = streamData->lin;
+
wchar_t szTemp[512], szTemp2[512];
wchar_t* pszNick = NULL;
- if (streamData->lin->ptszNick) {
- if (g_Settings->bLogLimitNames && mir_wstrlen(streamData->lin->ptszNick) > 20) {
- mir_wstrncpy(szTemp2, streamData->lin->ptszNick, 20);
+ if (lin->ptszNick) {
+ if (g_Settings->bLogLimitNames && mir_wstrlen(lin->ptszNick) > 20) {
+ mir_wstrncpy(szTemp2, lin->ptszNick, 20);
mir_wstrncpy(szTemp2 + 20, L"...", 4);
}
- else mir_wstrncpy(szTemp2, streamData->lin->ptszNick, 511);
+ else mir_wstrncpy(szTemp2, lin->ptszNick, 511);
- if (streamData->lin->ptszUserInfo)
- mir_snwprintf(szTemp, L"%s (%s)", szTemp2, streamData->lin->ptszUserInfo);
+ if (lin->ptszUserInfo)
+ mir_snwprintf(szTemp, L"%s (%s)", szTemp2, lin->ptszUserInfo);
else
wcsncpy_s(szTemp, szTemp2, _TRUNCATE);
pszNick = szTemp;
}
- switch (streamData->lin->iType) {
+ switch (lin->iType) {
case GC_EVENT_MESSAGE:
- if (streamData->lin->ptszText)
- Log_AppendRTF(streamData, false, buf, L"%s", streamData->lin->ptszText);
+ if (lin->ptszText)
+ Log_AppendRTF(streamData, false, buf, L"%s", lin->ptszText);
break;
case GC_EVENT_ACTION:
- if (streamData->lin->ptszNick && streamData->lin->ptszText) {
- Log_AppendRTF(streamData, true, buf, L"%s ", streamData->lin->ptszNick);
- Log_AppendRTF(streamData, false, buf, L"%s", streamData->lin->ptszText);
+ if (lin->ptszNick && lin->ptszText) {
+ Log_AppendRTF(streamData, true, buf, L"%s ", lin->ptszNick);
+ Log_AppendRTF(streamData, false, buf, L"%s", lin->ptszText);
}
break;
case GC_EVENT_JOIN:
if (pszNick) {
- if (!streamData->lin->bIsMe)
+ if (!lin->bIsMe)
Log_AppendRTF(streamData, true, buf, TranslateT("%s has joined"), pszNick);
else
Log_AppendRTF(streamData, false, buf, TranslateT("You have joined %s"), streamData->si->ptszName);
@@ -229,54 +231,54 @@ static void AddEventToBuffer(CMStringA &buf, LOGSTREAMDATA *streamData) case GC_EVENT_PART:
if (pszNick)
Log_AppendRTF(streamData, true, buf, TranslateT("%s has left"), pszNick);
- if (streamData->lin->ptszText)
- Log_AppendRTF(streamData, true, buf, L": %s", streamData->lin->ptszText);
+ if (lin->ptszText)
+ Log_AppendRTF(streamData, true, buf, L": %s", lin->ptszText);
break;
case GC_EVENT_QUIT:
if (pszNick)
Log_AppendRTF(streamData, true, buf, TranslateT("%s has disconnected"), pszNick);
- if (streamData->lin->ptszText)
- Log_AppendRTF(streamData, false, buf, L": %s", streamData->lin->ptszText);
+ if (lin->ptszText)
+ Log_AppendRTF(streamData, false, buf, L": %s", lin->ptszText);
break;
case GC_EVENT_NICK:
- if (pszNick && streamData->lin->ptszText) {
- if (!streamData->lin->bIsMe)
- Log_AppendRTF(streamData, true, buf, TranslateT("%s is now known as %s"), pszNick, streamData->lin->ptszText);
+ if (pszNick && lin->ptszText) {
+ if (!lin->bIsMe)
+ Log_AppendRTF(streamData, true, buf, TranslateT("%s is now known as %s"), pszNick, lin->ptszText);
else
- Log_AppendRTF(streamData, true, buf, TranslateT("You are now known as %s"), streamData->lin->ptszText);
+ Log_AppendRTF(streamData, true, buf, TranslateT("You are now known as %s"), lin->ptszText);
}
break;
case GC_EVENT_KICK:
- if (streamData->lin->ptszNick && streamData->lin->ptszStatus)
- Log_AppendRTF(streamData, true, buf, TranslateT("%s kicked %s"), streamData->lin->ptszStatus, streamData->lin->ptszNick);
- if (streamData->lin->ptszText)
- Log_AppendRTF(streamData, false, buf, L": %s", streamData->lin->ptszText);
+ if (lin->ptszNick && lin->ptszStatus)
+ Log_AppendRTF(streamData, true, buf, TranslateT("%s kicked %s"), lin->ptszStatus, lin->ptszNick);
+ if (lin->ptszText)
+ Log_AppendRTF(streamData, false, buf, L": %s", lin->ptszText);
break;
case GC_EVENT_NOTICE:
- if (pszNick && streamData->lin->ptszText) {
+ if (pszNick && lin->ptszText) {
Log_AppendRTF(streamData, true, buf, TranslateT("Notice from %s: "), pszNick);
- Log_AppendRTF(streamData, false, buf, L"%s", streamData->lin->ptszText);
+ Log_AppendRTF(streamData, false, buf, L"%s", lin->ptszText);
}
break;
case GC_EVENT_TOPIC:
- if (streamData->lin->ptszText)
- Log_AppendRTF(streamData, false, buf, TranslateT("The topic is '%s%s'"), streamData->lin->ptszText, L"%r");
- if (streamData->lin->ptszNick)
+ if (lin->ptszText)
+ Log_AppendRTF(streamData, false, buf, TranslateT("The topic is '%s%s'"), lin->ptszText, L"%r");
+ if (lin->ptszNick)
Log_AppendRTF(streamData, true, buf,
- streamData->lin->ptszUserInfo ? TranslateT(" (set by %s on %s)") : TranslateT(" (set by %s)"),
- streamData->lin->ptszNick, streamData->lin->ptszUserInfo);
+ lin->ptszUserInfo ? TranslateT(" (set by %s on %s)") : TranslateT(" (set by %s)"),
+ lin->ptszNick, lin->ptszUserInfo);
break;
case GC_EVENT_INFORMATION:
- if (streamData->lin->ptszText)
- Log_AppendRTF(streamData, false, buf, (streamData->lin->bIsMe) ? L"--> %s" : L"%s", streamData->lin->ptszText);
+ if (lin->ptszText)
+ Log_AppendRTF(streamData, false, buf, (lin->bIsMe) ? L"--> %s" : L"%s", lin->ptszText);
break;
case GC_EVENT_ADDSTATUS:
- if (streamData->lin->ptszNick && streamData->lin->ptszText && streamData->lin->ptszStatus)
- Log_AppendRTF(streamData, true, buf, TranslateT("%s enables '%s' status for %s"), streamData->lin->ptszText, streamData->lin->ptszStatus, streamData->lin->ptszNick);
+ if (lin->ptszNick && lin->ptszText && lin->ptszStatus)
+ Log_AppendRTF(streamData, true, buf, TranslateT("%s enables '%s' status for %s"), lin->ptszText, lin->ptszStatus, lin->ptszNick);
break;
case GC_EVENT_REMOVESTATUS:
- if (streamData->lin->ptszNick && streamData->lin->ptszText && streamData->lin->ptszStatus)
- Log_AppendRTF(streamData, TRUE, buf, TranslateT("%s disables '%s' status for %s"), streamData->lin->ptszText, streamData->lin->ptszStatus, streamData->lin->ptszNick);
+ if (lin->ptszNick && lin->ptszText && lin->ptszStatus)
+ Log_AppendRTF(streamData, TRUE, buf, TranslateT("%s disables '%s' status for %s"), lin->ptszText, lin->ptszStatus, lin->ptszNick);
break;
}
}
@@ -291,7 +293,8 @@ wchar_t* MakeTimeStamp(wchar_t *pszStamp, time_t time) char* Log_CreateRTF(LOGSTREAMDATA *streamData)
{
- MODULEINFO *mi = chatApi.MM_FindModule(streamData->si->pszModule);
+ SESSION_INFO *si = streamData->si;
+ MODULEINFO *mi = chatApi.MM_FindModule(si->pszModule);
// guesstimate amount of memory for the RTF
CMStringA buf;
@@ -304,8 +307,8 @@ char* Log_CreateRTF(LOGSTREAMDATA *streamData) // ### RTF BODY (one iteration per event that should be streamed in)
for (LOGINFO *lin = streamData->lin; lin; lin = lin->prev) {
// filter
- if (streamData->si->iType == GCW_CHATROOM || streamData->si->iType == GCW_PRIVMESS)
- if (streamData->si->bFilterEnabled && (streamData->si->iLogFilterFlags & lin->iType) == 0)
+ if (si->iType == GCW_CHATROOM || si->iType == GCW_PRIVMESS)
+ if (si->pDlg->m_bFilterEnabled && (si->pDlg->m_iLogFilterFlags & lin->iType) == 0)
continue;
// create new line, and set font and color
@@ -343,9 +346,9 @@ char* Log_CreateRTF(LOGSTREAMDATA *streamData) wchar_t szTimeStamp[30], szOldTimeStamp[30];
mir_wstrncpy(szTimeStamp, MakeTimeStamp(g_Settings->pszTimeStamp, lin->time), 30);
- mir_wstrncpy(szOldTimeStamp, MakeTimeStamp(g_Settings->pszTimeStamp, streamData->si->LastTime), 30);
- if (!g_Settings->bShowTimeIfChanged || streamData->si->LastTime == 0 || mir_wstrcmp(szTimeStamp, szOldTimeStamp)) {
- streamData->si->LastTime = lin->time;
+ mir_wstrncpy(szOldTimeStamp, MakeTimeStamp(g_Settings->pszTimeStamp, si->LastTime), 30);
+ if (!g_Settings->bShowTimeIfChanged || si->LastTime == 0 || mir_wstrcmp(szTimeStamp, szOldTimeStamp)) {
+ si->LastTime = lin->time;
Log_AppendRTF(streamData, TRUE, buf, L"%s", szTimeStamp);
}
buf.Append("\\tab ");
diff --git a/src/mir_app/src/chat_svc.cpp b/src/mir_app/src/chat_svc.cpp index a3f8f492d0..8256520450 100644 --- a/src/mir_app/src/chat_svc.cpp +++ b/src/mir_app/src/chat_svc.cpp @@ -229,20 +229,8 @@ EXTERN_C MIR_APP_DLL(GCSessionInfoBase*) Chat_NewSession( si->wStatus = ID_STATUS_ONLINE;
si->iType = iType;
si->ptszName = mir_wstrdup(ptszName);
- si->iLogFilterFlags = db_get_dw(NULL, CHAT_MODULE, "FilterFlags", 0x03E0);
- si->bFilterEnabled = db_get_b(NULL, CHAT_MODULE, "FilterEnabled", 0) != 0;
- si->bNicklistEnabled = db_get_b(NULL, CHAT_MODULE, "ShowNicklist", 1) != 0;
si->currentHovered = -1;
- if (mi->bColor) {
- si->iFG = 4;
- si->bFGSet = true;
- }
- if (mi->bBkgColor) {
- si->iBG = 2;
- si->bBGSet = true;
- }
-
wchar_t szTemp[256];
if (si->iType == GCW_SERVER)
mir_snwprintf(szTemp, L"Server: %s", si->ptszName);
diff --git a/src/mir_app/src/colorchooser.cpp b/src/mir_app/src/colorchooser.cpp index b33d296a81..942ef2ff8e 100644 --- a/src/mir_app/src/colorchooser.cpp +++ b/src/mir_app/src/colorchooser.cpp @@ -140,8 +140,8 @@ public: int ctrlId = GetDlgCtrlID(m_hwndChooser);
if (m_bForeground) {
- m_si->bFGSet = true;
- m_si->iFG = iCurrentHotTrack;
+ m_si->pDlg->m_bFGSet = true;
+ m_si->pDlg->m_iFG = iCurrentHotTrack;
if (IsDlgButtonChecked(hWindow, ctrlId)) {
cf.dwMask = CFM_COLOR;
cf.crTextColor = m_pModule->crColors[iCurrentHotTrack];
@@ -149,8 +149,8 @@ public: }
}
else {
- m_si->bBGSet = true;
- m_si->iBG = iCurrentHotTrack;
+ m_si->pDlg->m_bBGSet = true;
+ m_si->pDlg->m_iBG = iCurrentHotTrack;
if (IsDlgButtonChecked(hWindow, ctrlId)) {
cf.dwMask = CFM_BACKCOLOR;
cf.crBackColor = m_pModule->crColors[iCurrentHotTrack];
@@ -224,7 +224,7 @@ public: iThisRow++;
}
- if (m_bForeground && m_si->bFGSet && m_si->iFG == i || !m_bForeground && m_si->bBGSet && m_si->iBG == i) {
+ if (m_bForeground && m_si->pDlg->m_bFGSet && m_si->pDlg->m_iFG == i || !m_bForeground && m_si->pDlg->m_bBGSet && m_si->pDlg->m_iBG == i) {
rc.top = (iThisRow - 1) * 20 + 1 + 20;
rc.left = (iThisColumn - 1) * 25 + 1 + 1;
rc.bottom = iThisRow * 20 - 1 + 20;
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index e725d21d0f..d6414d4a10 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -399,7 +399,7 @@ Chat_UnescapeTags @399 NONAME ProtoGetAvatarFormatByMimeType @400
ProtoGetAvatarMimeType @401
?set_uin@DB_AUTH_BLOB@@QAEXK@Z @402 NONAME
-??0CSrmmBaseDialog@@IAE@PAUHINSTANCE__@@H@Z @403 NONAME
+??0CSrmmBaseDialog@@IAE@PAUHINSTANCE__@@HPAUSESSION_INFO@@@Z @403 NONAME
??0CSrmmBaseDialog@@QAE@ABV0@@Z @404 NONAME
??1CSrmmBaseDialog@@UAE@XZ @405 NONAME
??4CSrmmBaseDialog@@QAEAAV0@ABV0@@Z @406 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index b23014f010..1c66d0534a 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -399,7 +399,7 @@ Chat_UnescapeTags @399 NONAME ProtoGetAvatarFormatByMimeType @400
ProtoGetAvatarMimeType @401
?set_uin@DB_AUTH_BLOB@@QEAAXK@Z @402 NONAME
-??0CSrmmBaseDialog@@IEAA@PEAUHINSTANCE__@@H@Z @403 NONAME
+??0CSrmmBaseDialog@@IEAA@PEAUHINSTANCE__@@HPEAUSESSION_INFO@@@Z @403 NONAME
??0CSrmmBaseDialog@@QEAA@AEBV0@@Z @404 NONAME
??1CSrmmBaseDialog@@UEAA@XZ @405 NONAME
??4CSrmmBaseDialog@@QEAAAEAV0@AEBV0@@Z @406 NONAME
diff --git a/src/mir_app/src/srmm_base.cpp b/src/mir_app/src/srmm_base.cpp index 65f6c65d3c..0d007ea68f 100644 --- a/src/mir_app/src/srmm_base.cpp +++ b/src/mir_app/src/srmm_base.cpp @@ -23,15 +23,36 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h" +#include "chat.h" + extern HCURSOR g_hCurHyperlinkHand; -CSrmmBaseDialog::CSrmmBaseDialog(HINSTANCE hInst, int idDialog) : +CSrmmBaseDialog::CSrmmBaseDialog(HINSTANCE hInst, int idDialog, SESSION_INFO *si) : CDlgBase(hInst, idDialog), - m_si(nullptr), + m_si(si), m_pLog(nullptr), m_pEntry(nullptr), m_hContact(0) { + m_bFilterEnabled = db_get_b(NULL, CHAT_MODULE, "FilterEnabled", 0) != 0; + m_bNicklistEnabled = db_get_b(NULL, CHAT_MODULE, "ShowNicklist", 1) != 0; + m_iLogFilterFlags = db_get_dw(NULL, CHAT_MODULE, "FilterFlags", 0x03E0); + + if (si) { + m_hContact = si->hContact; + + MODULEINFO *mi = chatApi.MM_FindModule(si->pszModule); + if (mi == nullptr) { + if (mi->bColor) { + m_iFG = 4; + m_bFGSet = true; + } + if (mi->bBkgColor) { + m_iBG = 2; + m_bBGSet = true; + } + } + } } INT_PTR CSrmmBaseDialog::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) |