diff options
author | George Hazan <george.hazan@gmail.com> | 2024-06-17 14:48:39 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-06-17 14:48:39 +0300 |
commit | 3f45ae2cea6bc24aa4f0c94a3c7c4009c64faa56 (patch) | |
tree | 952b1bafe6defc7ec7ee5f7861023add17f37ec0 /plugins/IEView/src/TemplateHTMLBuilder.cpp | |
parent | b4794ea974e77df6c8e6e096eaad562b8c3eda07 (diff) |
fixes #4458 (IEView: Template Does not apply to Groupchats)
Diffstat (limited to 'plugins/IEView/src/TemplateHTMLBuilder.cpp')
-rw-r--r-- | plugins/IEView/src/TemplateHTMLBuilder.cpp | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/plugins/IEView/src/TemplateHTMLBuilder.cpp b/plugins/IEView/src/TemplateHTMLBuilder.cpp index 0c83b98d07..ac7b1e90ea 100644 --- a/plugins/IEView/src/TemplateHTMLBuilder.cpp +++ b/plugins/IEView/src/TemplateHTMLBuilder.cpp @@ -61,22 +61,26 @@ char* TemplateHTMLBuilder::getAvatar(MCONTACT hContact, const char *szProto) }
db_free(&dbv);
}
- char* res = mir_utf8encodeW(result);
+ char *res = mir_utf8encodeW(result);
Utils::convertPath(res);
return res;
}
-TemplateMap *TemplateHTMLBuilder::getTemplateMap(ProtocolSettings * protoSettings)
+TemplateMap* TemplateHTMLBuilder::getTemplateMap(MCONTACT hContact, ProtocolSettings *protoSettings)
{
+ if (Contact::IsGroupChat(hContact))
+ if (auto *result = TemplateMap::getTemplateMap(_T2A(protoSettings->getChatTemplateFilename())))
+ return result;
+
return TemplateMap::getTemplateMap(_T2A(protoSettings->getSRMMTemplateFilename()));
}
-int TemplateHTMLBuilder::getFlags(ProtocolSettings * protoSettings)
+int TemplateHTMLBuilder::getFlags(ProtocolSettings *protoSettings)
{
return protoSettings->getSRMMFlags();
}
-char *TemplateHTMLBuilder::timestampToString(uint32_t dwFlags, time_t check, int mode)
+char* TemplateHTMLBuilder::timestampToString(uint32_t dwFlags, time_t check, int mode)
{
static char szResult[512]; szResult[0] = '\0';
wchar_t str[300];
@@ -109,7 +113,7 @@ void TemplateHTMLBuilder::buildHeadTemplate(IEView *view, IEVIEWEVENT *event, Pr return;
DBVARIANT dbv;
-
+
char tempStr[1024];
char *szNameIn = nullptr;
char *szNameOut = nullptr;
@@ -122,7 +126,7 @@ void TemplateHTMLBuilder::buildHeadTemplate(IEView *view, IEVIEWEVENT *event, Pr MCONTACT hRealContact = getRealContact(event->hContact);
const char *szRealProto = Proto_GetBaseAccountName(hRealContact);
- TemplateMap *tmpm = getTemplateMap(protoSettings);
+ TemplateMap *tmpm = getTemplateMap(hRealContact, protoSettings);
if (tmpm == nullptr)
return;
@@ -147,13 +151,13 @@ void TemplateHTMLBuilder::buildHeadTemplate(IEView *view, IEVIEWEVENT *event, Pr szNameIn = mir_strdup(" ");
}
mir_snprintf(tempStr, "%snoavatar.png", tempBase);
-
+
CMStringW szNoAvatarPath(protoSettings->getSRMMTemplateFilename());
int idx = szNoAvatarPath.Find('\\');
if (idx != -1)
szNoAvatarPath.Delete(0, idx);
szNoAvatarPath.Append(L"\\noavatar.png");
-
+
if (_waccess(szNoAvatarPath, 0) == -1)
mir_snprintf(tempStr, "%snoavatar.jpg", tempBase);
else
@@ -263,7 +267,7 @@ void TemplateHTMLBuilder::buildHeadTemplate(IEView *view, IEVIEWEVENT *event, Pr iLastEventType = -1;
}
-void TemplateHTMLBuilder::appendEventTemplate(IEView *view, IEVIEWEVENT *event, ProtocolSettings* protoSettings)
+void TemplateHTMLBuilder::appendEventTemplate(IEView *view, IEVIEWEVENT *event, ProtocolSettings *protoSettings)
{
if (protoSettings == nullptr)
return;
@@ -290,12 +294,12 @@ void TemplateHTMLBuilder::appendEventTemplate(IEView *view, IEVIEWEVENT *event, const char *szProto = Proto_GetBaseAccountName(event->hContact);
tempBase[0] = '\0';
- TemplateMap *tmpm = getTemplateMap(protoSettings);
+ TemplateMap *tmpm = getTemplateMap(hRealContact, protoSettings);
if (tmpm != nullptr) {
strncpy_s(tempBase, "file://", _TRUNCATE);
mir_strcat(tempBase, _T2A(tmpm->getFilename()));
- char* pathrun = nullptr;
+ char *pathrun = nullptr;
if (pathrun = strrchr(tempBase, '\\'))
*(++pathrun) = '\0';
else if (pathrun = strrchr(tempBase, '/'))
@@ -322,7 +326,7 @@ void TemplateHTMLBuilder::appendEventTemplate(IEView *view, IEVIEWEVENT *event, if (idx != -1)
szNoAvatarPath.Delete(0, idx);
szNoAvatarPath.Append(L"\\noavatar.png");
-
+
if (_waccess(szNoAvatarPath, 0) == -1)
mir_snprintf(tempStr, "%snoavatar.jpg", tempBase);
else
@@ -364,7 +368,7 @@ void TemplateHTMLBuilder::appendEventTemplate(IEView *view, IEVIEWEVENT *event, CMStringA str;
bool isSent = (eventData->dwFlags & IEEDF_SENT) != 0;
bool isRTL = (eventData->dwFlags & IEEDF_RTL) && tmpm->isRTL();
- bool isHistory = (eventData->time < (uint32_t)getStartedTime() && (eventData->dwFlags &IEEDF_READ || eventData->dwFlags & IEEDF_SENT));
+ bool isHistory = (eventData->time < (uint32_t)getStartedTime() && (eventData->dwFlags & IEEDF_READ || eventData->dwFlags & IEEDF_SENT));
bool isGroupBreak = true;
if ((getFlags(protoSettings) & Options::LOG_GROUP_MESSAGES) && eventData->dwFlags == LOWORD(getLastEventType())
&& eventData->iType == IEED_EVENT_MESSAGE && HIWORD(getLastEventType()) == IEED_EVENT_MESSAGE
|