diff options
author | George Hazan <ghazan@miranda.im> | 2019-09-19 13:08:23 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-09-19 13:08:23 +0300 |
commit | 835555b9555f43be50582c4be774d65fe69fbe4d (patch) | |
tree | 98fdd6e6df7047603a52965c4299d0e4f8ba5a28 | |
parent | f28e24c9bd6eb51e07fd4ce82acff8add913df91 (diff) |
useless variable CMsgDialog::m_nMax removed
-rw-r--r-- | plugins/TabSRMM/src/contactcache.cpp | 22 | ||||
-rw-r--r-- | plugins/TabSRMM/src/controls.cpp | 13 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgdialog.cpp | 13 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgs.h | 1 | ||||
-rw-r--r-- | plugins/TabSRMM/src/sendqueue.cpp | 10 |
5 files changed, 31 insertions, 28 deletions
diff --git a/plugins/TabSRMM/src/contactcache.cpp b/plugins/TabSRMM/src/contactcache.cpp index ed30fba4b9..9298c79a03 100644 --- a/plugins/TabSRMM/src/contactcache.cpp +++ b/plugins/TabSRMM/src/contactcache.cpp @@ -449,17 +449,19 @@ HICON CContactCache::getIcon(int &iSize) const size_t CContactCache::getMaxMessageLength() { - MCONTACT hContact = getActiveContact(); - LPCSTR szProto = getActiveProto(); - if (szProto) { - m_nMax = CallProtoService(szProto, PS_GETCAPS, PFLAG_MAXLENOFMESSAGE, hContact); - if (m_nMax) { - if (M.GetByte("autosplit", 0)) - m_dat->LimitMessageText(20000); - else - m_dat->LimitMessageText(m_nMax); + if (m_nMax == 0) { + MCONTACT hContact = getActiveContact(); + LPCSTR szProto = getActiveProto(); + if (szProto) { + m_nMax = CallProtoService(szProto, PS_GETCAPS, PFLAG_MAXLENOFMESSAGE, hContact); + if (m_nMax) { + if (M.GetByte("autosplit", 0)) + m_nMax = 20000; + } + else m_nMax = 20000; + + m_dat->LimitMessageText(m_nMax); } - else m_dat->LimitMessageText(m_nMax = 20000); } return m_nMax; } diff --git a/plugins/TabSRMM/src/controls.cpp b/plugins/TabSRMM/src/controls.cpp index 62a22ec0f9..c3649a1cc1 100644 --- a/plugins/TabSRMM/src/controls.cpp +++ b/plugins/TabSRMM/src/controls.cpp @@ -790,8 +790,9 @@ LONG_PTR CALLBACK CMsgDialog::StatusBarSubclassProc(HWND hWnd, UINT msg, WPARAM rc.top = rc.bottom - 3;
rc.left = 0;
+ int iMaxSize = (int)dat->m_cache->getMaxMessageLength();
if (!PluginConfig.m_autoSplit) {
- float fMax = (float)dat->m_nMax;
+ float fMax = (float)iMaxSize;
float uPercent = (float)dat->m_textLen / ((fMax / (float)100.0) ? (fMax / (float)100.0) : (float)75.0);
float fx = ((float)rc.right / (float)100.0) * uPercent;
@@ -799,17 +800,17 @@ LONG_PTR CALLBACK CMsgDialog::StatusBarSubclassProc(HWND hWnd, UINT msg, WPARAM FillRect(hdcMem, &rc, br);
}
else {
- float baselen = (dat->m_textLen <= dat->m_nMax) ? (float)dat->m_textLen : (float)dat->m_nMax;
- float fMax = (float)dat->m_nMax;
+ float baselen = (dat->m_textLen <= iMaxSize) ? (float)dat->m_textLen : (float)iMaxSize;
+ float fMax = (float)iMaxSize;
float uPercent = baselen / ((fMax / (float)100.0) ? (fMax / (float)100.0) : (float)75.0);
float fx;
LONG width = rc.right - rc.left;
- if (dat->m_textLen >= dat->m_nMax)
+ if (dat->m_textLen >= iMaxSize)
rc.right = rc.right / 3;
fx = ((float)rc.right / (float)100.0) * uPercent;
rc.right = (LONG)fx;
FillRect(hdcMem, &rc, br);
- if (dat->m_textLen >= dat->m_nMax) {
+ if (dat->m_textLen >= iMaxSize) {
SelectObject(hdcMem, brOld);
DeleteObject(br);
br = CreateSolidBrush(RGB(255, 0, 0));
@@ -988,7 +989,7 @@ LONG_PTR CALLBACK CMsgDialog::StatusBarSubclassProc(HWND hWnd, UINT msg, WPARAM mir_snwprintf(wBuf,
TranslateT("There are %d pending send jobs. Message length: %d bytes, message length limit: %d bytes\n\n%d messages are queued for later delivery"),
- dat->m_iOpenJobs, dat->m_message.GetRichTextLength(CP_UTF8), dat->m_nMax ? dat->m_nMax : 20000, iQueued);
+ dat->m_iOpenJobs, dat->m_message.GetRichTextLength(CP_UTF8), dat->m_cache->getMaxMessageLength(), iQueued);
CallService("mToolTip/ShowTipW", (WPARAM)wBuf, (LPARAM)&ti);
}
diff --git a/plugins/TabSRMM/src/msgdialog.cpp b/plugins/TabSRMM/src/msgdialog.cpp index c0b6a04f2f..de3d44882b 100644 --- a/plugins/TabSRMM/src/msgdialog.cpp +++ b/plugins/TabSRMM/src/msgdialog.cpp @@ -592,6 +592,7 @@ bool CMsgDialog::OnInitDialog() // load old messages from history (if wanted...)
+ m_cache->getMaxMessageLength();
m_cache->updateStats(TSessionStats::INIT_TIMER);
LoadContactAvatar();
@@ -606,10 +607,9 @@ bool CMsgDialog::OnInitDialog() UpdateNickList();
}
else {
- if (m_hContact) {
+ if (m_hContact)
FindFirstEvent();
- m_nMax = (int)m_cache->getMaxMessageLength();
- }
+
DM_OptionsApplied(0, 0);
// restore saved msg if any...
@@ -2116,12 +2116,13 @@ LRESULT CMsgDialog::WndProc_Message(UINT msg, WPARAM wParam, LPARAM lParam) if (OpenClipboard(m_message.GetHwnd())) {
HANDLE hClip = GetClipboardData(CF_TEXT);
if (hClip) {
- if ((int)mir_strlen((char*)hClip) > m_nMax) {
+ size_t iMaxSize = m_cache->getMaxMessageLength();
+ if (mir_strlen((char*)hClip) > iMaxSize) {
wchar_t szBuffer[512];
if (M.GetByte("autosplit", 0))
- mir_snwprintf(szBuffer, TranslateT("WARNING: The message you are trying to paste exceeds the message size limit for the active protocol. It will be sent in chunks of max %d characters"), m_nMax - 10);
+ mir_snwprintf(szBuffer, TranslateT("WARNING: The message you are trying to paste exceeds the message size limit for the active protocol. It will be sent in chunks of max %d characters"), iMaxSize - 10);
else
- mir_snwprintf(szBuffer, TranslateT("The message you are trying to paste exceeds the message size limit for the active protocol. Only the first %d characters will be sent."), m_nMax);
+ mir_snwprintf(szBuffer, TranslateT("The message you are trying to paste exceeds the message size limit for the active protocol. Only the first %d characters will be sent."), iMaxSize);
ActivateTooltip(IDC_SRMM_MESSAGE, szBuffer);
}
}
diff --git a/plugins/TabSRMM/src/msgs.h b/plugins/TabSRMM/src/msgs.h index e09f552bce..9d299951ad 100644 --- a/plugins/TabSRMM/src/msgs.h +++ b/plugins/TabSRMM/src/msgs.h @@ -397,7 +397,6 @@ public: int m_iSplitterY, m_dynaSplitter;
int m_savedSplitterY, m_savedDynaSplit;
char *m_sendBuffer;
- int m_nMax; // max message size
wchar_t m_wszMyNickname[130];
wchar_t m_wszStatus[50];
diff --git a/plugins/TabSRMM/src/sendqueue.cpp b/plugins/TabSRMM/src/sendqueue.cpp index 73f56681c8..78744e7138 100644 --- a/plugins/TabSRMM/src/sendqueue.cpp +++ b/plugins/TabSRMM/src/sendqueue.cpp @@ -238,12 +238,12 @@ int SendQueue::sendQueued(CMsgDialog *dat, const int iEntry) if (dat->m_hContact == 0) return 0; //never happens - dat->m_nMax = (int)dat->m_cache->getMaxMessageLength(); // refresh length info + size_t iMaxSize = dat->m_cache->getMaxMessageLength(); if (M.GetByte("autosplit", 0) && !(dat->m_sendMode & SMODE_SENDLATER)) { // determine send buffer length BOOL fSplit = FALSE; - if ((int)getSendLength(iEntry) >= dat->m_nMax) + if (getSendLength(iEntry) >= iMaxSize) fSplit = true; if (!fSplit) @@ -253,7 +253,7 @@ int SendQueue::sendQueued(CMsgDialog *dat, const int iEntry) m_jobs[iEntry].hOwnerWnd = hwndDlg; m_jobs[iEntry].iStatus = SQ_INPROGRESS; m_jobs[iEntry].iAcksNeeded = 1; - m_jobs[iEntry].chunkSize = dat->m_nMax; + m_jobs[iEntry].chunkSize = (int)iMaxSize; DWORD dwOldFlags = m_jobs[iEntry].dwFlags; mir_forkthread(DoSplitSendA, (LPVOID)iEntry); @@ -269,8 +269,8 @@ int SendQueue::sendQueued(CMsgDialog *dat, const int iEntry) wchar_t tszError[256]; size_t iSendLength = getSendLength(iEntry); - if ((int)iSendLength >= dat->m_nMax) { - mir_snwprintf(tszError, TranslateT("The message cannot be sent delayed or to multiple contacts, because it exceeds the maximum allowed message length of %d bytes"), dat->m_nMax); + if (iSendLength >= iMaxSize) { + mir_snwprintf(tszError, TranslateT("The message cannot be sent delayed or to multiple contacts, because it exceeds the maximum allowed message length of %d bytes"), iMaxSize); dat->ActivateTooltip(IDC_SRMM_MESSAGE, tszError); clearJob(iEntry); return 0; |