diff options
-rw-r--r-- | plugins/TabSRMM/src/chat.h | 3 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat_log.cpp | 3 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat_main.cpp | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/chat_options.cpp | 90 | ||||
-rw-r--r-- | plugins/TabSRMM/src/container.cpp | 4 | ||||
-rw-r--r-- | plugins/TabSRMM/src/eventpopups.cpp | 6 | ||||
-rw-r--r-- | plugins/TabSRMM/src/generic_msghandlers.cpp | 23 | ||||
-rw-r--r-- | plugins/TabSRMM/src/infopanel.cpp | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgdlgother.cpp | 4 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msglog.cpp | 18 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgoptions.cpp | 22 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgs.cpp | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/msgs.h | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/selectcontainer.cpp | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/sendlater.cpp | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/stdafx.h | 2 | ||||
-rw-r--r-- | plugins/TabSRMM/src/themeio.cpp | 7 | ||||
-rw-r--r-- | plugins/TabSRMM/src/themes.cpp | 2 |
18 files changed, 85 insertions, 111 deletions
diff --git a/plugins/TabSRMM/src/chat.h b/plugins/TabSRMM/src/chat.h index abb39a9634..17e7dab2f1 100644 --- a/plugins/TabSRMM/src/chat.h +++ b/plugins/TabSRMM/src/chat.h @@ -102,8 +102,7 @@ char* Log_CreateRTF(LOGSTREAMDATA *streamData); // options.c
enum { FONTSECTION_AUTO, FONTSECTION_IM, FONTSECTION_IP };
-void LoadMsgDlgFont(int section, int i, LOGFONT *lf, COLORREF *colour, char *szModule);
-void LoadLogfont(int section, int i, LOGFONTA *lf, COLORREF *colour, char *szModule);
+void LoadMsgDlgFont(int section, int i, LOGFONTW *lf, COLORREF *colour = nullptr);
void AddIcons(void);
HICON LoadIconEx(char *pszIcoLibName);
diff --git a/plugins/TabSRMM/src/chat_log.cpp b/plugins/TabSRMM/src/chat_log.cpp index 837a457a76..7732e26572 100644 --- a/plugins/TabSRMM/src/chat_log.cpp +++ b/plugins/TabSRMM/src/chat_log.cpp @@ -278,6 +278,9 @@ char* Log_CreateRtfHeader(void) szString[1] = 0;
szString[0] = 0x28;
g_chatApi.LoadMsgDlgFont(17, &lf, nullptr);
+ lf.lfCharSet = SYMBOL_CHARSET;
+ wcsncpy_s(lf.lfFaceName, L"Webdings", _TRUNCATE);
+
HFONT hFont = CreateFontIndirect(&lf);
int iText = Chat_GetTextPixelSize(szString, hFont, true) + 3;
DeleteObject(hFont);
diff --git a/plugins/TabSRMM/src/chat_main.cpp b/plugins/TabSRMM/src/chat_main.cpp index 45a64cb83d..ce201a4f91 100644 --- a/plugins/TabSRMM/src/chat_main.cpp +++ b/plugins/TabSRMM/src/chat_main.cpp @@ -224,7 +224,7 @@ void ShowRoom(TContainerData *pContainer, SESSION_INFO *si) if (pContainer == nullptr) {
GetContainerNameForContact(si->hContact, szName, CONTAINER_NAMELEN);
if (!g_Settings.bOpenInDefault && !mir_wstrcmp(szName, L"default"))
- wcsncpy(szName, L"Chat Rooms", CONTAINER_NAMELEN);
+ wcsncpy_s(szName, L"Chat Rooms", _TRUNCATE);
szName[CONTAINER_NAMELEN] = 0;
pContainer = FindContainerByName(szName);
}
diff --git a/plugins/TabSRMM/src/chat_options.cpp b/plugins/TabSRMM/src/chat_options.cpp index fcc1c1d3fb..79273619d5 100644 --- a/plugins/TabSRMM/src/chat_options.cpp +++ b/plugins/TabSRMM/src/chat_options.cpp @@ -126,7 +126,7 @@ static FontOptionsList IP_fontOptionsList[] = { LPGENW("Window caption (skinned mode)"), RGB(255, 255, 255), lfDefault.lfFaceName, DEFAULT_CHARSET, 0, -12 },
};
-void LoadMsgDlgFont(int section, int i, LOGFONT *lf, COLORREF* colour, char *szMod)
+void LoadMsgDlgFont(int section, int i, LOGFONT *lf, COLORREF* colour)
{
char str[32];
int db_idx = (section == FONTSECTION_IM) ? i : i + 100;
@@ -141,17 +141,17 @@ void LoadMsgDlgFont(int section, int i, LOGFONT *lf, COLORREF* colour, char *szM if (colour) {
mir_snprintf(str, "Font%dCol", db_idx);
- *colour = db_get_dw(0, szMod, str, fol[i].defColour);
+ *colour = db_get_dw(0, FONTMODULE, str, fol[i].defColour);
}
if (lf) {
mir_snprintf(str, "Font%dSize", db_idx);
- lf->lfHeight = (char)db_get_b(0, szMod, str, fol[i].defSize);
+ lf->lfHeight = (char)db_get_b(0, FONTMODULE, str, fol[i].defSize);
lf->lfWidth = 0;
lf->lfEscapement = 0;
lf->lfOrientation = 0;
mir_snprintf(str, "Font%dSty", db_idx);
- int style = db_get_b(0, szMod, str, fol[i].defStyle);
+ int style = db_get_b(0, FONTMODULE, str, fol[i].defStyle);
if (i == MSGFONTID_MESSAGEAREA && section == FONTSECTION_IM && M.GetByte("inputFontFix", 1) == 1) {
lf->lfWeight = FW_NORMAL;
lf->lfItalic = 0;
@@ -165,17 +165,17 @@ void LoadMsgDlgFont(int section, int i, LOGFONT *lf, COLORREF* colour, char *szM lf->lfStrikeOut = style & FONTF_STRIKEOUT ? 1 : 0;
}
mir_snprintf(str, "Font%dSet", db_idx);
- lf->lfCharSet = db_get_b(0, szMod, str, fol[i].defCharset);
+ lf->lfCharSet = db_get_b(0, FONTMODULE, str, fol[i].defCharset);
lf->lfOutPrecision = OUT_DEFAULT_PRECIS;
lf->lfClipPrecision = CLIP_DEFAULT_PRECIS;
lf->lfQuality = DEFAULT_QUALITY;
lf->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
mir_snprintf(str, "Font%d", db_idx);
- if ((i == 17 && !mir_strcmp(szMod, CHATFONT_MODULE)) || ((i == 20 || i == 21) && !mir_strcmp(szMod, FONTMODULE))) {
+ if (i == 20 || i == 21) {
lf->lfCharSet = SYMBOL_CHARSET;
wcsncpy_s(lf->lfFaceName, L"Webdings", _TRUNCATE);
}
- else wcsncpy_s(lf->lfFaceName, ptrW(db_get_wsa(0, szMod, str, fol[i].szDefFace)), _TRUNCATE);
+ else wcsncpy_s(lf->lfFaceName, ptrW(db_get_wsa(0, FONTMODULE, str, fol[i].szDefFace)), _TRUNCATE);
}
}
@@ -244,66 +244,66 @@ void RegisterFontServiceFonts() FontIDW fid = {};
ColourIDW cid = {};
- strncpy(fid.dbSettingsGroup, FONTMODULE, _countof(fid.dbSettingsGroup));
+ strncpy_s(fid.dbSettingsGroup, FONTMODULE, _TRUNCATE);
int i = 0;
for (auto &it : IM_fontOptionsList) {
fid.flags = FIDF_DEFAULTVALID | FIDF_ALLOWEFFECTS;
- LoadMsgDlgFont(FONTSECTION_IM, i, &lf, &it.colour, FONTMODULE);
+ LoadMsgDlgFont(FONTSECTION_IM, i, &lf, &it.colour);
mir_snprintf(fid.setting, "Font%d", i);
fid.order = i;
- wcsncpy(fid.name, it.szDescr, _countof(fid.name));
+ wcsncpy_s(fid.name, it.szDescr, _TRUNCATE);
fid.deffontsettings.colour = it.colour;
fid.deffontsettings.size = (char)lf.lfHeight;
fid.deffontsettings.style = (lf.lfWeight >= FW_BOLD ? FONTF_BOLD : 0) | (lf.lfItalic ? FONTF_ITALIC : 0);
fid.deffontsettings.charset = lf.lfCharSet;
fid.flags = fid.flags & ~FIDF_CLASSMASK | (fid.deffontsettings.style&FONTF_BOLD ? FIDF_CLASSHEADER : FIDF_CLASSGENERAL);
- wcsncpy(fid.deffontsettings.szFace, lf.lfFaceName, LF_FACESIZE);
- wcsncpy(fid.backgroundGroup, LPGENW("Message sessions") L"/" LPGENW("Single Messaging"), _countof(fid.backgroundGroup));
- wcsncpy(fid.group, LPGENW("Message sessions") L"/" LPGENW("Single Messaging"), _countof(fid.group));
+ wcsncpy_s(fid.deffontsettings.szFace, lf.lfFaceName, _TRUNCATE);
+ wcsncpy_s(fid.backgroundGroup, LPGENW("Message sessions") L"/" LPGENW("Single Messaging"), _TRUNCATE);
+ wcsncpy_s(fid.group, LPGENW("Message sessions") L"/" LPGENW("Single Messaging"), _TRUNCATE);
switch (i) {
case MSGFONTID_MYMSG:
case MSGFONTID_MYMISC:
case MSGFONTID_MYNAME:
case MSGFONTID_MYTIME:
case MSGFONTID_SYMBOLS_OUT:
- wcsncpy(fid.backgroundName, LPGENW("Outgoing background"), _countof(fid.backgroundName));
+ wcsncpy_s(fid.backgroundName, LPGENW("Outgoing background"), _TRUNCATE);
break;
case H_MSGFONTID_MYMSG:
case H_MSGFONTID_MYMISC:
case H_MSGFONTID_MYNAME:
case H_MSGFONTID_MYTIME:
case MSGFONTID_SYMBOLS_IN:
- wcsncpy(fid.backgroundName, LPGENW("Outgoing background(old)"), _countof(fid.backgroundName));
+ wcsncpy_s(fid.backgroundName, LPGENW("Outgoing background(old)"), _TRUNCATE);
break;
case MSGFONTID_YOURMSG:
case MSGFONTID_YOURMISC:
case MSGFONTID_YOURNAME:
case MSGFONTID_YOURTIME:
- wcsncpy(fid.backgroundName, LPGENW("Incoming background"), _countof(fid.backgroundName));
+ wcsncpy_s(fid.backgroundName, LPGENW("Incoming background"), _TRUNCATE);
break;
case H_MSGFONTID_YOURMSG:
case H_MSGFONTID_YOURMISC:
case H_MSGFONTID_YOURNAME:
case H_MSGFONTID_YOURTIME:
- wcsncpy(fid.backgroundName, LPGENW("Incoming background(old)"), _countof(fid.backgroundName));
+ wcsncpy_s(fid.backgroundName, LPGENW("Incoming background(old)"), _TRUNCATE);
break;
case MSGFONTID_MESSAGEAREA:
- wcsncpy(fid.group, LPGENW("Message sessions"), _countof(fid.group));
- wcsncpy(fid.backgroundGroup, LPGENW("Message sessions"), _countof(fid.backgroundGroup));
- wcsncpy(fid.backgroundName, LPGENW("Input area background"), _countof(fid.backgroundName));
+ wcsncpy_s(fid.group, LPGENW("Message sessions"), _TRUNCATE);
+ wcsncpy_s(fid.backgroundGroup, LPGENW("Message sessions"), _TRUNCATE);
+ wcsncpy_s(fid.backgroundName, LPGENW("Input area background"), _TRUNCATE);
break;
case H_MSGFONTID_STATUSCHANGES:
fid.flags |= FIDF_DISABLESTYLES;
fid.flags &= ~FIDF_ALLOWEFFECTS;
- wcsncpy(fid.backgroundName, LPGENW("Status background"), _countof(fid.backgroundName));
+ wcsncpy_s(fid.backgroundName, LPGENW("Status background"), _TRUNCATE);
break;
case H_MSGFONTID_DIVIDERS:
- wcsncpy(fid.backgroundGroup, LPGENW("Message sessions"), _countof(fid.backgroundGroup));
- wcsncpy(fid.backgroundName, LPGENW("Log background"), _countof(fid.backgroundName));
+ wcsncpy_s(fid.backgroundGroup, LPGENW("Message sessions"), _TRUNCATE);
+ wcsncpy_s(fid.backgroundName, LPGENW("Log background"), _TRUNCATE);
break;
case MSGFONTID_ERROR:
- wcsncpy(fid.backgroundName, L"", _countof(fid.backgroundName));
+ fid.backgroundName[0] = 0;
break;
}
g_plugin.addFont(&fid);
@@ -312,35 +312,35 @@ void RegisterFontServiceFonts() i = 0;
fid.flags = FIDF_DEFAULTVALID | FIDF_ALLOWEFFECTS;
- wcsncpy(fid.group, LPGENW("Message sessions") L"/" LPGENW("Info Panel"), _countof(fid.group));
- wcsncpy(fid.backgroundGroup, LPGENW("Message sessions") L"/" LPGENW("Info Panel"), _countof(fid.backgroundGroup));
- wcsncpy(fid.backgroundName, LPGENW("Fields background"), _countof(fid.backgroundName));
+ wcsncpy_s(fid.group, LPGENW("Message sessions") L"/" LPGENW("Info Panel"), _TRUNCATE);
+ wcsncpy_s(fid.backgroundGroup, LPGENW("Message sessions") L"/" LPGENW("Info Panel"), _TRUNCATE);
+ wcsncpy_s(fid.backgroundName, LPGENW("Fields background"), _TRUNCATE);
for (auto &it : IP_fontOptionsList) {
- LoadMsgDlgFont(FONTSECTION_IP, i, &lf, &it.colour, FONTMODULE);
+ LoadMsgDlgFont(FONTSECTION_IP, i, &lf, &it.colour);
mir_snprintf(fid.setting, "Font%d", i+100);
fid.order = i+100;
- wcsncpy(fid.name, it.szDescr, _countof(fid.name));
+ wcsncpy_s(fid.name, it.szDescr, _TRUNCATE);
fid.deffontsettings.colour = it.colour;
fid.deffontsettings.size = (char)lf.lfHeight;
fid.deffontsettings.style = (lf.lfWeight >= FW_BOLD ? FONTF_BOLD : 0) | (lf.lfItalic ? FONTF_ITALIC : 0);
fid.deffontsettings.charset = lf.lfCharSet;
fid.flags = fid.flags & ~FIDF_CLASSMASK | (fid.deffontsettings.style&FONTF_BOLD ? FIDF_CLASSHEADER : FIDF_CLASSGENERAL);
fid.deffontsettings.charset = lf.lfCharSet;
- wcsncpy(fid.deffontsettings.szFace, lf.lfFaceName, LF_FACESIZE);
+ wcsncpy_s(fid.deffontsettings.szFace, lf.lfFaceName, _TRUNCATE);
if (i == IPFONTCOUNT - 1) {
- wcsncpy(fid.backgroundGroup, L"", _countof(fid.backgroundGroup));
- wcsncpy(fid.backgroundName, L"", _countof(fid.backgroundName));
- wcsncpy(fid.group, LPGENW("Message sessions"), _countof(fid.group));
+ fid.backgroundGroup[0] = 0;
+ fid.backgroundName[0] = 0;
+ wcsncpy_s(fid.group, LPGENW("Message sessions"), _TRUNCATE);
}
g_plugin.addFont(&fid);
i++;
}
- wcsncpy(cid.group, LPGENW("Message sessions") L"/" LPGENW("Group chats"), _countof(cid.group));
- strncpy(cid.dbSettingsGroup, CHAT_MODULE, _countof(cid.dbSettingsGroup));
+ wcsncpy_s(cid.group, LPGENW("Message sessions") L"/" LPGENW("Group chats"), _TRUNCATE);
+ strncpy_s(cid.dbSettingsGroup, CHAT_MODULE, _TRUNCATE);
for (i = 0; i <= 7; i++) {
mir_snprintf(cid.setting, "NickColor%d", i);
- wcsncpy(cid.name, chatcolorsnames[i], _countof(cid.name));
+ wcsncpy_s(cid.name, chatcolorsnames[i], _TRUNCATE);
cid.order = i + 1;
switch (i) {
case 5:
@@ -367,14 +367,14 @@ void RegisterFontServiceFonts() g_plugin.addColor(&cid);
// static colors (info panel, tool bar background etc...)
- strncpy(fid.dbSettingsGroup, FONTMODULE, _countof(fid.dbSettingsGroup));
- strncpy(cid.dbSettingsGroup, FONTMODULE, _countof(fid.dbSettingsGroup));
+ strncpy_s(fid.dbSettingsGroup, FONTMODULE, _TRUNCATE);
+ strncpy_s(cid.dbSettingsGroup, FONTMODULE, _TRUNCATE);
for (auto &it : _clrs) {
cid.order = it.order;
- wcsncpy(cid.group, it.tszGroup, _countof(fid.group));
- wcsncpy(cid.name, it.tszName, _countof(cid.name));
- strncpy(cid.setting, it.szSetting, _countof(cid.setting));
+ wcsncpy_s(cid.group, it.tszGroup, _TRUNCATE);
+ wcsncpy_s(cid.name, it.tszName, _TRUNCATE);
+ strncpy_s(cid.setting, it.szSetting, _TRUNCATE);
if (it.def & 0xff000000)
cid.defcolour = GetSysColor(it.def & 0x000000ff);
else
@@ -382,14 +382,14 @@ void RegisterFontServiceFonts() g_plugin.addColor(&cid);
}
- strncpy(cid.dbSettingsGroup, SRMSGMOD_T, _countof(fid.dbSettingsGroup));
+ strncpy_s(cid.dbSettingsGroup, SRMSGMOD_T, _TRUNCATE);
// text and background colors for tabs
for (auto &it : _tabclrs) {
cid.order = it.order;
- wcsncpy(cid.group, it.tszGroup, _countof(fid.group));
- wcsncpy(cid.name, it.tszName, _countof(cid.name));
- strncpy(cid.setting, it.szSetting, _countof(cid.setting));
+ wcsncpy_s(cid.group, it.tszGroup, _TRUNCATE);
+ wcsncpy_s(cid.name, it.tszName, _TRUNCATE);
+ strncpy_s(cid.setting, it.szSetting, _TRUNCATE);
if (it.def & 0xff000000)
cid.defcolour = GetSysColor(it.def & 0x000000ff);
else
diff --git a/plugins/TabSRMM/src/container.cpp b/plugins/TabSRMM/src/container.cpp index 2e3e4f8e82..acebc25dc2 100644 --- a/plugins/TabSRMM/src/container.cpp +++ b/plugins/TabSRMM/src/container.cpp @@ -463,7 +463,7 @@ void TContainerData::LoadOverrideTheme() memcpy(m_rtl_templates, &RTL_Active, sizeof(TTemplateSet));
}
- m_theme.logFonts = (LOGFONTA *)mir_alloc(sizeof(LOGFONTA) * (MSGDLGFONTCOUNT + 2));
+ m_theme.logFonts = (LOGFONTW *)mir_alloc(sizeof(LOGFONTW) * (MSGDLGFONTCOUNT + 2));
m_theme.fontColors = (COLORREF *)mir_alloc(sizeof(COLORREF) * (MSGDLGFONTCOUNT + 2));
m_theme.rtfFonts = (char *)mir_alloc((MSGDLGFONTCOUNT + 2) * RTFCACHELINESIZE);
@@ -2155,7 +2155,7 @@ TContainerData* TSAPI CreateContainer(const wchar_t *name, int iTemp, MCONTACT h return nullptr;
TContainerData *pContainer = new TContainerData();
- wcsncpy(pContainer->m_wszName, name, CONTAINER_NAMELEN + 1);
+ wcsncpy_s(pContainer->m_wszName, name, _TRUNCATE);
AppendToContainerList(pContainer);
if (M.GetByte("limittabs", 0) && !mir_wstrcmp(name, L"default"))
diff --git a/plugins/TabSRMM/src/eventpopups.cpp b/plugins/TabSRMM/src/eventpopups.cpp index e4f5bcc465..7b28288a9e 100644 --- a/plugins/TabSRMM/src/eventpopups.cpp +++ b/plugins/TabSRMM/src/eventpopups.cpp @@ -339,7 +339,7 @@ static int PopupUpdateT(MCONTACT hContact, MEVENT hEvent) wchar_t lpzText[MAX_SECONDLINE];
int i, available = MAX_SECONDLINE - 1;
if (pdata->pluginOptions->bShowHeaders) {
- wcsncpy(lpzText, szHeader, MAX_SECONDLINE);
+ wcsncpy_s(lpzText, szHeader, _TRUNCATE);
available -= (int)mir_wstrlen(szHeader);
}
else lpzText[0] = 0;
@@ -426,12 +426,12 @@ static int PopupShowT(NEN_OPTIONS *pluginOptions, MCONTACT hContact, MEVENT hEve wcsncpy_s(pud.lpwzText, szPreview, _TRUNCATE);
mir_free(szPreview);
}
- else wcsncpy(pud.lpwzText, L" ", MAX_SECONDLINE);
+ else wcsncpy_s(pud.lpwzText, L" ", _TRUNCATE);
pdata->eventData = (EVENT_DATAT *)mir_alloc(NR_MERGED * sizeof(EVENT_DATAT));
pdata->eventData[0].hEvent = hEvent;
pdata->eventData[0].timestamp = dbe.timestamp;
- wcsncpy(pdata->eventData[0].tszText, pud.lpwzText, MAX_SECONDLINE);
+ wcsncpy_s(pdata->eventData[0].tszText, pud.lpwzText, _TRUNCATE);
pdata->eventData[0].tszText[MAX_SECONDLINE - 1] = 0;
pdata->nrEventsAlloced = NR_MERGED;
pdata->nrMerged = 1;
diff --git a/plugins/TabSRMM/src/generic_msghandlers.cpp b/plugins/TabSRMM/src/generic_msghandlers.cpp index 499a0883fb..04bed928fb 100644 --- a/plugins/TabSRMM/src/generic_msghandlers.cpp +++ b/plugins/TabSRMM/src/generic_msghandlers.cpp @@ -497,11 +497,8 @@ LRESULT CMsgDialog::DM_MsgWindowCmdHandler(UINT cmd, WPARAM wParam, LPARAM lPara void CMsgDialog::DM_InitRichEdit() { - bool fIsChat = isChat(); - COLORREF inputcharcolor; - char *szStreamOut = nullptr; - if (!fIsChat && GetWindowTextLength(m_message.GetHwnd()) > 0) + if (!isChat() && GetWindowTextLength(m_message.GetHwnd()) > 0) szStreamOut = m_message.GetRichTextRtf(); SetWindowText(m_message.GetHwnd(), L""); @@ -509,27 +506,27 @@ void CMsgDialog::DM_InitRichEdit() m_message.SendMsg(EM_SETBKGNDCOLOR, 0, m_pContainer->m_theme.inputbg); - CHARFORMAT2A cf2; - memset(&cf2, 0, sizeof(CHARFORMAT2A)); + CHARFORMAT2 cf2 = {}; cf2.cbSize = sizeof(cf2); - if (fIsChat) { - LOGFONTA lf; - LoadLogfont(FONTSECTION_IM, MSGFONTID_MESSAGEAREA, &lf, &inputcharcolor, FONTMODULE); + if (isChat()) { + LOGFONTW lf; + COLORREF inputcharcolor; + LoadMsgDlgFont(FONTSECTION_IM, MSGFONTID_MESSAGEAREA, &lf, &inputcharcolor); cf2.dwMask = CFM_COLOR | CFM_FACE | CFM_CHARSET | CFM_SIZE | CFM_WEIGHT | CFM_ITALIC | CFM_BACKCOLOR; cf2.crTextColor = inputcharcolor; cf2.bCharSet = lf.lfCharSet; cf2.crBackColor = m_pContainer->m_theme.inputbg; - strncpy(cf2.szFaceName, lf.lfFaceName, LF_FACESIZE); + wcsncpy_s(cf2.szFaceName, lf.lfFaceName, _TRUNCATE); cf2.dwEffects = 0; cf2.wWeight = (WORD)lf.lfWeight; cf2.bPitchAndFamily = lf.lfPitchAndFamily; cf2.yHeight = abs(lf.lfHeight) * 15; } else { - LOGFONTA lf = m_pContainer->m_theme.logFonts[MSGFONTID_MESSAGEAREA]; - inputcharcolor = m_pContainer->m_theme.fontColors[MSGFONTID_MESSAGEAREA]; + LOGFONTW lf = m_pContainer->m_theme.logFonts[MSGFONTID_MESSAGEAREA]; + COLORREF inputcharcolor = m_pContainer->m_theme.fontColors[MSGFONTID_MESSAGEAREA]; for (auto &it : Utils::rtf_clrs) if (it->clr == inputcharcolor) @@ -538,7 +535,7 @@ void CMsgDialog::DM_InitRichEdit() cf2.dwMask = CFM_COLOR | CFM_FACE | CFM_CHARSET | CFM_SIZE | CFM_WEIGHT | CFM_BOLD | CFM_ITALIC; cf2.crTextColor = inputcharcolor; cf2.bCharSet = lf.lfCharSet; - strncpy(cf2.szFaceName, lf.lfFaceName, LF_FACESIZE - 1); + wcsncpy_s(cf2.szFaceName, lf.lfFaceName, _TRUNCATE); cf2.dwEffects = ((lf.lfWeight >= FW_BOLD) ? CFE_BOLD : 0) | (lf.lfItalic ? CFE_ITALIC : 0) | (lf.lfUnderline ? CFE_UNDERLINE : 0) | (lf.lfStrikeOut ? CFE_STRIKEOUT : 0); cf2.wWeight = (WORD)lf.lfWeight; cf2.bPitchAndFamily = lf.lfPitchAndFamily; diff --git a/plugins/TabSRMM/src/infopanel.cpp b/plugins/TabSRMM/src/infopanel.cpp index dfa76b980d..7368c7be05 100644 --- a/plugins/TabSRMM/src/infopanel.cpp +++ b/plugins/TabSRMM/src/infopanel.cpp @@ -657,7 +657,7 @@ void CInfoPanel::Chat_RenderIPSecondLine(const HDC hdc, RECT& rcItem) COLORREF clr = m_ipConfig.clrs[IPFONTID_UIN];
SIZE szTitle;
- wchar_t szPrefix[100];
+ wchar_t szPrefix[100];
mir_snwprintf(szPrefix, TranslateT("Topic is: %s"), L"");
::GetTextExtentPoint32(hdc, szPrefix, (int)mir_wstrlen(szPrefix), &szTitle);
mapRealRect(rcItem, m_rcUIN, szTitle);
diff --git a/plugins/TabSRMM/src/msgdlgother.cpp b/plugins/TabSRMM/src/msgdlgother.cpp index 132a7babf3..ee45e05116 100644 --- a/plugins/TabSRMM/src/msgdlgother.cpp +++ b/plugins/TabSRMM/src/msgdlgother.cpp @@ -235,7 +235,7 @@ BOOL CMsgDialog::DoRtfToTags(CMStringW &pszText) const return FALSE; // used to filter out attributes which are already set for the default message input area font - LOGFONTA lf = m_pContainer->m_theme.logFonts[MSGFONTID_MESSAGEAREA]; + auto &lf = m_pContainer->m_theme.logFonts[MSGFONTID_MESSAGEAREA]; // create an index of colors in the module and map them to // corresponding colors in the RTF color table @@ -825,7 +825,7 @@ void CMsgDialog::LoadOwnAvatar() void CMsgDialog::LoadSettings() { m_clrInputBG = m_pContainer->m_theme.inputbg; - LoadLogfont(FONTSECTION_IM, MSGFONTID_MESSAGEAREA, nullptr, &m_clrInputFG, FONTMODULE); + LoadMsgDlgFont(FONTSECTION_IM, MSGFONTID_MESSAGEAREA, nullptr, &m_clrInputFG); } ///////////////////////////////////////////////////////////////////////////////////////// diff --git a/plugins/TabSRMM/src/msglog.cpp b/plugins/TabSRMM/src/msglog.cpp index b053d0b47e..5e05db523c 100644 --- a/plugins/TabSRMM/src/msglog.cpp +++ b/plugins/TabSRMM/src/msglog.cpp @@ -67,7 +67,7 @@ static wchar_t szToday[22], szYesterday[22]; char rtfFontsGlobal[MSGDLGFONTCOUNT + 2][RTFCACHELINESIZE];
char *rtfFonts;
-LOGFONTA logfonts[MSGDLGFONTCOUNT + 2];
+LOGFONTW logfonts[MSGDLGFONTCOUNT + 2];
COLORREF fontcolors[MSGDLGFONTCOUNT + 2];
#define LOGICON_MSG 0
@@ -110,13 +110,13 @@ void TSAPI CacheLogFonts() memset(logfonts, 0, (sizeof(LOGFONTA) * (MSGDLGFONTCOUNT + 2)));
for (int i = 0; i < MSGDLGFONTCOUNT; i++) {
- LoadLogfont(FONTSECTION_IM, i, &logfonts[i], &fontcolors[i], FONTMODULE);
+ LoadMsgDlgFont(FONTSECTION_IM, i, &logfonts[i], &fontcolors[i]);
mir_snprintf(rtfFontsGlobal[i], "\\f%u\\cf%u\\b%d\\i%d\\ul%d\\fs%u", i, i, logfonts[i].lfWeight >= FW_BOLD ? 1 : 0, logfonts[i].lfItalic, logfonts[i].lfUnderline, 2 * abs(logfonts[i].lfHeight) * 74 / logPixelSY);
}
mir_snprintf(rtfFontsGlobal[MSGDLGFONTCOUNT], "\\f%u\\cf%u\\b%d\\i%d\\fs%u", MSGDLGFONTCOUNT, MSGDLGFONTCOUNT, 0, 0, 0);
- wcsncpy(szToday, TranslateT("Today"), 20);
- wcsncpy(szYesterday, TranslateT("Yesterday"), 20);
+ wcsncpy_s(szToday, TranslateT("Today"), _TRUNCATE);
+ wcsncpy_s(szYesterday, TranslateT("Yesterday"), _TRUNCATE);
szToday[19] = szYesterday[19] = 0;
// cache/create the info panel fonts
@@ -125,10 +125,10 @@ void TSAPI CacheLogFonts() DeleteObject(CInfoPanel::m_ipConfig.hFonts[i]);
COLORREF clr;
- LOGFONTA lf;
- LoadLogfont(FONTSECTION_IP, i, &lf, &clr, FONTMODULE);
+ LOGFONTW lf;
+ LoadMsgDlgFont(FONTSECTION_IP, i, &lf, &clr);
lf.lfUnderline = 0;
- CInfoPanel::m_ipConfig.hFonts[i] = CreateFontIndirectA(&lf);
+ CInfoPanel::m_ipConfig.hFonts[i] = CreateFontIndirectW(&lf);
CInfoPanel::m_ipConfig.clrs[i] = clr;
}
@@ -309,14 +309,14 @@ static int AppendUnicodeToBuffer(CMStringA &str, const wchar_t *line, int mode) static void Build_RTF_Header(CMStringA &str, CMsgDialog *dat)
{
int i;
- LOGFONTA *logFonts = dat->m_pContainer->m_theme.logFonts;
+ LOGFONTW *logFonts = dat->m_pContainer->m_theme.logFonts;
COLORREF *fontColors = dat->m_pContainer->m_theme.fontColors;
TLogTheme *theme = &dat->m_pContainer->m_theme;
str.Append("{\\rtf1\\ansi\\deff0{\\fonttbl");
for (i = 0; i < MSGDLGFONTCOUNT; i++)
- str.AppendFormat("{\\f%u\\fnil\\fcharset%u %s;}", i, logFonts[i].lfCharSet, logFonts[i].lfFaceName);
+ str.AppendFormat("{\\f%u\\fnil\\fcharset%u %S;}", i, logFonts[i].lfCharSet, logFonts[i].lfFaceName);
str.AppendFormat("{\\f%u\\fnil\\fcharset%u %s;}", MSGDLGFONTCOUNT, logFonts[i].lfCharSet, "Arial");
str.Append("}{\\colortbl ");
diff --git a/plugins/TabSRMM/src/msgoptions.cpp b/plugins/TabSRMM/src/msgoptions.cpp index 2c7e801de2..2af0b38b25 100644 --- a/plugins/TabSRMM/src/msgoptions.cpp +++ b/plugins/TabSRMM/src/msgoptions.cpp @@ -30,28 +30,6 @@ #define DM_GETSTATUSMASK (WM_USER + 10)
-void LoadLogfont(int section, int i, LOGFONTA * lf, COLORREF * colour, char *szModule)
-{
- LOGFONT lfResult;
- LoadMsgDlgFont(section, i, &lfResult, colour, szModule);
- if (lf) {
- lf->lfHeight = lfResult.lfHeight;
- lf->lfWidth = lfResult.lfWidth;
- lf->lfEscapement = lfResult.lfEscapement;
- lf->lfOrientation = lfResult.lfOrientation;
- lf->lfWeight = lfResult.lfWeight;
- lf->lfItalic = lfResult.lfItalic;
- lf->lfUnderline = lfResult.lfUnderline;
- lf->lfStrikeOut = lfResult.lfStrikeOut;
- lf->lfCharSet = lfResult.lfCharSet;
- lf->lfOutPrecision = lfResult.lfOutPrecision;
- lf->lfClipPrecision = lfResult.lfClipPrecision;
- lf->lfQuality = lfResult.lfQuality;
- lf->lfPitchAndFamily = lfResult.lfPitchAndFamily;
- mir_snprintf(lf->lfFaceName, "%S", lfResult.lfFaceName);
- }
-}
-
/////////////////////////////////////////////////////////////////////////////////////////
void TreeViewInit(CCtrlTreeView &ctrl, TOptionListGroup *lvGroups, TOptionListItem *lvItems, const char *DBPath, DWORD dwFlags, bool bFromMem)
diff --git a/plugins/TabSRMM/src/msgs.cpp b/plugins/TabSRMM/src/msgs.cpp index a01fe9a93a..492e9072e1 100644 --- a/plugins/TabSRMM/src/msgs.cpp +++ b/plugins/TabSRMM/src/msgs.cpp @@ -555,7 +555,7 @@ static int TSAPI SetupIconLibConfig() sid.iDefaultIndex = -IDI_CLOCK;
g_plugin.addIcon(&sid);
- wcsncpy(szFilename, L"plugins\\tabsrmm.dll", MAX_PATH);
+ wcsncpy_s(szFilename, L"plugins\\tabsrmm.dll", _TRUNCATE);
sid.pszName = "tabSRMM_overlay_disabled";
sid.description.a = LPGEN("Feature disabled (used as overlay)");
diff --git a/plugins/TabSRMM/src/msgs.h b/plugins/TabSRMM/src/msgs.h index 8be03332b3..83979a2368 100644 --- a/plugins/TabSRMM/src/msgs.h +++ b/plugins/TabSRMM/src/msgs.h @@ -124,7 +124,7 @@ struct TLogTheme COLORREF custom_colors[5];
DWORD dwFlags;
DWORD left_indent, right_indent;
- LOGFONTA *logFonts;
+ LOGFONTW *logFonts;
COLORREF *fontColors;
char *rtfFonts;
bool isPrivate;
diff --git a/plugins/TabSRMM/src/selectcontainer.cpp b/plugins/TabSRMM/src/selectcontainer.cpp index 2a57e922aa..6174bd48a4 100644 --- a/plugins/TabSRMM/src/selectcontainer.cpp +++ b/plugins/TabSRMM/src/selectcontainer.cpp @@ -128,7 +128,7 @@ INT_PTR CALLBACK SelectContainerDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, L SendDlgItemMessage(hwndDlg, IDC_CNTLIST, LB_RESETCONTENT, 0, 0);
for (TContainerData *p = pFirstContainer; p; p = p->pNext) {
if (!wcsncmp(p->m_wszName, szName, CONTAINER_NAMELEN) && mir_wstrlen(p->m_wszName) == mir_wstrlen(szName)) {
- wcsncpy(p->m_wszName, szNewName, CONTAINER_NAMELEN);
+ wcsncpy_s(p->m_wszName, szNewName, _TRUNCATE);
p->Configure();
}
}
diff --git a/plugins/TabSRMM/src/sendlater.cpp b/plugins/TabSRMM/src/sendlater.cpp index 9a080cd83c..517c3db5ca 100644 --- a/plugins/TabSRMM/src/sendlater.cpp +++ b/plugins/TabSRMM/src/sendlater.cpp @@ -304,7 +304,7 @@ int CSendLater::addJob(const char *szSetting, void *lParam) CSendLaterJob *job = new CSendLaterJob;
- strncpy(job->szId, szSetting, 20);
+ strncpy_s(job->szId, szSetting, _TRUNCATE);
job->szId[19] = 0;
job->hContact = hContact;
job->created = atol(&szSetting[1]);
diff --git a/plugins/TabSRMM/src/stdafx.h b/plugins/TabSRMM/src/stdafx.h index e6077bc3a4..4672ad2f17 100644 --- a/plugins/TabSRMM/src/stdafx.h +++ b/plugins/TabSRMM/src/stdafx.h @@ -218,7 +218,7 @@ extern TContainerData *pFirstContainer, *pLastActiveContainer; extern ButtonSet g_ButtonSet;
extern RECT rcLastStatusBarClick;
extern TTemplateSet RTL_Active, LTR_Active, LTR_Default, RTL_Default;
-extern LOGFONTA logfonts[MSGDLGFONTCOUNT + 2];
+extern LOGFONTW logfonts[MSGDLGFONTCOUNT + 2];
extern COLORREF fontcolors[MSGDLGFONTCOUNT + 2];
extern HINSTANCE hinstance;
extern BOOL g_bIMGtagButton;
diff --git a/plugins/TabSRMM/src/themeio.cpp b/plugins/TabSRMM/src/themeio.cpp index 5b3b551d1d..a0299e27fd 100644 --- a/plugins/TabSRMM/src/themeio.cpp +++ b/plugins/TabSRMM/src/themeio.cpp @@ -97,7 +97,7 @@ static _extSettings_v5[] = * *lf = pointer to a LOGFONT structure which will receive the font definition
* *colour = pointer to a COLORREF which will receive the color of the font definition
*/
-static void TSAPI LoadLogfontFromINI(int i, char *szKey, LOGFONTA *lf, COLORREF *colour, const char *szIniFilename)
+static void TSAPI LoadLogfontFromINI(int i, char *szKey, LOGFONTW *lf, COLORREF *colour, const char *szIniFilename)
{
int style;
char bSize;
@@ -136,11 +136,10 @@ static void TSAPI LoadLogfontFromINI(int i, char *szKey, LOGFONTA *lf, COLORREF lf->lfQuality = DEFAULT_QUALITY;
lf->lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE;
if (i == MSGFONTID_SYMBOLS_IN || i == MSGFONTID_SYMBOLS_OUT) {
- strncpy_s(lf->lfFaceName, "Webdings", _TRUNCATE);
+ wcsncpy_s(lf->lfFaceName, L"Webdings", _TRUNCATE);
lf->lfCharSet = SYMBOL_CHARSET;
}
- else
- GetPrivateProfileStringA(szKey, "Face", "Tahoma", lf->lfFaceName, LF_FACESIZE - 1, szIniFilename);
+ else GetPrivateProfileStringW(_A2T(szKey), L"Face", L"Tahoma", lf->lfFaceName, _countof(lf->lfFaceName), _A2T(szIniFilename));
/*
* filter out font attributes from the message input area font
diff --git a/plugins/TabSRMM/src/themes.cpp b/plugins/TabSRMM/src/themes.cpp index d99626f254..eb0faceaa8 100644 --- a/plugins/TabSRMM/src/themes.cpp +++ b/plugins/TabSRMM/src/themes.cpp @@ -815,8 +815,6 @@ wchar_t* CImageItem::Read(const wchar_t *szFilename) GetPrivateProfileString(m_szName, L"Image", L"None", buffer, 500, szFilename);
if (mir_wstrcmp(buffer, L"None") || m_dwFlags & IMAGE_GLYPH) {
szFinalName = new wchar_t[MAX_PATH];
- //strncpy(m_szName, &m_szName[1], sizeof(m_szName));
- //m_szName[sizeof(m_szName) - 1] = 0;
_wsplitpath(szFilename, szDrive, szPath, nullptr, nullptr);
mir_snwprintf(szFinalName, MAX_PATH, L"%s\\%s%s", szDrive, szPath, buffer);
if (!PathFileExists(szFinalName)) {
|