summaryrefslogtreecommitdiff
path: root/plugins/TabSRMM
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/TabSRMM')
-rw-r--r--plugins/TabSRMM/src/msglog.cpp3
-rw-r--r--plugins/TabSRMM/src/utils.cpp126
2 files changed, 65 insertions, 64 deletions
diff --git a/plugins/TabSRMM/src/msglog.cpp b/plugins/TabSRMM/src/msglog.cpp
index 6815a68c19..512cd8373f 100644
--- a/plugins/TabSRMM/src/msglog.cpp
+++ b/plugins/TabSRMM/src/msglog.cpp
@@ -432,7 +432,6 @@ static char* Template_CreateRTFFromDbEvent(CTabBaseDlg *dat, MCONTACT hContact,
BOOL skipToNext = FALSE, skipFont = FALSE;
struct tm event_time = { 0 };
BOOL isBold = FALSE, isItalic = FALSE, isUnderline = FALSE;
- DWORD dwFormattingParams = MAKELONG(1, 0);
DBEVENTINFO dbei = { 0 };
if (streamData->dbei != 0)
@@ -459,7 +458,7 @@ static char* Template_CreateRTFFromDbEvent(CTabBaseDlg *dat, MCONTACT hContact,
return nullptr;
}
msg.TrimRight();
- dat->FormatRaw(msg, dwFormattingParams, FALSE);
+ dat->FormatRaw(msg, 1, FALSE);
CMStringA str;
BOOL bIsStatusChangeEvent = IsStatusEvent(dbei.eventType);
diff --git a/plugins/TabSRMM/src/utils.cpp b/plugins/TabSRMM/src/utils.cpp
index 2083c1bec9..2a32e19292 100644
--- a/plugins/TabSRMM/src/utils.cpp
+++ b/plugins/TabSRMM/src/utils.cpp
@@ -73,10 +73,10 @@ void CTabBaseDlg::FormatRaw(CMStringW &msg, int flags, bool isSent)
if (m_dwFlags & MWF_LOG_BBCODE) {
beginmark = 0;
while (true) {
- for (i = 0; i < NR_CODES; i++) {
+ for (i = 0; i < NR_CODES; i++)
if ((tempmark = msg.Find(w_bbcodes_begin[i], 0)) != -1)
break;
- }
+
if (i >= NR_CODES)
break;
@@ -99,7 +99,7 @@ search_again:
if (!wcsnicmp(colorname, Utils::rtf_ctable[ii].szName, mir_wstrlen(Utils::rtf_ctable[ii].szName))) {
closing = beginmark + 7 + (int)mir_wstrlen(Utils::rtf_ctable[ii].szName);
if (endmark != -1) {
- msg.Delete(endmark, 4);
+ msg.Delete(endmark, 8);
msg.Insert(endmark, L"c0 ");
}
msg.Delete(beginmark, (closing - beginmark));
@@ -144,80 +144,82 @@ invalid_code:
}
continue;
}
- if (endmark != -1)
+
+ if (endmark != -1) {
+ msg.Delete(endmark, 4);
msg.Insert(endmark, formatting_strings_end[i]);
+ }
+ msg.Delete(beginmark, 4);
msg.Insert(beginmark, L" ");
msg.Insert(beginmark, formatting_strings_begin[i]);
}
}
- if (!(m_dwFlags & MWF_LOG_TEXTFORMAT) || msg.Find(L"://") != -1) {
- m_bClrAdded = clr_was_added;
- return;
- }
+ if ((m_dwFlags & MWF_LOG_TEXTFORMAT) && msg.Find(L"://") == -1) {
+ while ((beginmark = msg.Find(L"*/_", beginmark)) != -1) {
+ endmarker = msg[beginmark];
+ if (LOWORD(flags)) {
+ if (beginmark > 0 && !iswspace(msg[beginmark - 1]) && !iswpunct(msg[beginmark - 1])) {
+ beginmark++;
+ continue;
+ }
- while ((beginmark = msg.Find(L"*/_", beginmark)) != -1) {
- endmarker = msg[beginmark];
- if (LOWORD(flags)) {
- if (beginmark > 0 && !iswspace(msg[beginmark - 1]) && !iswpunct(msg[beginmark - 1])) {
- beginmark++;
- continue;
+ // search a corresponding endmarker which fulfills the criteria
+ INT_PTR mark = beginmark + 1;
+ while ((endmark = msg.Find(endmarker, mark)) != -1) {
+ if (iswpunct(msg[endmark + 1]) || iswspace(msg[endmark + 1]) || msg[endmark + 1] == 0 || wcschr(L"*/_", msg[endmark + 1]) != nullptr)
+ goto ok;
+ mark = endmark + 1;
+ }
+ break;
}
-
- // search a corresponding endmarker which fulfills the criteria
- INT_PTR mark = beginmark + 1;
- while ((endmark = msg.Find(endmarker, mark)) != -1) {
- if (iswpunct(msg[endmark + 1]) || iswspace(msg[endmark + 1]) || msg[endmark + 1] == 0 || wcschr(L"*/_", msg[endmark + 1]) != nullptr)
- goto ok;
- mark = endmark + 1;
+ else {
+ if ((endmark = msg.Find(endmarker, beginmark + 1)) == -1)
+ break;
}
- break;
- }
- else {
- if ((endmark = msg.Find(endmarker, beginmark + 1)) == -1)
- break;
- }
ok:
- if ((endmark - beginmark) < 2) {
- beginmark++;
- continue;
- }
- index = 0;
- switch (endmarker) {
- case '*':
+ if ((endmark - beginmark) < 2) {
+ beginmark++;
+ continue;
+ }
index = 0;
- break;
- case '/':
- index = 1;
- break;
- case '_':
- index = 2;
- break;
- }
+ switch (endmarker) {
+ case '*':
+ index = 0;
+ break;
+ case '/':
+ index = 1;
+ break;
+ case '_':
+ index = 2;
+ break;
+ }
- // check if the code enclosed by simple formatting tags is a valid smiley code and skip formatting if
- // it really is one.
- if (PluginConfig.g_SmileyAddAvail && (endmark > (beginmark + 1))) {
- CMStringW smcode = msg.Mid(beginmark, (endmark - beginmark) + 1);
-
- SMADD_BATCHPARSE2 smbp = { 0 };
- smbp.cbSize = sizeof(smbp);
- smbp.Protocolname = m_cache->getActiveProto();
- smbp.flag = SAFL_TCHAR | SAFL_PATH | (isSent ? SAFL_OUTGOING : 0);
- smbp.str = (wchar_t*)smcode.c_str();
- smbp.hContact = m_hContact;
- SMADD_BATCHPARSERES *smbpr = (SMADD_BATCHPARSERES *)CallService(MS_SMILEYADD_BATCHPARSE, 0, (LPARAM)&smbp);
- if (smbpr) {
- CallService(MS_SMILEYADD_BATCHFREE, 0, (LPARAM)smbpr);
- beginmark = endmark + 1;
- continue;
+ // check if the code enclosed by simple formatting tags is a valid smiley code and skip formatting if
+ // it really is one.
+ if (PluginConfig.g_SmileyAddAvail && (endmark > (beginmark + 1))) {
+ CMStringW smcode = msg.Mid(beginmark, (endmark - beginmark) + 1);
+
+ SMADD_BATCHPARSE2 smbp = { 0 };
+ smbp.cbSize = sizeof(smbp);
+ smbp.Protocolname = m_cache->getActiveProto();
+ smbp.flag = SAFL_TCHAR | SAFL_PATH | (isSent ? SAFL_OUTGOING : 0);
+ smbp.str = (wchar_t*)smcode.c_str();
+ smbp.hContact = m_hContact;
+ SMADD_BATCHPARSERES *smbpr = (SMADD_BATCHPARSERES *)CallService(MS_SMILEYADD_BATCHPARSE, 0, (LPARAM)&smbp);
+ if (smbpr) {
+ CallService(MS_SMILEYADD_BATCHFREE, 0, (LPARAM)smbpr);
+ beginmark = endmark + 1;
+ continue;
+ }
}
+ msg.Delete(endmark, 1);
+ msg.Insert(endmark, formatting_strings_end[index]);
+ msg.Delete(beginmark, 1);
+ msg.Insert(beginmark, formatting_strings_begin[index]);
}
- msg.Insert(endmark, L"%%%");
- msg.Insert(endmark, formatting_strings_end[index]);
- msg.Insert(beginmark, L"%%%");
- msg.Insert(beginmark, formatting_strings_begin[index]);
}
+
m_bClrAdded = clr_was_added;
}