From a411a7391bb879db8da398f067245a13c7fa7aee Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 25 Jul 2018 23:10:36 +0300 Subject: major code cleaning of all font-related structures --- include/delphi/m_fontservice.inc | 18 ---- include/m_fontservice.h | 66 +++++--------- plugins/Alarms/src/alarm_win.cpp | 7 +- plugins/Alarms/src/frame.cpp | 4 +- plugins/BASS_interface/src/Main.cpp | 4 +- plugins/BasicHistory/src/Options.cpp | 8 +- plugins/Clist_modern/src/modern_clcopts.cpp | 10 +-- plugins/Clist_nicer/src/clui.cpp | 39 ++++---- plugins/Console/src/Console.cpp | 8 +- plugins/FavContacts/src/services.cpp | 12 +-- plugins/HistoryPlusPlus/hpp_options.pas | 2 - plugins/MyDetails/src/frame.cpp | 19 ++-- plugins/NotesAndReminders/src/options.cpp | 10 +-- plugins/Ping/src/pingthread.cpp | 4 +- plugins/Popup/src/font.cpp | 16 ++-- plugins/Popup/src/notifications.cpp | 8 +- plugins/Popup/src/services.cpp | 10 +-- plugins/QuickSearch/i_ok.inc | 1 - plugins/QuickSearch/sr_frame.pas | 1 - plugins/Scriver/src/msgoptions.cpp | 6 +- plugins/SmileyAdd/src/main.cpp | 2 +- plugins/TabSRMM/src/chat_options.cpp | 11 +-- plugins/TipperYM/src/tipper.cpp | 17 +--- plugins/TooltipNotify/src/TooltipNotify.cpp | 6 +- plugins/TrafficCounter/src/TrafficCounter.cpp | 4 +- plugins/Weather/src/weather_mwin.cpp | 10 +-- plugins/YAPP/src/yapp.cpp | 17 ++-- plugins/mRadio/rframeapi.pas | 1 - protocols/JabberG/src/jabber.cpp | 11 +-- protocols/JabberG/src/jabber_menu.cpp | 2 +- src/core/stdclist/src/clcfonts.cpp | 38 ++++---- src/core/stdmsg/src/chat_manager.cpp | 2 +- src/core/stdmsg/src/msgoptions.cpp | 6 +- src/mir_app/src/FontOptions.cpp | 122 +++++++++++++------------- src/mir_app/src/FontService.cpp | 41 ++------- src/mir_app/src/chat_opts.cpp | 4 +- utils/mir_fonts.cpp | 8 +- 37 files changed, 220 insertions(+), 335 deletions(-) diff --git a/include/delphi/m_fontservice.inc b/include/delphi/m_fontservice.inc index 4c6f5c09f4..1a906e596e 100644 --- a/include/delphi/m_fontservice.inc +++ b/include/delphi/m_fontservice.inc @@ -67,20 +67,12 @@ type // and getting one out again PFontID_tag = ^TFontID_tag; TFontID_tag = record - cbSize : int; - // [TRANSLATED-BY-CORE] group the font belongs to - this is the 'Font Group' list in the options page group : array[0..63] of AnsiChar; - // [TRANSLATED-BY-CORE] the name of the font setting e.g. 'contacts' in the 'contact list' group name : array[0..63] of AnsiChar; - // the 'module' in the database where the font data is stored dbSettingsGroup: array[0..31] of AnsiChar; - // prepended to the settings used to store this font's data in the db prefix : array[0..31] of AnsiChar; - // bitwise OR of the FIDF_* flags above flags : dword; deffontsettings: TFontSettings; // defaults, if flags & FIDF_DEFAULTVALID - // controls the order in the font group in which the fonts are listed in the - // UI (if order fields are equal, they will be ordered alphabetically by name) order : int; backgroundGroup:array [0..63] of AnsiChar; backgroundName: array [0..63] of AnsiChar; @@ -90,20 +82,12 @@ type PFontIDW_tag = ^TFontIDW_tag; TFontIDW_tag = record - cbSize : int; - // [TRANSLATED-BY-CORE] group the font belongs to - this is the 'Font Group' list in the options page group : array[0..63] of WideChar; - // [TRANSLATED-BY-CORE] the name of the font setting e.g. 'contacts' in the 'contact list' group name : array[0..63] of WideChar; - // the 'module' in the database where the font data is stored dbSettingsGroup: array[0..31] of AnsiChar; - // prepended to the settings used to store this font's data in the db prefix : array[0..31] of AnsiChar; - // bitwise OR of the FIDF_* flags above flags : dword; deffontsettings: TFontSettingsW; // defaults, if flags & FIDF_DEFAULTVALID - // controls the order in the font group in which the fonts are listed in the - // UI (if order fields are equal, they will be ordered alphabetically by name) order : int; backgroundGroup:array [0..63] of WideChar; backgroundName: array [0..63] of WideChar; @@ -121,7 +105,6 @@ function Font_Get(pGroup,pName:pAnsiChar; pFont:pLogFontA) : longint; stdcall; e type PColourID_tag = ^TColourID_tag; TColourID_tag = record - cbSize : int; group : array[0..63] of AnsiChar; name : array[0..63] of AnsiChar; dbSettingsGroup : array[0..31] of AnsiChar; @@ -135,7 +118,6 @@ type PColourIDW_tag = ^TColourIDW_tag; TColourIDW_tag = record - cbSize : int; group : array[0..63] of WideChar; name : array[0..63] of WideChar; dbSettingsGroup : array[0..31] of AnsiChar; diff --git a/include/m_fontservice.h b/include/m_fontservice.h index ffb8cbfea2..3bda3038f1 100644 --- a/include/m_fontservice.h +++ b/include/m_fontservice.h @@ -9,6 +9,24 @@ #include #endif +struct MBaseFontObject +{ + char group[64]; // [TRANSLATED-BY-CORE] + char name[64]; // [TRANSLATED-BY-CORE] + char dbSettingsGroup[32]; + char setting[32]; + DWORD flags; +}; + +struct MBaseFontObjectW +{ + wchar_t group[64]; + wchar_t name[64]; + char dbSettingsGroup[32]; + char setting[32]; + DWORD flags; +}; + ////////////////////////////////////////////////////////////////////////// // // FONTS @@ -66,14 +84,8 @@ struct FontSettingsW // are translated by the core, which may lead to double translation. // Use LPGEN instead which are just dummy wrappers/markers for "lpgen.pl". -struct FontID +struct FontID : public MBaseFontObject { - int cbSize; - char group[64]; // [TRANSLATED-BY-CORE] group the font belongs to - this is the 'Font Group' list in the options page - char name[64]; // [TRANSLATED-BY-CORE] this is the name of the font setting - e.g. 'contacts' in the 'contact list' group - char dbSettingsGroup[32]; // the 'module' in the database where the font data is stored - char prefix[32]; // this is prepended to the settings used to store this font's data in the db - DWORD flags; // bitwise OR of the FIDF_* flags above FontSettings deffontsettings; // defaults, valid if flags & FIDF_DEFAULTVALID int order; // controls the order in the font group in which the fonts are listed in the UI (if order fields are equal, // they will be ordered alphabetically by name) @@ -81,14 +93,8 @@ struct FontID char backgroundName[64]; }; -struct FontIDW +struct FontIDW : public MBaseFontObjectW { - int cbSize; - wchar_t group[64]; // [TRANSLATED-BY-CORE] group the font belongs to - this is the 'Font Group' list in the options page - wchar_t name[64]; // [TRANSLATED-BY-CORE] this is the name of the font setting - e.g. 'contacts' in the 'contact list' group - char dbSettingsGroup[32]; // the 'module' in the database where the font data is stored - char prefix[32]; // this is prepended to the settings used to store this font's data in the db - DWORD flags; // bitwise OR of the FIDF_* flags above FontSettingsW deffontsettings; // defaults, valid if flags & FIDF_DEFAULTVALID int order; // controls the order in the font group in which the fonts are listed in the UI (if order fields are equal, // they will be ordered alphabetically by name) @@ -132,27 +138,15 @@ __forceinline COLORREF Font_GetW(FontIDW &p, LOGFONTW *pFont) // are translated by the core, which may lead to double translation. // Use LPGEN instead which are just dummy wrappers/markers for "lpgen.pl". -struct ColourID +struct ColourID : public MBaseFontObject { - int cbSize; - char group[64]; // [TRANSLATED-BY-CORE] - char name[64]; // [TRANSLATED-BY-CORE] - char dbSettingsGroup[32]; - char setting[32]; - DWORD flags; // not used COLORREF defcolour; // default value int order; }; // a font identifier structure - used for registering a font, and getting one out again -struct ColourIDW +struct ColourIDW : public MBaseFontObjectW { - int cbSize; - wchar_t group[64]; // [TRANSLATED-BY-CORE] - wchar_t name[64]; // [TRANSLATED-BY-CORE] - char dbSettingsGroup[32]; - char setting[32]; - DWORD flags; // not used COLORREF defcolour; // default value int order; }; @@ -191,27 +185,15 @@ struct FONTEFFECT DWORD secondaryColour; // ARGB }; -struct EffectID +struct EffectID : public MBaseFontObject { - int cbSize; - char group[64]; - char name[64]; - char dbSettingsGroup[32]; - char setting[32]; - DWORD flags; FONTEFFECT defeffect; int order; FONTEFFECT value; }; -struct EffectIDW +struct EffectIDW : public MBaseFontObjectW { - int cbSize; - wchar_t group[64]; - wchar_t name[64]; - char dbSettingsGroup[32]; - char setting[32]; - DWORD flags; FONTEFFECT defeffect; int order; FONTEFFECT value; diff --git a/plugins/Alarms/src/alarm_win.cpp b/plugins/Alarms/src/alarm_win.cpp index 83cd180c2b..fc4813f962 100644 --- a/plugins/Alarms/src/alarm_win.cpp +++ b/plugins/Alarms/src/alarm_win.cpp @@ -347,29 +347,26 @@ int ReloadFonts(WPARAM, LPARAM) int AlarmWinModulesLoaded(WPARAM, LPARAM) { - title_font_id.cbSize = sizeof(FontIDW); wcsncpy_s(title_font_id.group, LPGENW("Alarms"), _TRUNCATE); wcsncpy_s(title_font_id.name, LPGENW("Title"), _TRUNCATE); strncpy_s(title_font_id.dbSettingsGroup, MODULENAME, _TRUNCATE); - strncpy_s(title_font_id.prefix, "FontTitle", _TRUNCATE); + strncpy_s(title_font_id.setting, "FontTitle", _TRUNCATE); wcsncpy_s(title_font_id.backgroundGroup, LPGENW("Alarms"), _TRUNCATE); wcsncpy_s(title_font_id.backgroundName, LPGENW("Background"), _TRUNCATE); title_font_id.flags = 0; title_font_id.order = 0; g_plugin.addFont(&title_font_id); - window_font_id.cbSize = sizeof(FontIDW); wcsncpy_s(window_font_id.group, LPGENW("Alarms"), _TRUNCATE); wcsncpy_s(window_font_id.name, LPGENW("Window"), _TRUNCATE); strncpy_s(window_font_id.dbSettingsGroup, MODULENAME, _TRUNCATE); - strncpy_s(window_font_id.prefix, "FontWindow", _TRUNCATE); + strncpy_s(window_font_id.setting, "FontWindow", _TRUNCATE); wcsncpy_s(window_font_id.backgroundGroup, LPGENW("Alarms"), _TRUNCATE); wcsncpy_s(window_font_id.backgroundName, LPGENW("Background"), _TRUNCATE); window_font_id.flags = 0; window_font_id.order = 1; g_plugin.addFont(&window_font_id); - bk_colour_id.cbSize = sizeof(ColourIDW); strncpy_s(bk_colour_id.dbSettingsGroup, MODULENAME, _TRUNCATE); wcsncpy_s(bk_colour_id.group, LPGENW("Alarms"), _TRUNCATE); wcsncpy_s(bk_colour_id.name, LPGENW("Background"), _TRUNCATE); diff --git a/plugins/Alarms/src/frame.cpp b/plugins/Alarms/src/frame.cpp index 744892450d..921ca4f290 100755 --- a/plugins/Alarms/src/frame.cpp +++ b/plugins/Alarms/src/frame.cpp @@ -555,15 +555,13 @@ int CreateFrame() SendMessage(hwnd_plugin, WMU_INITIALIZE, 0, 0); - font_id.cbSize = sizeof(font_id); strncpy_s(font_id.group, LPGEN("Frames"), _TRUNCATE); strncpy_s(font_id.name, LPGEN("Alarm reminders"), _TRUNCATE); strncpy_s(font_id.dbSettingsGroup, MODULENAME, _TRUNCATE); - strncpy_s(font_id.prefix, "Font", _TRUNCATE); + strncpy_s(font_id.setting, "Font", _TRUNCATE); font_id.order = 0; g_plugin.addFont(&font_id); - framebk_colour_id.cbSize = sizeof(ColourID); strncpy_s(framebk_colour_id.dbSettingsGroup, MODULENAME, _TRUNCATE); strncpy_s(framebk_colour_id.group, LPGEN("Frames"), _TRUNCATE); strncpy_s(framebk_colour_id.name, LPGEN("Alarm reminders"), _TRUNCATE); diff --git a/plugins/BASS_interface/src/Main.cpp b/plugins/BASS_interface/src/Main.cpp index 2d2eb55ff0..a55f34fd11 100644 --- a/plugins/BASS_interface/src/Main.cpp +++ b/plugins/BASS_interface/src/Main.cpp @@ -454,9 +454,7 @@ void CreateFrame() Frame.hIcon = Skin_LoadIcon(SKINICON_OTHER_FRAME); frame_id = g_plugin.addFrame(&Frame); - ColourIDW colourid = { 0 }; - colourid.cbSize = sizeof(ColourIDW); - + ColourIDW colourid = {}; strcpy_s(colourid.dbSettingsGroup, MODULENAME); strcpy_s(colourid.setting, "ColorFrame"); wcscpy_s(colourid.name, LPGENW("Frame background")); diff --git a/plugins/BasicHistory/src/Options.cpp b/plugins/BasicHistory/src/Options.cpp index da971082be..293708c2b6 100644 --- a/plugins/BasicHistory/src/Options.cpp +++ b/plugins/BasicHistory/src/Options.cpp @@ -231,11 +231,9 @@ const int g_hotkeysSize = _countof(g_HotkeyOptionsList); void Options::Load(void) { - FontIDW fid = { 0 }; - ColourIDW cid = { 0 }; + FontIDW fid = {}; + ColourIDW cid = {}; HOTKEYDESC hid = {}; - fid.cbSize = sizeof(FontIDW); - cid.cbSize = sizeof(ColourIDW); strncpy_s(fid.dbSettingsGroup, "BasicHistory_Fonts", _TRUNCATE); wcsncpy_s(fid.backgroundGroup, L"History", _TRUNCATE); wcsncpy_s(fid.group, LPGENW("History"), _TRUNCATE); @@ -246,7 +244,7 @@ void Options::Load(void) fid.deffontsettings.colour = g_FontOptionsList[i].defColour; fid.deffontsettings.style = g_FontOptionsList[i].defStyle; fid.deffontsettings.charset = DEFAULT_CHARSET; - mir_snprintf(fid.prefix, _countof(fid.prefix), "Font%d", i); + mir_snprintf(fid.setting, _countof(fid.setting), "Font%d", i); wcsncpy_s(fid.name, g_FontOptionsList[i].szDescr, _TRUNCATE); wcsncpy_s(fid.backgroundName, g_FontOptionsList[i].szBackgroundName, _TRUNCATE); fid.flags = FIDF_DEFAULTVALID | FIDF_CLASSGENERAL | g_FontOptionsList[i].flags; diff --git a/plugins/Clist_modern/src/modern_clcopts.cpp b/plugins/Clist_modern/src/modern_clcopts.cpp index e7c74bedeb..586fbbb5fe 100644 --- a/plugins/Clist_modern/src/modern_clcopts.cpp +++ b/plugins/Clist_modern/src/modern_clcopts.cpp @@ -131,11 +131,8 @@ void RegisterCLUIFonts(void) EffectIDW effectid = {}; char idstr[10]; - fontid.cbSize = sizeof(fontid); - mir_strncpy(fontid.dbSettingsGroup, "CLC", _countof(fontid.dbSettingsGroup)); - - effectid.cbSize = sizeof(effectid); - mir_strncpy(effectid.dbSettingsGroup, "CLC", _countof(effectid.dbSettingsGroup)); + strncpy_s(fontid.dbSettingsGroup, "CLC", _TRUNCATE); + strncpy_s(effectid.dbSettingsGroup, "CLC", _TRUNCATE); int index = 1; for (auto &p : fontOptionsList) { @@ -145,7 +142,7 @@ void RegisterCLUIFonts(void) wcsncpy_s(fontid.group, p.szGroup, _TRUNCATE); wcsncpy_s(fontid.name, p.szDescr, _TRUNCATE); mir_snprintf(idstr, "Font%d", p.fontID); - strncpy_s(fontid.prefix, idstr, _TRUNCATE); + strncpy_s(fontid.setting, idstr, _TRUNCATE); fontid.order = index; fontid.deffontsettings.charset = p.defCharset; @@ -171,7 +168,6 @@ void RegisterCLUIFonts(void) } ColourIDW colourid = {}; - colourid.cbSize = sizeof(colourid); index = 1; for (auto &p : colourOptionsList) { diff --git a/plugins/Clist_nicer/src/clui.cpp b/plugins/Clist_nicer/src/clui.cpp index f2ee3b3ae7..affee6a037 100644 --- a/plugins/Clist_nicer/src/clui.cpp +++ b/plugins/Clist_nicer/src/clui.cpp @@ -1871,9 +1871,9 @@ static clistFontDescr[] = void FS_RegisterFonts() { - FontIDW fid = { sizeof(fid) }; - wcsncpy(fid.group, LPGENW("Contact list"), _countof(fid.group)); - strncpy(fid.dbSettingsGroup, "CLC", 5); + FontIDW fid = {}; + wcsncpy_s(fid.group, LPGENW("Contact list"), _TRUNCATE); + strncpy_s(fid.dbSettingsGroup, "CLC", _TRUNCATE); fid.flags = FIDF_DEFAULTVALID | FIDF_ALLOWEFFECTS | FIDF_APPENDNAME | FIDF_SAVEPOINTSIZE; HDC hdc = GetDC(nullptr); @@ -1890,49 +1890,48 @@ void FS_RegisterFonts() fid.flags &= ~FIDF_CLASSMASK; fid.flags |= clistFontDescr[i].iMask; - wcsncpy(fid.name, clistFontDescr[i].tszName, _countof(fid.name)); + wcsncpy_s(fid.name, clistFontDescr[i].tszName, _TRUNCATE); char idstr[10]; mir_snprintf(idstr, "Font%d", i); - strncpy(fid.prefix, idstr, _countof(fid.prefix)); + strncpy_s(fid.setting, idstr, _TRUNCATE); fid.order = i; g_plugin.addFont(&fid); } ReleaseDC(nullptr, hdc); // and colours - ColourIDW colourid = { 0 }; - colourid.cbSize = sizeof(colourid); + ColourIDW colourid = {}; colourid.order = 0; - strncpy(colourid.dbSettingsGroup, "CLC", sizeof(colourid.dbSettingsGroup)); + strncpy_s(colourid.dbSettingsGroup, "CLC", _TRUNCATE); - strncpy(colourid.setting, "BkColour", sizeof(colourid.setting)); - wcsncpy(colourid.name, LPGENW("Background"), _countof(colourid.name)); - wcsncpy(colourid.group, LPGENW("Contact list"), _countof(colourid.group)); + strncpy_s(colourid.setting, "BkColour", _TRUNCATE); + wcsncpy_s(colourid.name, LPGENW("Background"), _TRUNCATE); + wcsncpy_s(colourid.group, LPGENW("Contact list"), _TRUNCATE); colourid.defcolour = CLCDEFAULT_BKCOLOUR; g_plugin.addColor(&colourid); - strncpy(colourid.setting, "SelTextColour", sizeof(colourid.setting)); - wcsncpy(colourid.name, LPGENW("Selected text"), _countof(colourid.name)); + strncpy_s(colourid.setting, "SelTextColour", _TRUNCATE); + wcsncpy_s(colourid.name, LPGENW("Selected text"), _TRUNCATE); colourid.order = 1; colourid.defcolour = CLCDEFAULT_SELTEXTCOLOUR; g_plugin.addColor(&colourid); - strncpy(colourid.setting, "HotTextColour", sizeof(colourid.setting)); - wcsncpy(colourid.name, LPGENW("Hottrack text"), _countof(colourid.name)); + strncpy_s(colourid.setting, "HotTextColour", _TRUNCATE); + wcsncpy_s(colourid.name, LPGENW("Hottrack text"), _TRUNCATE); colourid.order = 1; colourid.defcolour = CLCDEFAULT_HOTTEXTCOLOUR; g_plugin.addColor(&colourid); - strncpy(colourid.setting, "QuickSearchColour", sizeof(colourid.setting)); - wcsncpy(colourid.name, LPGENW("Quicksearch text"), _countof(colourid.name)); + strncpy_s(colourid.setting, "QuickSearchColour", _TRUNCATE); + wcsncpy_s(colourid.name, LPGENW("Quicksearch text"), _TRUNCATE); colourid.order = 1; colourid.defcolour = CLCDEFAULT_QUICKSEARCHCOLOUR; g_plugin.addColor(&colourid); - strncpy(colourid.dbSettingsGroup, "CLUI", sizeof(colourid.dbSettingsGroup)); - strncpy(colourid.setting, "clr_frameborder", sizeof(colourid.setting)); - wcsncpy(colourid.name, LPGENW("Embedded frames border"), _countof(colourid.name)); + strncpy_s(colourid.dbSettingsGroup, "CLUI", _TRUNCATE); + strncpy_s(colourid.setting, "clr_frameborder", _TRUNCATE); + wcsncpy_s(colourid.name, LPGENW("Embedded frames border"), _TRUNCATE); colourid.order = 1; colourid.defcolour = RGB(40, 40, 40); g_plugin.addColor(&colourid); diff --git a/plugins/Console/src/Console.cpp b/plugins/Console/src/Console.cpp index c9b09e9a14..5b2a737243 100644 --- a/plugins/Console/src/Console.cpp +++ b/plugins/Console/src/Console.cpp @@ -1100,12 +1100,11 @@ static int OnSystemModulesLoaded(WPARAM, LPARAM) { CreateServiceFunction(MS_CONSOLE_SHOW_HIDE, ShowHideConsole); - FontIDW fid = { 0 }; - fid.cbSize = sizeof(fid); + FontIDW fid = {}; mir_wstrncpy(fid.group, LPGENW("Console"), _countof(fid.group)); mir_wstrncpy(fid.name, LPGENW("Text"), _countof(fid.name)); mir_strncpy(fid.dbSettingsGroup, "Console", _countof(fid.dbSettingsGroup)); - mir_strncpy(fid.prefix, "ConsoleFont", _countof(fid.prefix)); + mir_strncpy(fid.setting, "ConsoleFont", _countof(fid.setting)); mir_wstrncpy(fid.backgroundGroup, LPGENW("Console"), _countof(fid.backgroundGroup)); mir_wstrncpy(fid.backgroundName, LPGENW("Background"), _countof(fid.backgroundName)); fid.flags = FIDF_DEFAULTVALID; @@ -1118,8 +1117,7 @@ static int OnSystemModulesLoaded(WPARAM, LPARAM) HookEvent(ME_FONT_RELOAD, OnFontChange); - ColourIDW cid = { 0 }; - cid.cbSize = sizeof(cid); + ColourIDW cid = {}; mir_wstrncpy(cid.group, LPGENW("Console"), _countof(cid.group)); mir_wstrncpy(cid.name, LPGENW("Background"), _countof(cid.name)); mir_strncpy(cid.dbSettingsGroup, "Console", _countof(cid.dbSettingsGroup)); diff --git a/plugins/FavContacts/src/services.cpp b/plugins/FavContacts/src/services.cpp index 7d91eb4ad8..8137add545 100644 --- a/plugins/FavContacts/src/services.cpp +++ b/plugins/FavContacts/src/services.cpp @@ -158,7 +158,7 @@ int ProcessModulesLoaded(WPARAM, LPARAM) ///////////////////////////////////////////////////////////////////////////////////// - FontIDW fontid = { sizeof(fontid) }; + FontIDW fontid = {}; wcsncpy_s(fontid.group, LPGENW("Favorite Contacts"), _TRUNCATE); strncpy_s(fontid.dbSettingsGroup, "FavContacts", _TRUNCATE); wcsncpy_s(fontid.backgroundGroup, LPGENW("Favorite Contacts"), _TRUNCATE); @@ -171,13 +171,13 @@ int ProcessModulesLoaded(WPARAM, LPARAM) wcsncpy_s(fontid.backgroundName, LPGENW("Background"), _TRUNCATE); wcsncpy_s(fontid.name, LPGENW("Contact name"), _TRUNCATE); - strncpy_s(fontid.prefix, "fntName", _TRUNCATE); + strncpy_s(fontid.setting, "fntName", _TRUNCATE); fontid.deffontsettings.colour = GetSysColor(COLOR_MENUTEXT); fontid.deffontsettings.style = DBFONTF_BOLD; g_plugin.addFont(&fontid); wcsncpy_s(fontid.name, LPGENW("Second line"), _TRUNCATE); - strncpy_s(fontid.prefix, "fntSecond", _TRUNCATE); + strncpy_s(fontid.setting, "fntSecond", _TRUNCATE); fontid.deffontsettings.colour = sttShadeColor(GetSysColor(COLOR_MENUTEXT), GetSysColor(COLOR_MENU)); fontid.deffontsettings.style = 0; g_plugin.addFont(&fontid); @@ -185,20 +185,20 @@ int ProcessModulesLoaded(WPARAM, LPARAM) wcsncpy_s(fontid.backgroundName, LPGENW("Selected background"), _TRUNCATE); wcsncpy_s(fontid.name, LPGENW("Selected contact name (color)"), _TRUNCATE); - strncpy_s(fontid.prefix, "fntNameSel", _TRUNCATE); + strncpy_s(fontid.setting, "fntNameSel", _TRUNCATE); fontid.deffontsettings.colour = GetSysColor(COLOR_HIGHLIGHTTEXT); fontid.deffontsettings.style = DBFONTF_BOLD; g_plugin.addFont(&fontid); wcsncpy_s(fontid.name, LPGENW("Selected second line (color)"), _TRUNCATE); - strncpy_s(fontid.prefix, "fntSecondSel", _TRUNCATE); + strncpy_s(fontid.setting, "fntSecondSel", _TRUNCATE); fontid.deffontsettings.colour = sttShadeColor(GetSysColor(COLOR_HIGHLIGHTTEXT), GetSysColor(COLOR_HIGHLIGHT)); fontid.deffontsettings.style = 0; g_plugin.addFont(&fontid); ///////////////////////////////////////////////////////////////////////////////////// - ColourIDW colourid = { sizeof(colourid) }; + ColourIDW colourid = {}; wcsncpy_s(colourid.group, LPGENW("Favorite Contacts"), _TRUNCATE); strncpy_s(colourid.dbSettingsGroup, "FavContacts", _TRUNCATE); diff --git a/plugins/HistoryPlusPlus/hpp_options.pas b/plugins/HistoryPlusPlus/hpp_options.pas index d638a2a030..d8a442a711 100644 --- a/plugins/HistoryPlusPlus/hpp_options.pas +++ b/plugins/HistoryPlusPlus/hpp_options.pas @@ -264,7 +264,6 @@ procedure RegisterFont(Name:PAnsiChar; Order:integer; const defFont:TFontSetting var fid: TFontID; begin - fid.cbSize := sizeof(fid); fid.group := hppName; fid.dbSettingsGroup := hppDBName; fid.flags := FIDF_DEFAULTVALID+FIDF_ALLOWEFFECTS; @@ -282,7 +281,6 @@ procedure RegisterColor(Name:PAnsiChar; Order:integer; defColor:TColor); var cid: TColourID; begin - cid.cbSize := sizeof(cid); cid.group := hppName; cid.dbSettingsGroup := hppDBName; cid.order := Order; diff --git a/plugins/MyDetails/src/frame.cpp b/plugins/MyDetails/src/frame.cpp index 46f69fb83e..cc39049339 100644 --- a/plugins/MyDetails/src/frame.cpp +++ b/plugins/MyDetails/src/frame.cpp @@ -73,9 +73,7 @@ char font_sizes[] = { 13, 8, 8, 8, 8 }; BYTE font_styles[] = { DBFONTF_BOLD, 0, 0, DBFONTF_ITALIC, DBFONTF_ITALIC }; COLORREF font_colors[] = { RGB(0, 0, 0), RGB(0, 0, 0), RGB(0, 0, 0), RGB(150, 150, 150), RGB(150, 150, 150) }; -static ColourID -bg_colour = { sizeof(bg_colour), LPGEN("My details"), LPGEN("Background"), MODULENAME, "BackgroundColor", 0, GetSysColor(COLOR_BTNFACE) }, -av_colour = { sizeof(av_colour), LPGEN("My details"), LPGEN("Avatar border"), MODULENAME, "AvatarBorderColor", 0, RGB(0, 0, 0) }; +static ColourID bg_colour, av_colour; int CreateFrame(); void FixMainMenu(); @@ -225,22 +223,31 @@ int CreateFrame() { HDC hdc = GetDC(nullptr); + strncpy_s(bg_colour.group, LPGEN("My details"), _TRUNCATE); + strncpy_s(bg_colour.name, LPGEN("Background"), _TRUNCATE); + strncpy_s(bg_colour.dbSettingsGroup, MODULENAME, _TRUNCATE); + strncpy_s(bg_colour.setting, "BackgroundColor", _TRUNCATE); + bg_colour.defcolour = GetSysColor(COLOR_BTNFACE); g_plugin.addColor(&bg_colour); + + strncpy_s(av_colour.group, LPGEN("My details"), _TRUNCATE); + strncpy_s(av_colour.name, LPGEN("Avatar border"), _TRUNCATE); + strncpy_s(av_colour.dbSettingsGroup, MODULENAME, _TRUNCATE); + strncpy_s(av_colour.setting, "AvatarBorderColor", _TRUNCATE); g_plugin.addColor(&av_colour); + ReloadColour(0, 0); HookEvent(ME_COLOUR_RELOAD, ReloadColour); for (int i = 0; i < NUM_FONTS; i++) { memset(&font_id[i], 0, sizeof(font_id[i])); - font_id[i].cbSize = sizeof(FontIDW); mir_wstrncpy(font_id[i].group, LPGENW("My details"), _countof(font_id[i].group)); mir_wstrncpy(font_id[i].name, font_names[i], _countof(font_id[i].name)); mir_strncpy(font_id[i].dbSettingsGroup, MODULENAME, _countof(font_id[i].dbSettingsGroup)); mir_wstrncpy(font_id[i].backgroundName, LPGENW("Background"), _countof(font_id[i].backgroundName)); mir_wstrncpy(font_id[i].backgroundGroup, LPGENW("My details"), _countof(font_id[i].backgroundGroup)); - - mir_strncpy(font_id[i].prefix, font_settings[i], _countof(font_id[i].prefix)); + mir_strncpy(font_id[i].setting, font_settings[i], _countof(font_id[i].setting)); font_id[i].deffontsettings.colour = font_colors[i]; font_id[i].deffontsettings.size = -MulDiv(font_sizes[i], GetDeviceCaps(hdc, LOGPIXELSY), 72); diff --git a/plugins/NotesAndReminders/src/options.cpp b/plugins/NotesAndReminders/src/options.cpp index 3ab3c022a3..6b03a5493e 100644 --- a/plugins/NotesAndReminders/src/options.cpp +++ b/plugins/NotesAndReminders/src/options.cpp @@ -226,9 +226,7 @@ void RegisterFontServiceFonts() { char szTemp[100]; - FontID fontid = { 0 }; - fontid.cbSize = sizeof(FontIDW); - + FontID fontid = {}; strncpy(fontid.group, SECTIONNAME, _countof(fontid.group)); strncpy(fontid.backgroundGroup, SECTIONNAME, _countof(fontid.backgroundGroup)); strncpy(fontid.dbSettingsGroup, MODULENAME, _countof(fontid.dbSettingsGroup)); @@ -241,7 +239,7 @@ void RegisterFontServiceFonts() for (int i = 0; i < _countof(fontOptionsList); i++) { fontid.order = i; mir_snprintf(szTemp, "Font%d", i); - strncpy(fontid.prefix, szTemp, _countof(fontid.prefix)); + strncpy(fontid.setting, szTemp, _countof(fontid.setting)); strncpy(fontid.name, fontOptionsList[i].szDescr, _countof(fontid.name)); fontid.deffontsettings.colour = fontOptionsList[i].defColour; @@ -256,9 +254,7 @@ void RegisterFontServiceFonts() g_plugin.addFont(&fontid); } - ColourID colorid = { 0 }; - colorid.cbSize = sizeof(ColourIDW); - + ColourID colorid = {}; strncpy(colorid.group, SECTIONNAME, _countof(colorid.group)); strncpy(colorid.dbSettingsGroup, MODULENAME, _countof(fontid.dbSettingsGroup)); colorid.flags = 0; diff --git a/plugins/Ping/src/pingthread.cpp b/plugins/Ping/src/pingthread.cpp index 8823b181be..09eba92fb0 100644 --- a/plugins/Ping/src/pingthread.cpp +++ b/plugins/Ping/src/pingthread.cpp @@ -895,11 +895,10 @@ void InitList() else ShowWindow(hpwnd, SW_SHOW); } - font_id.cbSize = sizeof(FontIDW); mir_wstrncpy(font_id.group, LPGENW("Ping"), _countof(font_id.group)); mir_wstrncpy(font_id.name, LPGENW("List"), _countof(font_id.name)); mir_strncpy(font_id.dbSettingsGroup, "PING", _countof(font_id.dbSettingsGroup)); - mir_strncpy(font_id.prefix, "Font", _countof(font_id.prefix)); + mir_strncpy(font_id.setting, "Font", _countof(font_id.setting)); mir_wstrncpy(font_id.backgroundGroup, L"Ping", _countof(font_id.backgroundGroup)); mir_wstrncpy(font_id.backgroundName, L"Background", _countof(font_id.backgroundName)); font_id.order = 0; @@ -912,7 +911,6 @@ void InitList() g_plugin.addFont(&font_id); - bk_col_id.cbSize = sizeof(ColourIDW); mir_wstrncpy(bk_col_id.group, L"Ping", _countof(bk_col_id.group)); mir_wstrncpy(bk_col_id.name, L"Background", _countof(bk_col_id.name)); mir_strncpy(bk_col_id.dbSettingsGroup, "PING", _countof(bk_col_id.dbSettingsGroup)); diff --git a/plugins/Popup/src/font.cpp b/plugins/Popup/src/font.cpp index 6570315168..b274615963 100644 --- a/plugins/Popup/src/font.cpp +++ b/plugins/Popup/src/font.cpp @@ -28,8 +28,7 @@ PopupFonts fonts = {}; void InitFonts() { // Fonts - FontIDW fid = { 0 }; - fid.cbSize = sizeof(FontIDW); + FontIDW fid = {}; mir_wstrncpy(fid.group, _A2W(PU_FNT_AND_COLOR), _countof(fid.group)); mir_strncpy(fid.dbSettingsGroup, PU_FNT_AND_COLOR_DB, _countof(fid.dbSettingsGroup)); fid.flags = FIDF_DEFAULTVALID; @@ -40,33 +39,32 @@ void InitFonts() mir_wstrncpy(fid.deffontsettings.szFace, L"Tahoma", _countof(fid.deffontsettings.szFace)); mir_wstrncpy(fid.name, _A2W(PU_FNT_NAME_TITLE), _countof(fid.name)); - mir_snprintf(fid.prefix, PU_FNT_PREFIX, PU_FNT_NAME_TITLE); + mir_snprintf(fid.setting, PU_FNT_PREFIX, PU_FNT_NAME_TITLE); fid.deffontsettings.style = DBFONTF_BOLD; fid.deffontsettings.colour = RGB(0, 0, 0); g_plugin.addFont(&fid); mir_wstrncpy(fid.name, _A2W(PU_FNT_NAME_CLOCK), _countof(fid.name)); - mir_snprintf(fid.prefix, PU_FNT_PREFIX, PU_FNT_NAME_CLOCK); + mir_snprintf(fid.setting, PU_FNT_PREFIX, PU_FNT_NAME_CLOCK); g_plugin.addFont(&fid); mir_wstrncpy(fid.name, _A2W(PU_FNT_NAME_TEXT), _countof(fid.name)); - mir_snprintf(fid.prefix, PU_FNT_PREFIX, PU_FNT_NAME_TEXT); + mir_snprintf(fid.setting, PU_FNT_PREFIX, PU_FNT_NAME_TEXT); fid.deffontsettings.style = 0; g_plugin.addFont(&fid); mir_wstrncpy(fid.name, _A2W(PU_FNT_NAME_ACTION), _countof(fid.name)); - mir_snprintf(fid.prefix, PU_FNT_PREFIX, PU_FNT_NAME_ACTION); + mir_snprintf(fid.setting, PU_FNT_PREFIX, PU_FNT_NAME_ACTION); fid.flags = FIDF_DEFAULTVALID | FIDF_ALLOWEFFECTS; fid.deffontsettings.colour = RGB(0, 0, 255); g_plugin.addFont(&fid); mir_wstrncpy(fid.name, _A2W(PU_FNT_NAME_HOVERED_ACTION), _countof(fid.name)); - mir_snprintf(fid.prefix, PU_FNT_PREFIX, PU_FNT_NAME_HOVERED_ACTION); + mir_snprintf(fid.setting, PU_FNT_PREFIX, PU_FNT_NAME_HOVERED_ACTION); fid.deffontsettings.style = DBFONTF_UNDERLINE; g_plugin.addFont(&fid); - ColourIDW cid = { 0 }; - cid.cbSize = sizeof(ColourIDW); + ColourIDW cid = {}; mir_wstrncpy(cid.group, _A2W(PU_FNT_AND_COLOR), _countof(cid.group)); mir_strncpy(cid.dbSettingsGroup, PU_FNT_AND_COLOR_DB, _countof(cid.dbSettingsGroup)); diff --git a/plugins/Popup/src/notifications.cpp b/plugins/Popup/src/notifications.cpp index 1e2d97e7bc..fdd18a93cc 100644 --- a/plugins/Popup/src/notifications.cpp +++ b/plugins/Popup/src/notifications.cpp @@ -183,8 +183,7 @@ HANDLE RegisterNotification(POPUPNOTIFICATION *notification) // ugly hack to make reset always possible SaveNotificationSettings(ptd, "PopupNotifications"); - FontID fontid = { 0 }; - fontid.cbSize = sizeof(fontid); + FontID fontid = {}; mir_snprintf(fontid.group, PU_FNT_AND_COLOR "/%s", notification->lpzGroup); mir_strcpy(fontid.dbSettingsGroup, "PopupNotifications"); fontid.flags = FIDF_DEFAULTVALID; @@ -194,12 +193,11 @@ HANDLE RegisterNotification(POPUPNOTIFICATION *notification) mir_strncpy(fontid.deffontsettings.szFace, "MS Shell Dlg", _countof(fontid.deffontsettings.szFace)); fontid.deffontsettings.style = 0; mir_snprintf(fontid.name, "%s (colors only)", notification->lpzName); - mir_snprintf(fontid.prefix, "{%s/%s}text", notification->lpzGroup, notification->lpzName); + mir_snprintf(fontid.setting, "{%s/%s}text", notification->lpzGroup, notification->lpzName); fontid.deffontsettings.style = 0; g_plugin.addFont(&fontid); - ColourID colourid = { 0 }; - colourid.cbSize = sizeof(colourid); + ColourID colourid = {}; mir_snprintf(colourid.group, PU_FNT_AND_COLOR"/%s", notification->lpzGroup); mir_strcpy(colourid.dbSettingsGroup, "PopupNotifications"); mir_snprintf(colourid.name, "%s (colors only)", notification->lpzName); diff --git a/plugins/Popup/src/services.cpp b/plugins/Popup/src/services.cpp index 960762e556..77ab39de01 100644 --- a/plugins/Popup/src/services.cpp +++ b/plugins/Popup/src/services.cpp @@ -381,8 +381,7 @@ INT_PTR Popup_RegisterPopupClass(WPARAM, LPARAM lParam) mir_snprintf(setting, "%s/TextCol", ptd->pupClass.pszName); ptd->pupClass.colorText = (COLORREF)db_get_dw(NULL, PU_MODULCLASS, setting, fonts.clText/*pc->colorText*/); - FontIDW fid = { 0 }; - fid.cbSize = sizeof(FontIDW); + FontIDW fid = {}; mir_snwprintf(fid.group, L"%S/%s", PU_FNT_AND_COLOR, ptd->pszDescription); strncpy_s(fid.dbSettingsGroup, PU_MODULCLASS, _TRUNCATE); fid.flags = FIDF_DEFAULTVALID; @@ -390,8 +389,8 @@ INT_PTR Popup_RegisterPopupClass(WPARAM, LPARAM lParam) fid.deffontsettings.size = -11; wcsncpy_s(fid.deffontsettings.szFace, L"Verdana", _TRUNCATE); wcsncpy_s(fid.name, _A2W(PU_FNT_NAME_TEXT), _TRUNCATE); - strncpy_s(fid.prefix, setting, _TRUNCATE); - mir_snprintf(fid.prefix, "%s/Text", ptd->pupClass.pszName); // result is "%s/TextCol" + strncpy_s(fid.setting, setting, _TRUNCATE); + mir_snprintf(fid.setting, "%s/Text", ptd->pupClass.pszName); // result is "%s/TextCol" fid.deffontsettings.style = 0; fid.deffontsettings.colour = fonts.clText; g_plugin.addFont(&fid); @@ -400,8 +399,7 @@ INT_PTR Popup_RegisterPopupClass(WPARAM, LPARAM lParam) mir_snprintf(setting, "%s/BgCol", ptd->pupClass.pszName); ptd->pupClass.colorBack = (COLORREF)db_get_dw(NULL, PU_MODULCLASS, setting, (DWORD)fonts.clBack/*pc->colorBack*/); - ColourIDW cid = { 0 }; - cid.cbSize = sizeof(ColourIDW); + ColourIDW cid = {}; mir_snwprintf(cid.group, L"%S/%s", PU_FNT_AND_COLOR, ptd->pszDescription); wcsncpy_s(cid.name, PU_COL_BACK_NAME, _TRUNCATE); strncpy_s(cid.dbSettingsGroup, PU_MODULCLASS, _TRUNCATE); diff --git a/plugins/QuickSearch/i_ok.inc b/plugins/QuickSearch/i_ok.inc index 52c0d450c9..49a0729a9c 100644 --- a/plugins/QuickSearch/i_ok.inc +++ b/plugins/QuickSearch/i_ok.inc @@ -44,7 +44,6 @@ var cid:TColourID; i:tqscolor; begin - cid.cbSize:=SizeOf(cid); cid.flags :=0; StrCopy(cid.group,qs_module); StrCopy(cid.dbSettingsGroup,qs_module); diff --git a/plugins/QuickSearch/sr_frame.pas b/plugins/QuickSearch/sr_frame.pas index 76696e462c..1aba1c850a 100644 --- a/plugins/QuickSearch/sr_frame.pas +++ b/plugins/QuickSearch/sr_frame.pas @@ -180,7 +180,6 @@ begin tmp:=SendMessage(wnd,CLM_GETEXSTYLE,0,0); SendMessage(wnd,CLM_SETEXSTYLE,tmp or CLS_EX_SHOWSELALWAYS,0); - cid.cbSize:=SizeOf(cid); cid.flags :=0; StrCopy(cid.group,'QuickSearch'); StrCopy(cid.dbSettingsGroup,qs_module); diff --git a/plugins/Scriver/src/msgoptions.cpp b/plugins/Scriver/src/msgoptions.cpp index 0379451f63..431d98c9e1 100644 --- a/plugins/Scriver/src/msgoptions.cpp +++ b/plugins/Scriver/src/msgoptions.cpp @@ -86,7 +86,7 @@ int FontServiceFontsChanged(WPARAM, LPARAM) void RegisterFontServiceFonts() { - FontIDW fid = { sizeof(fid) }; + FontIDW fid = {}; wcsncpy_s(fid.group, LPGENW("Messaging"), _TRUNCATE); wcsncpy_s(fid.backgroundGroup, LPGENW("Messaging"), _TRUNCATE); strncpy(fid.dbSettingsGroup, SRMM_MODULE, _countof(fid.dbSettingsGroup)); @@ -96,7 +96,7 @@ void RegisterFontServiceFonts() char szTemp[100]; mir_snprintf(szTemp, "SRMFont%d", i); - strncpy(fid.prefix, szTemp, _countof(fid.prefix)); + strncpy(fid.setting, szTemp, _countof(fid.setting)); wcsncpy(fid.name, fontOptionsList[i].szDescr, _countof(fid.name)); fid.deffontsettings.colour = fontOptionsList[i].defColour; fid.deffontsettings.size = fontOptionsList[i].defSize; @@ -107,7 +107,7 @@ void RegisterFontServiceFonts() g_plugin.addFont(&fid); } - ColourIDW cid = { sizeof(cid) }; + ColourIDW cid = {}; wcsncpy_s(cid.group, LPGENW("Messaging"), _TRUNCATE); strncpy(cid.dbSettingsGroup, SRMM_MODULE, _countof(fid.dbSettingsGroup)); cid.flags = 0; diff --git a/plugins/SmileyAdd/src/main.cpp b/plugins/SmileyAdd/src/main.cpp index 7745910a4f..424618f61f 100644 --- a/plugins/SmileyAdd/src/main.cpp +++ b/plugins/SmileyAdd/src/main.cpp @@ -69,7 +69,7 @@ static int ModulesLoaded(WPARAM, LPARAM) g_SmileyCategories.AddAllProtocolsAsCategory(); g_SmileyCategories.ClearAndLoadAll(); - ColourID cid = { sizeof(cid) }; + ColourID cid = {}; strcpy_s(cid.dbSettingsGroup, MODULENAME); strcpy_s(cid.group, MODULENAME); strcpy_s(cid.name, LPGEN("Background color")); diff --git a/plugins/TabSRMM/src/chat_options.cpp b/plugins/TabSRMM/src/chat_options.cpp index 373450eba7..6b218f16f3 100644 --- a/plugins/TabSRMM/src/chat_options.cpp +++ b/plugins/TabSRMM/src/chat_options.cpp @@ -290,18 +290,15 @@ static wchar_t *chatcolorsnames[] = void RegisterFontServiceFonts() { LOGFONT lf; - FontIDW fid = { 0 }; - ColourIDW cid = { 0 }; - - fid.cbSize = sizeof(FontIDW); - cid.cbSize = sizeof(ColourIDW); + FontIDW fid = {}; + ColourIDW cid = {}; strncpy(fid.dbSettingsGroup, FONTMODULE, _countof(fid.dbSettingsGroup)); for (int i = 0; i < _countof(IM_fontOptionsList); i++) { fid.flags = FIDF_DEFAULTVALID | FIDF_ALLOWEFFECTS; LoadMsgDlgFont(FONTSECTION_IM, i, &lf, &fontOptionsList[i].colour, FONTMODULE); - mir_snprintf(fid.prefix, "Font%d", i); + mir_snprintf(fid.setting, "Font%d", i); fid.order = i; wcsncpy(fid.name, fontOptionsList[i].szDescr, _countof(fid.name)); fid.deffontsettings.colour = fontOptionsList[i].colour; @@ -363,7 +360,7 @@ void RegisterFontServiceFonts() wcsncpy(fid.backgroundName, LPGENW("Fields background"), _countof(fid.backgroundName)); for (int i = 0; i < IPFONTCOUNT; i++) { LoadMsgDlgFont(FONTSECTION_IP, i, &lf, &fontOptionsList[i].colour, FONTMODULE); - mir_snprintf(fid.prefix, "Font%d", i + 100); + mir_snprintf(fid.setting, "Font%d", i + 100); fid.order = i + 100; wcsncpy(fid.name, fontOptionsList[i].szDescr, _countof(fid.name)); fid.deffontsettings.colour = fontOptionsList[i].colour; diff --git a/plugins/TipperYM/src/tipper.cpp b/plugins/TipperYM/src/tipper.cpp index 5c8cd820d2..d7fcb2e9a4 100644 --- a/plugins/TipperYM/src/tipper.cpp +++ b/plugins/TipperYM/src/tipper.cpp @@ -116,7 +116,6 @@ static int ReloadSkinFolder(WPARAM, LPARAM) static void InitFonts() { - colourBg.cbSize = sizeof(ColourIDW); mir_wstrcpy(colourBg.group, LPGENW("Tooltips")); mir_wstrcpy(colourBg.name, LPGENW("Background")); mir_strcpy(colourBg.dbSettingsGroup, MODULENAME); @@ -125,7 +124,6 @@ static void InitFonts() colourBg.order = 0; g_plugin.addColor(&colourBg); - colourBorder.cbSize = sizeof(ColourIDW); mir_wstrcpy(colourBorder.group, LPGENW("Tooltips")); mir_wstrcpy(colourBorder.name, LPGENW("Border")); mir_strcpy(colourBorder.dbSettingsGroup, MODULENAME); @@ -134,7 +132,6 @@ static void InitFonts() colourBorder.order = 0; g_plugin.addColor(&colourBorder); - colourAvatarBorder.cbSize = sizeof(ColourIDW); mir_wstrcpy(colourAvatarBorder.group, LPGENW("Tooltips")); mir_wstrcpy(colourAvatarBorder.name, LPGENW("Avatar border")); mir_strcpy(colourAvatarBorder.dbSettingsGroup, MODULENAME); @@ -143,7 +140,6 @@ static void InitFonts() colourAvatarBorder.order = 0; g_plugin.addColor(&colourAvatarBorder); - colourDivider.cbSize = sizeof(ColourIDW); mir_wstrcpy(colourDivider.group, LPGENW("Tooltips")); mir_wstrcpy(colourDivider.name, LPGENW("Dividers")); mir_strcpy(colourDivider.dbSettingsGroup, MODULENAME); @@ -152,7 +148,6 @@ static void InitFonts() colourDivider.order = 0; g_plugin.addColor(&colourDivider); - colourSidebar.cbSize = sizeof(ColourIDW); mir_wstrcpy(colourSidebar.group, LPGENW("Tooltips")); mir_wstrcpy(colourSidebar.name, LPGENW("Sidebar")); mir_strcpy(colourSidebar.dbSettingsGroup, MODULENAME); @@ -161,12 +156,11 @@ static void InitFonts() colourSidebar.order = 0; g_plugin.addColor(&colourSidebar); - fontTitle.cbSize = sizeof(FontIDW); fontTitle.flags = FIDF_ALLOWEFFECTS; mir_wstrcpy(fontTitle.group, LPGENW("Tooltips")); mir_wstrcpy(fontTitle.name, LPGENW("Title")); mir_strcpy(fontTitle.dbSettingsGroup, MODULENAME); - mir_strcpy(fontTitle.prefix, "FontFirst"); + mir_strcpy(fontTitle.setting, "FontFirst"); mir_wstrcpy(fontTitle.backgroundGroup, LPGENW("Tooltips")); mir_wstrcpy(fontTitle.backgroundName, LPGENW("Background")); fontTitle.order = 0; @@ -177,12 +171,11 @@ static void InitFonts() fontTitle.deffontsettings.colour = RGB(255, 0, 0); fontTitle.flags |= FIDF_DEFAULTVALID; - fontLabels.cbSize = sizeof(FontIDW); fontLabels.flags = FIDF_ALLOWEFFECTS; mir_wstrcpy(fontLabels.group, LPGENW("Tooltips")); mir_wstrcpy(fontLabels.name, LPGENW("Labels")); mir_strcpy(fontLabels.dbSettingsGroup, MODULENAME); - mir_strcpy(fontLabels.prefix, "FontLabels"); + mir_strcpy(fontLabels.setting, "FontLabels"); mir_wstrcpy(fontLabels.backgroundGroup, LPGENW("Tooltips")); mir_wstrcpy(fontLabels.backgroundName, LPGENW("Background")); fontLabels.order = 1; @@ -193,12 +186,11 @@ static void InitFonts() fontLabels.deffontsettings.colour = RGB(128, 128, 128); fontLabels.flags |= FIDF_DEFAULTVALID; - fontValues.cbSize = sizeof(FontIDW); fontValues.flags = FIDF_ALLOWEFFECTS; mir_wstrcpy(fontValues.group, LPGENW("Tooltips")); mir_wstrcpy(fontValues.name, LPGENW("Values")); mir_strcpy(fontValues.dbSettingsGroup, MODULENAME); - mir_strcpy(fontValues.prefix, "FontValues"); + mir_strcpy(fontValues.setting, "FontValues"); mir_wstrcpy(fontValues.backgroundGroup, LPGENW("Tooltips")); mir_wstrcpy(fontValues.backgroundName, LPGENW("Background")); fontValues.order = 2; @@ -209,12 +201,11 @@ static void InitFonts() fontValues.deffontsettings.colour = RGB(0, 0, 0); fontValues.flags |= FIDF_DEFAULTVALID; - fontTrayTitle.cbSize = sizeof(FontIDW); fontTrayTitle.flags = FIDF_ALLOWEFFECTS; mir_wstrcpy(fontTrayTitle.group, LPGENW("Tooltips")); mir_wstrcpy(fontTrayTitle.name, LPGENW("Tray title")); mir_strcpy(fontTrayTitle.dbSettingsGroup, MODULENAME); - mir_strcpy(fontTrayTitle.prefix, "FontTrayTitle"); + mir_strcpy(fontTrayTitle.setting, "FontTrayTitle"); mir_wstrcpy(fontTrayTitle.backgroundGroup, LPGENW("Tooltips")); mir_wstrcpy(fontTrayTitle.backgroundName, LPGENW("Background")); fontTrayTitle.order = 0; diff --git a/plugins/TooltipNotify/src/TooltipNotify.cpp b/plugins/TooltipNotify/src/TooltipNotify.cpp index ae03ca7685..cde67b2709 100644 --- a/plugins/TooltipNotify/src/TooltipNotify.cpp +++ b/plugins/TooltipNotify/src/TooltipNotify.cpp @@ -72,7 +72,7 @@ CTooltipNotify::~CTooltipNotify() void CTooltipNotify::RegisterFonts() { - FontIDW fontId = { sizeof(fontId) }; + FontIDW fontId = {}; wcsncpy(fontId.group, FONTSERV_GROUP, _countof(fontId.group) - 1); strncpy(fontId.dbSettingsGroup, MODULENAME, _countof(fontId.dbSettingsGroup) - 1); fontId.flags = FIDF_DEFAULTVALID; @@ -84,7 +84,7 @@ void CTooltipNotify::RegisterFonts() fontId.order = 0; wcsncpy(fontId.backgroundGroup, FONTSERV_GROUP, _countof(fontId.backgroundGroup) - 1); - ColourIDW colorId = { sizeof(colorId) }; + ColourIDW colorId = {}; wcsncpy(colorId.group, FONTSERV_GROUP, _countof(colorId.group) - 1); strncpy(colorId.dbSettingsGroup, MODULENAME, _countof(colorId.dbSettingsGroup) - 1); colorId.flags = 0; @@ -93,7 +93,7 @@ void CTooltipNotify::RegisterFonts() for (int i = 0; i < _countof(s_fontTable); i++) { wcsncpy(fontId.name, s_fontTable[i].name, _countof(fontId.name) - 1); - strncpy(fontId.prefix, s_fontTable[i].fontPrefix, _countof(fontId.prefix) - 1); + strncpy(fontId.setting, s_fontTable[i].fontPrefix, _countof(fontId.setting) - 1); wcsncpy(fontId.backgroundName, s_fontTable[i].name, _countof(fontId.backgroundName) - 1); ::g_plugin.addFont(&fontId); diff --git a/plugins/TrafficCounter/src/TrafficCounter.cpp b/plugins/TrafficCounter/src/TrafficCounter.cpp index 37e6ac7a85..8e7cb33cc3 100644 --- a/plugins/TrafficCounter/src/TrafficCounter.cpp +++ b/plugins/TrafficCounter/src/TrafficCounter.cpp @@ -1086,11 +1086,10 @@ static int TrafficCounterModulesLoaded(WPARAM, LPARAM) OverallInfo.Total.Timer = db_get_dw(NULL, MODULENAME, SETTINGS_TOTAL_ONLINE_TIME, 0); //register traffic font - TrafficFontID.cbSize = sizeof(FontIDW); mir_wstrcpy(TrafficFontID.group, LPGENW("Traffic counter")); mir_wstrcpy(TrafficFontID.name, LPGENW("Font")); mir_strcpy(TrafficFontID.dbSettingsGroup, MODULENAME); - mir_strcpy(TrafficFontID.prefix, "Font"); + mir_strcpy(TrafficFontID.setting, "Font"); TrafficFontID.flags = FIDF_DEFAULTVALID | FIDF_SAVEPOINTSIZE; TrafficFontID.deffontsettings.charset = DEFAULT_CHARSET; TrafficFontID.deffontsettings.colour = GetSysColor(COLOR_BTNTEXT); @@ -1101,7 +1100,6 @@ static int TrafficCounterModulesLoaded(WPARAM, LPARAM) g_plugin.addFont(&TrafficFontID); // Регистрируем цвет фона - TrafficBackgroundColorID.cbSize = sizeof(ColourIDW); mir_wstrcpy(TrafficBackgroundColorID.group, LPGENW("Traffic counter")); mir_wstrcpy(TrafficBackgroundColorID.name, LPGENW("Font")); mir_strcpy(TrafficBackgroundColorID.dbSettingsGroup, MODULENAME); diff --git a/plugins/Weather/src/weather_mwin.cpp b/plugins/Weather/src/weather_mwin.cpp index 7208b267df..9c5e098dfd 100644 --- a/plugins/Weather/src/weather_mwin.cpp +++ b/plugins/Weather/src/weather_mwin.cpp @@ -316,8 +316,7 @@ void InitMwin(void) wndclass.lpszClassName = L"WeatherFrame"; RegisterClass(&wndclass); - ColourIDW colourid = { 0 }; - colourid.cbSize = sizeof(ColourIDW); + ColourIDW colourid = {}; mir_strcpy(colourid.dbSettingsGroup, WEATHERPROTONAME); mir_strcpy(colourid.setting, "ColorMwinFrame"); mir_wstrcpy(colourid.name, LPGENW("Frame Background")); @@ -325,13 +324,12 @@ void InitMwin(void) colourid.defcolour = GetSysColor(COLOR_3DFACE); g_plugin.addColor(&colourid); - FontIDW fontid = { 0 }; - fontid.cbSize = sizeof(FontIDW); + FontIDW fontid = {}; fontid.flags = FIDF_ALLOWREREGISTER | FIDF_DEFAULTVALID; mir_strcpy(fontid.dbSettingsGroup, WEATHERPROTONAME); mir_wstrcpy(fontid.group, _A2W(WEATHERPROTONAME)); mir_wstrcpy(fontid.name, LPGENW("Frame Font")); - mir_strcpy(fontid.prefix, "fnt0"); + mir_strcpy(fontid.setting, "fnt0"); HDC hdc = GetDC(nullptr); fontid.deffontsettings.size = -13; @@ -345,7 +343,7 @@ void InitMwin(void) fontid.deffontsettings.style = DBFONTF_BOLD; mir_wstrcpy(fontid.name, LPGENW("Frame Title Font")); - mir_strcpy(fontid.prefix, "fnt1"); + mir_strcpy(fontid.setting, "fnt1"); g_plugin.addFont(&fontid); for (auto &hContact : Contacts(WEATHERPROTONAME)) diff --git a/plugins/YAPP/src/yapp.cpp b/plugins/YAPP/src/yapp.cpp index 041ef7d85a..f3642de98c 100644 --- a/plugins/YAPP/src/yapp.cpp +++ b/plugins/YAPP/src/yapp.cpp @@ -11,8 +11,8 @@ MNOTIFYLINK *notifyLink = nullptr; // used to work around a bug in neweventnotify and others with the address passed in the GetPluginData function bool ignore_gpd_passed_addy = false; -FontIDW font_id_firstline = {0}, font_id_secondline = {0}, font_id_time = {0}; -ColourIDW colour_id_bg = {0}, colour_id_border = {0}, colour_id_sidebar = {0}, colour_id_titleunderline = {0}; +FontIDW font_id_firstline = {}, font_id_secondline = {}, font_id_time = {}; +ColourIDW colour_id_bg = {}, colour_id_border = {}, colour_id_sidebar = {}, colour_id_titleunderline = {}; COLORREF colBg = GetSysColor(COLOR_3DSHADOW); HFONT hFontFirstLine = nullptr, hFontSecondLine = nullptr, hFontTime = nullptr; @@ -86,40 +86,36 @@ static int TTBLoaded(WPARAM, LPARAM) static void InitFonts() { - font_id_firstline.cbSize = sizeof(FontIDW); font_id_firstline.flags = FIDF_ALLOWEFFECTS; mir_wstrcpy(font_id_firstline.group, LPGENW("Popups")); mir_wstrcpy(font_id_firstline.name, LPGENW("First line")); mir_strcpy(font_id_firstline.dbSettingsGroup, MODULENAME); - mir_strcpy(font_id_firstline.prefix, "FontFirst"); + mir_strcpy(font_id_firstline.setting, "FontFirst"); mir_wstrcpy(font_id_firstline.backgroundGroup, L"Popups"); mir_wstrcpy(font_id_firstline.backgroundName, L"Background"); font_id_firstline.order = 0; g_plugin.addFont(&font_id_firstline); - font_id_secondline.cbSize = sizeof(FontIDW); font_id_secondline.flags = FIDF_ALLOWEFFECTS; mir_wstrcpy(font_id_secondline.group, LPGENW("Popups")); mir_wstrcpy(font_id_secondline.name, LPGENW("Second line")); mir_strcpy(font_id_secondline.dbSettingsGroup, MODULENAME); - mir_strcpy(font_id_secondline.prefix, "FontSecond"); + mir_strcpy(font_id_secondline.setting, "FontSecond"); mir_wstrcpy(font_id_secondline.backgroundGroup, L"Popups"); mir_wstrcpy(font_id_secondline.backgroundName, L"Background"); font_id_secondline.order = 1; g_plugin.addFont(&font_id_secondline); - font_id_time.cbSize = sizeof(FontIDW); font_id_time.flags = FIDF_ALLOWEFFECTS; mir_wstrcpy(font_id_time.group, LPGENW("Popups")); mir_wstrcpy(font_id_time.name, LPGENW("Time")); mir_strcpy(font_id_time.dbSettingsGroup, MODULENAME); - mir_strcpy(font_id_time.prefix, "FontTime"); + mir_strcpy(font_id_time.setting, "FontTime"); mir_wstrcpy(font_id_time.backgroundGroup, L"Popups"); mir_wstrcpy(font_id_time.backgroundName, L"Background"); font_id_time.order = 2; g_plugin.addFont(&font_id_time); - colour_id_bg.cbSize = sizeof(ColourIDW); mir_wstrcpy(colour_id_bg.group, LPGENW("Popups")); mir_wstrcpy(colour_id_bg.name, LPGENW("Background")); mir_strcpy(colour_id_bg.dbSettingsGroup, MODULENAME); @@ -128,7 +124,6 @@ static void InitFonts() colour_id_bg.order = 0; g_plugin.addColor(&colour_id_bg); - colour_id_border.cbSize = sizeof(ColourIDW); mir_wstrcpy(colour_id_border.group, LPGENW("Popups")); mir_wstrcpy(colour_id_border.name, LPGENW("Border")); mir_strcpy(colour_id_border.dbSettingsGroup, MODULENAME); @@ -137,7 +132,6 @@ static void InitFonts() colour_id_border.order = 1; g_plugin.addColor(&colour_id_border); - colour_id_sidebar.cbSize = sizeof(ColourIDW); mir_wstrcpy(colour_id_sidebar.group, LPGENW("Popups")); mir_wstrcpy(colour_id_sidebar.name, LPGENW("Sidebar")); mir_strcpy(colour_id_sidebar.dbSettingsGroup, MODULENAME); @@ -146,7 +140,6 @@ static void InitFonts() colour_id_sidebar.order = 2; g_plugin.addColor(&colour_id_sidebar); - colour_id_titleunderline.cbSize = sizeof(ColourIDW); mir_wstrcpy(colour_id_titleunderline.group, LPGENW("Popups")); mir_wstrcpy(colour_id_titleunderline.name, LPGENW("Title underline")); mir_strcpy(colour_id_titleunderline.dbSettingsGroup, MODULENAME); diff --git a/plugins/mRadio/rframeapi.pas b/plugins/mRadio/rframeapi.pas index 94d5438ea5..81443dd843 100644 --- a/plugins/mRadio/rframeapi.pas +++ b/plugins/mRadio/rframeapi.pas @@ -236,7 +236,6 @@ begin tmp:=SendMessage(wnd,CLM_GETEXSTYLE,0,0); SendMessage(wnd,CLM_SETEXSTYLE,tmp or CLS_EX_SHOWSELALWAYS,0); - cid.cbSize:=SizeOf(cid); cid.flags :=0; StrCopy(cid.group,cPluginName); StrCopy(cid.dbSettingsGroup,cPluginName); diff --git a/protocols/JabberG/src/jabber.cpp b/protocols/JabberG/src/jabber.cpp index 5f57a3bedd..06d7fec2b4 100755 --- a/protocols/JabberG/src/jabber.cpp +++ b/protocols/JabberG/src/jabber.cpp @@ -108,8 +108,7 @@ static int OnModulesLoaded(WPARAM, LPARAM) } // init fontservice for info frame - FontIDW fontid = { 0 }; - fontid.cbSize = sizeof(fontid); + FontIDW fontid = {}; wcsncpy_s(fontid.group, LPGENW("Jabber"), _TRUNCATE); strncpy_s(fontid.dbSettingsGroup, GLOBAL_SETTING_MODULE, _TRUNCATE); wcsncpy_s(fontid.backgroundGroup, L"Jabber", _TRUNCATE); @@ -123,17 +122,16 @@ static int OnModulesLoaded(WPARAM, LPARAM) fontid.deffontsettings.style = 0; wcsncpy_s(fontid.name, LPGENW("Frame title"), _TRUNCATE); - strncpy_s(fontid.prefix, "fntFrameTitle", _TRUNCATE); + strncpy_s(fontid.setting, "fntFrameTitle", _TRUNCATE); fontid.deffontsettings.style = DBFONTF_BOLD; g_plugin.addFont(&fontid); wcsncpy_s(fontid.name, LPGENW("Frame text"), _TRUNCATE); - strncpy_s(fontid.prefix, "fntFrameClock", _TRUNCATE); + strncpy_s(fontid.setting, "fntFrameClock", _TRUNCATE); fontid.deffontsettings.style = 0; g_plugin.addFont(&fontid); - ColourIDW colourid = {0}; - colourid.cbSize = sizeof(colourid); + ColourIDW colourid = {}; wcsncpy_s(colourid.group, L"Jabber", _TRUNCATE); strncpy_s(colourid.dbSettingsGroup, GLOBAL_SETTING_MODULE, _TRUNCATE); @@ -141,7 +139,6 @@ static int OnModulesLoaded(WPARAM, LPARAM) strncpy_s(colourid.setting, "clFrameBack", _TRUNCATE); colourid.defcolour = GetSysColor(COLOR_WINDOW); g_plugin.addColor(&colourid); - return 0; } diff --git a/protocols/JabberG/src/jabber_menu.cpp b/protocols/JabberG/src/jabber_menu.cpp index e29c547cdf..89d745bb3d 100644 --- a/protocols/JabberG/src/jabber_menu.cpp +++ b/protocols/JabberG/src/jabber_menu.cpp @@ -907,7 +907,7 @@ int CJabberProto::OnProcessSrmmEvent(WPARAM, LPARAM lParam) DBVARIANT dbv; bool bSupportTyping = false; - if (!db_get_b(event->hContact, "SRMsg", "SupportTyping")) { + if (!db_get(event->hContact, "SRMsg", "SupportTyping", &dbv)) { bSupportTyping = dbv.bVal == 1; db_free(&dbv); } diff --git a/src/core/stdclist/src/clcfonts.cpp b/src/core/stdclist/src/clcfonts.cpp index e7729d616b..adcca0412e 100644 --- a/src/core/stdclist/src/clcfonts.cpp +++ b/src/core/stdclist/src/clcfonts.cpp @@ -51,10 +51,10 @@ static int FS_FontsChanged(WPARAM, LPARAM) void RegisterCListFonts() { - FontIDW fontid = { sizeof(fontid) }; + FontIDW fontid = {}; fontid.flags = FIDF_DEFAULTVALID | FIDF_ALLOWREREGISTER | FIDF_APPENDNAME | FIDF_NOAS | FIDF_SAVEPOINTSIZE | FIDF_ALLOWEFFECTS; - strncpy(fontid.dbSettingsGroup, "CLC", sizeof(fontid.dbSettingsGroup)); - wcsncpy(fontid.group, LPGENW("Contact list"), _countof(fontid.group)); + strncpy_s(fontid.dbSettingsGroup, "CLC", _TRUNCATE); + wcsncpy_s(fontid.group, LPGENW("Contact list"), _TRUNCATE); HDC hdc = GetDC(nullptr); for (int i = 0; i < _countof(clistFontDescr); i++) { @@ -70,42 +70,38 @@ void RegisterCListFonts() fontid.flags &= ~FIDF_CLASSMASK; fontid.flags |= clistFontDescr[i].iMask; - wcsncpy(fontid.name, clistFontDescr[i].tszName, _countof(fontid.name)); + wcsncpy_s(fontid.name, clistFontDescr[i].tszName, _TRUNCATE); - char idstr[10]; - mir_snprintf(idstr, "Font%d", i); - strncpy(fontid.prefix, idstr, _countof(fontid.prefix)); + mir_snprintf(fontid.setting, "Font%d", i); fontid.order = i; g_plugin.addFont(&fontid); } ReleaseDC(nullptr, hdc); // and colours - ColourIDW colourid = { 0 }; - colourid.cbSize = sizeof(ColourIDW); - colourid.order = 0; - strncpy(colourid.dbSettingsGroup, "CLC", sizeof(colourid.dbSettingsGroup)); - - strncpy(colourid.setting, "BkColour", sizeof(colourid.setting)); - wcsncpy(colourid.name, LPGENW("Background"), _countof(colourid.name)); - wcsncpy(colourid.group, LPGENW("Contact list"), _countof(colourid.group)); + ColourIDW colourid = {}; + strncpy_s(colourid.dbSettingsGroup, "CLC", _TRUNCATE); + + strncpy_s(colourid.setting, "BkColour", _TRUNCATE); + wcsncpy_s(colourid.name, LPGENW("Background"), _TRUNCATE); + wcsncpy_s(colourid.group, LPGENW("Contact list"), _TRUNCATE); colourid.defcolour = CLCDEFAULT_BKCOLOUR; g_plugin.addColor(&colourid); - strncpy(colourid.setting, "SelTextColour", sizeof(colourid.setting)); - wcsncpy(colourid.name, LPGENW("Selected text"), _countof(colourid.name)); + strncpy_s(colourid.setting, "SelTextColour", _TRUNCATE); + wcsncpy_s(colourid.name, LPGENW("Selected text"), _TRUNCATE); colourid.order = 1; colourid.defcolour = CLCDEFAULT_SELTEXTCOLOUR; g_plugin.addColor(&colourid); - strncpy(colourid.setting, "HotTextColour", sizeof(colourid.setting)); - wcsncpy(colourid.name, LPGENW("Hottrack text"), _countof(colourid.name)); + strncpy_s(colourid.setting, "HotTextColour", _TRUNCATE); + wcsncpy_s(colourid.name, LPGENW("Hottrack text"), _TRUNCATE); colourid.order = 1; colourid.defcolour = CLCDEFAULT_HOTTEXTCOLOUR; g_plugin.addColor(&colourid); - strncpy(colourid.setting, "QuickSearchColour", sizeof(colourid.setting)); - wcsncpy(colourid.name, LPGENW("Quicksearch text"), _countof(colourid.name)); + strncpy_s(colourid.setting, "QuickSearchColour", _TRUNCATE); + wcsncpy_s(colourid.name, LPGENW("Quicksearch text"), _TRUNCATE); colourid.order = 1; colourid.defcolour = CLCDEFAULT_QUICKSEARCHCOLOUR; g_plugin.addColor(&colourid); diff --git a/src/core/stdmsg/src/chat_manager.cpp b/src/core/stdmsg/src/chat_manager.cpp index 84afc895b4..18626e3f28 100644 --- a/src/core/stdmsg/src/chat_manager.cpp +++ b/src/core/stdmsg/src/chat_manager.cpp @@ -146,7 +146,7 @@ static void OnLoadSettings() static void RegisterFonts() { - ColourIDW colourid = { sizeof(colourid) }; + ColourIDW colourid = {}; strncpy(colourid.dbSettingsGroup, CHAT_MODULE, sizeof(colourid.dbSettingsGroup)); wcsncpy(colourid.group, LPGENW("Message sessions") L"/" LPGENW("Chat module"), _countof(colourid.group)); diff --git a/src/core/stdmsg/src/msgoptions.cpp b/src/core/stdmsg/src/msgoptions.cpp index d8c88d0327..98cd0e55b2 100644 --- a/src/core/stdmsg/src/msgoptions.cpp +++ b/src/core/stdmsg/src/msgoptions.cpp @@ -95,7 +95,7 @@ bool LoadMsgDlgFont(int i, LOGFONT* lf, COLORREF * colour) void RegisterSRMMFonts(void) { - FontIDW fontid = { sizeof(fontid) }; + FontIDW fontid = {}; fontid.flags = FIDF_ALLOWREREGISTER | FIDF_DEFAULTVALID; for (int i = 0; i < _countof(fontOptionsList); i++) { strncpy_s(fontid.dbSettingsGroup, SRMMMOD, _TRUNCATE); @@ -104,7 +104,7 @@ void RegisterSRMMFonts(void) char idstr[10]; mir_snprintf(idstr, "SRMFont%d", i); - strncpy_s(fontid.prefix, idstr, _TRUNCATE); + strncpy_s(fontid.setting, idstr, _TRUNCATE); fontid.order = i; fontid.flags &= ~FIDF_CLASSMASK; @@ -120,7 +120,7 @@ void RegisterSRMMFonts(void) g_plugin.addFont(&fontid); } - ColourIDW colourid = { sizeof(colourid) }; + ColourIDW colourid = {}; strncpy_s(colourid.dbSettingsGroup, SRMMMOD, _TRUNCATE); strncpy_s(colourid.setting, SRMSGSET_BKGCOLOUR, _TRUNCATE); colourid.defcolour = SRMSGDEFSET_BKGCOLOUR; diff --git a/src/mir_app/src/FontOptions.cpp b/src/mir_app/src/FontOptions.cpp index 9c89f7d287..26e6708bff 100644 --- a/src/mir_app/src/FontOptions.cpp +++ b/src/mir_app/src/FontOptions.cpp @@ -126,13 +126,12 @@ void UpdateFontSettings(FontIDW *font_id, FontSettingsW *fontsettings); void UpdateColourSettings(ColourIDW *colour_id, COLORREF *colour); void UpdateEffectSettings(EffectIDW *effect_id, FONTEFFECT* effectsettings); -static void WriteLine(FILE *out, const char pszText[]) +static int CompareObj(const MBaseFontObjectW *p1, const MBaseFontObjectW *p2) { - fputs(pszText, out); - fputc('\n', out); + return strcmp(p1->dbSettingsGroup, p2->dbSettingsGroup); } -static BOOL ExportSettings(HWND hwndDlg, const wchar_t *filename, OBJLIST& flist, OBJLIST& clist, OBJLIST& elist) +static BOOL ExportSettings(HWND hwndDlg, const wchar_t *filename, OBJLIST &flist, OBJLIST &clist, OBJLIST &elist) { FILE *out = _wfopen(filename, L"w"); if (out == nullptr) { @@ -145,66 +144,69 @@ static BOOL ExportSettings(HWND hwndDlg, const wchar_t *filename, OBJLISTdbSettingsGroup); + LIST arObjects(100, CompareObj); + for (auto &it : flist) + arObjects.insert(it); + for (auto &it : clist) + arObjects.insert(it); + for (auto &it : elist) + arObjects.insert(it); + + for (auto &it : arObjects) { + mir_snprintf(buff, "\n[%s]", it->dbSettingsGroup); if (mir_strcmp(buff, header) != 0) { strncpy(header, buff, _countof(header)); - WriteLine(out, buff); + fputs(buff, out); + fputc('\n', out); } - fprintf(out, (F->flags & FIDF_APPENDNAME) ? "%sName=s%S\n" : "%s=s%S\n", F->prefix, F->value.szFace); + FontInternal *F = (FontInternal*)it; + if (flist.indexOf(F) != -1) { + fprintf(out, (F->flags & FIDF_APPENDNAME) ? "%sName=s%S\n" : "%s=s%S\n", F->setting, F->value.szFace); - int iFontSize; - if (F->flags & FIDF_SAVEACTUALHEIGHT) { - SIZE size; - LOGFONT lf; - CreateFromFontSettings(&F->value, &lf); - HFONT hFont = CreateFontIndirect(&lf); + int iFontSize; + if (F->flags & FIDF_SAVEACTUALHEIGHT) { + LOGFONT lf; + CreateFromFontSettings(&F->value, &lf); + HFONT hFont = CreateFontIndirect(&lf); - HDC hdc = GetDC(hwndDlg); - HFONT hOldFont = (HFONT)SelectObject(hdc, hFont); - GetTextExtentPoint32(hdc, L"_W", 2, &size); - ReleaseDC(hwndDlg, hdc); - SelectObject(hdc, hOldFont); - DeleteObject(hFont); + HDC hdc = GetDC(hwndDlg); + HFONT hOldFont = (HFONT)SelectObject(hdc, hFont); - iFontSize = size.cy; - } - else if (F->flags & FIDF_SAVEPOINTSIZE) { - HDC hdc = GetDC(hwndDlg); - iFontSize = (BYTE)-MulDiv(F->value.size, 72, GetDeviceCaps(hdc, LOGPIXELSY)); - ReleaseDC(hwndDlg, hdc); - } - else iFontSize = F->value.size; - fprintf(out, "%sSize=b%d\n", F->prefix, iFontSize); + SIZE size; + GetTextExtentPoint32(hdc, L"_W", 2, &size); + ReleaseDC(hwndDlg, hdc); + SelectObject(hdc, hOldFont); + DeleteObject(hFont); - fprintf(out, "%sSty=b%d\n", F->prefix, F->value.style); - fprintf(out, "%sSet=b%d\n", F->prefix, F->value.charset); - fprintf(out, "%sCol=d%d\n", F->prefix, F->value.colour); + iFontSize = size.cy; + } + else if (F->flags & FIDF_SAVEPOINTSIZE) { + HDC hdc = GetDC(hwndDlg); + iFontSize = (BYTE)-MulDiv(F->value.size, 72, GetDeviceCaps(hdc, LOGPIXELSY)); + ReleaseDC(hwndDlg, hdc); + } + else iFontSize = F->value.size; + fprintf(out, "%sSize=b%d\n", F->setting, iFontSize); - if (F->flags & FIDF_NOAS) - fprintf(out, "%sAs=w%d\n", F->prefix, 0x00FF); + fprintf(out, "%sSty=b%d\n", F->setting, F->value.style); + fprintf(out, "%sSet=b%d\n", F->setting, F->value.charset); + fprintf(out, "%sCol=d%d\n", F->setting, F->value.colour); - fprintf(out, "%sFlags=w%d\n", F->prefix, F->flags); - } + if (F->flags & FIDF_NOAS) + fprintf(out, "%sAs=w%d\n", F->setting, 0x00FF); - header[0] = 0; - for (auto &C : clist) { - mir_snprintf(buff, "\n[%s]", C->dbSettingsGroup); - if (mir_strcmp(buff, header) != 0) { - strncpy_s(header, buff, _TRUNCATE); - WriteLine(out, buff); + fprintf(out, "%sFlags=w%d\n", F->setting, F->flags); + continue; } - fprintf(out, "%s=d%d\n", C->setting, (DWORD)C->value); - } - header[0] = 0; - for (auto &E : elist) { - mir_snprintf(buff, "\n[%s]", E->dbSettingsGroup); - if (mir_strcmp(buff, header) != 0) { - strncpy_s(header, buff, _TRUNCATE); - WriteLine(out, buff); + ColourInternal *C = (ColourInternal*)it; + if (clist.indexOf(C) != -1) { + fprintf(out, "%s=d%d\n", C->setting, (DWORD)C->value); + continue; } + + EffectInternal *E = (EffectInternal*)it; fprintf(out, "%sEffect=b%d\n", E->setting, E->value.effectIndex); fprintf(out, "%sEffectCol1=d%d\n", E->setting, E->value.baseColour); fprintf(out, "%sEffectCol2=d%d\n", E->setting, E->value.secondaryColour); @@ -496,9 +498,9 @@ static void sttSaveFontData(HWND hwndDlg, FontInternal &F) char str[128]; if (F.flags & FIDF_APPENDNAME) - mir_snprintf(str, "%sName", F.prefix); + mir_snprintf(str, "%sName", F.setting); else - strncpy_s(str, F.prefix, _TRUNCATE); + strncpy_s(str, F.setting, _TRUNCATE); if (db_set_ws(0, F.dbSettingsGroup, str, F.value.szFace)) { char buff[1024]; @@ -506,7 +508,7 @@ static void sttSaveFontData(HWND hwndDlg, FontInternal &F) db_set_s(0, F.dbSettingsGroup, str, buff); } - mir_snprintf(str, "%sSize", F.prefix); + mir_snprintf(str, "%sSize", F.setting); if (F.flags & FIDF_SAVEACTUALHEIGHT) { SIZE size; CreateFromFontSettings(&F.value, &lf); @@ -527,17 +529,17 @@ static void sttSaveFontData(HWND hwndDlg, FontInternal &F) } else db_set_b(0, F.dbSettingsGroup, str, F.value.size); - mir_snprintf(str, "%sSty", F.prefix); + mir_snprintf(str, "%sSty", F.setting); db_set_b(0, F.dbSettingsGroup, str, F.value.style); - mir_snprintf(str, "%sSet", F.prefix); + mir_snprintf(str, "%sSet", F.setting); db_set_b(0, F.dbSettingsGroup, str, F.value.charset); - mir_snprintf(str, "%sCol", F.prefix); + mir_snprintf(str, "%sCol", F.setting); db_set_dw(0, F.dbSettingsGroup, str, F.value.colour); if (F.flags & FIDF_NOAS) { - mir_snprintf(str, "%sAs", F.prefix); + mir_snprintf(str, "%sAs", F.setting); db_set_w(0, F.dbSettingsGroup, str, (WORD)0x00FF); } - mir_snprintf(str, "%sFlags", F.prefix); + mir_snprintf(str, "%sFlags", F.setting); db_set_w(0, F.dbSettingsGroup, str, (WORD)F.flags); } @@ -1196,10 +1198,10 @@ int OptInit(WPARAM wParam, LPARAM) ///////////////////////////////////////////////////////////////////////////////////////// -static FontInternal* sttFindFont(OBJLIST &fonts, char *module, char *prefix) +static FontInternal* sttFindFont(OBJLIST &fonts, char *module, char *setting) { for (auto &F : fonts) - if (!mir_strcmp(F->dbSettingsGroup, module) && !mir_strcmp(F->prefix, prefix)) + if (!mir_strcmp(F->dbSettingsGroup, module) && !mir_strcmp(F->setting, setting)) return F; return nullptr; diff --git a/src/mir_app/src/FontService.cpp b/src/mir_app/src/FontService.cpp index 333c1a7176..dce937b2be 100644 --- a/src/mir_app/src/FontService.cpp +++ b/src/mir_app/src/FontService.cpp @@ -49,13 +49,9 @@ void ConvertFontSettings(FontSettings *fs, FontSettingsW *fsw) bool ConvertFontID(FontID *fid, FontIDW *fidw) { - if (fid->cbSize != sizeof(FontID)) - return false; - memset(fidw, 0, sizeof(FontIDW)); - fidw->cbSize = sizeof(FontIDW); strncpy_s(fidw->dbSettingsGroup, fid->dbSettingsGroup, _TRUNCATE); - strncpy_s(fidw->prefix, fid->prefix, _TRUNCATE); + strncpy_s(fidw->setting, fid->setting, _TRUNCATE); fidw->flags = fid->flags; fidw->order = fid->order; ConvertFontSettings(&fid->deffontsettings, &fidw->deffontsettings); @@ -70,11 +66,6 @@ bool ConvertFontID(FontID *fid, FontIDW *fidw) bool ConvertColourID(ColourID *cid, ColourIDW *cidw) { - if (cid->cbSize != sizeof(ColourID)) - return false; - - cidw->cbSize = sizeof(ColourIDW); - strncpy_s(cidw->dbSettingsGroup, cid->dbSettingsGroup, _TRUNCATE); strncpy_s(cidw->setting, cid->setting, _TRUNCATE); cidw->flags = cid->flags; @@ -88,11 +79,6 @@ bool ConvertColourID(ColourID *cid, ColourIDW *cidw) bool ConvertEffectID(EffectID *eid, EffectIDW *eidw) { - if (eid->cbSize != sizeof(EffectID)) - return false; - - eidw->cbSize = sizeof(EffectIDW); - strncpy_s(eidw->dbSettingsGroup, eid->dbSettingsGroup, _TRUNCATE); strncpy_s(eidw->setting, eid->setting, _TRUNCATE); eidw->flags = eid->flags; @@ -228,7 +214,7 @@ void UpdateFontSettings(FontIDW *font_id, FontSettingsW *fontsettings) { LOGFONT lf; COLORREF colour; - if (GetFontSettingFromDB(font_id->dbSettingsGroup, font_id->prefix, &lf, &colour, font_id->flags) && (font_id->flags & FIDF_DEFAULTVALID)) { + if (GetFontSettingFromDB(font_id->dbSettingsGroup, font_id->setting, &lf, &colour, font_id->flags) && (font_id->flags & FIDF_DEFAULTVALID)) { CreateFromFontSettings(&font_id->deffontsettings, &lf); colour = font_id->deffontsettings.colour; } @@ -247,20 +233,17 @@ void UpdateFontSettings(FontIDW *font_id, FontSettingsW *fontsettings) static int sttRegisterFontWorker(FontIDW *font_id, HPLUGIN pPlugin) { - if (font_id->cbSize != sizeof(FontIDW)) - return -1; - for (auto &F : font_id_list) if (!mir_wstrcmp(F->group, font_id->group) && !mir_wstrcmp(F->name, font_id->name) && !(F->flags & FIDF_ALLOWREREGISTER)) return 1; char idstr[256]; - mir_snprintf(idstr, "%sFlags", font_id->prefix); + mir_snprintf(idstr, "%sFlags", font_id->setting); db_set_dw(0, font_id->dbSettingsGroup, idstr, font_id->flags); FontInternal* newItem = new FontInternal; memset(newItem, 0, sizeof(FontInternal)); - memcpy(newItem, font_id, font_id->cbSize); + memcpy(newItem, font_id, sizeof(FontIDW)); newItem->pPlugin = pPlugin; if (!mir_wstrcmp(newItem->deffontsettings.szFace, L"MS Shell Dlg")) { @@ -299,7 +282,7 @@ static COLORREF sttGetFontWorker(const wchar_t *wszGroup, const wchar_t *wszName for (auto &F : font_id_list) { if (!wcsncmp(F->name, wszName, _countof(F->name)) && !wcsncmp(F->group, wszGroup, _countof(F->group))) { - if (GetFontSettingFromDB(F->dbSettingsGroup, F->prefix, lf, &colour, F->flags) && (F->flags & FIDF_DEFAULTVALID)) { + if (GetFontSettingFromDB(F->dbSettingsGroup, F->setting, lf, &colour, F->flags) && (F->flags & FIDF_DEFAULTVALID)) { CreateFromFontSettings(&F->deffontsettings, lf); colour = F->deffontsettings.colour; } @@ -354,9 +337,6 @@ void UpdateColourSettings(ColourIDW *colour_id, COLORREF *colour) static INT_PTR sttRegisterColourWorker(ColourIDW *colour_id, HPLUGIN pPlugin) { - if (colour_id->cbSize != sizeof(ColourIDW)) - return -1; - for (auto &C : colour_id_list) if (!mir_wstrcmp(C->group, colour_id->group) && !mir_wstrcmp(C->name, colour_id->name)) return 1; @@ -446,9 +426,6 @@ void UpdateEffectSettings(EffectIDW *effect_id, FONTEFFECT *effectsettings) static int sttRegisterEffectWorker(EffectIDW *effect_id, HPLUGIN pPlugin) { - if (effect_id->cbSize != sizeof(EffectIDW)) - return -1; - for (auto &E : effect_id_list) if (!mir_wstrcmp(E->group, effect_id->group) && !mir_wstrcmp(E->name, effect_id->name)) return 1; @@ -542,23 +519,23 @@ int LoadFontserviceModule(void) hColourReloadEvent = CreateHookableEvent(ME_COLOUR_RELOAD); // create generic fonts - FontIDW fontid = { sizeof(fontid) }; + FontIDW fontid = {}; strncpy(fontid.dbSettingsGroup, "Fonts", sizeof(fontid.dbSettingsGroup)); wcsncpy_s(fontid.group, LPGENW("General"), _TRUNCATE); wcsncpy_s(fontid.name, LPGENW("Headers"), _TRUNCATE); fontid.flags = FIDF_APPENDNAME | FIDF_NOAS | FIDF_SAVEPOINTSIZE | FIDF_ALLOWEFFECTS | FIDF_CLASSHEADER; - strncpy(fontid.prefix, "Header", _countof(fontid.prefix)); + strncpy_s(fontid.setting, "Header", _TRUNCATE); g_plugin.addFont(&fontid); wcsncpy_s(fontid.name, LPGENW("Generic text"), _TRUNCATE); fontid.flags = FIDF_APPENDNAME | FIDF_NOAS | FIDF_SAVEPOINTSIZE | FIDF_ALLOWEFFECTS | FIDF_CLASSGENERAL; - strncpy(fontid.prefix, "Generic", _countof(fontid.prefix)); + strncpy_s(fontid.setting, "Generic", _TRUNCATE); g_plugin.addFont(&fontid); wcsncpy_s(fontid.name, LPGENW("Small text"), _TRUNCATE); fontid.flags = FIDF_APPENDNAME | FIDF_NOAS | FIDF_SAVEPOINTSIZE | FIDF_ALLOWEFFECTS | FIDF_CLASSSMALL; - strncpy(fontid.prefix, "Small", _countof(fontid.prefix)); + strncpy_s(fontid.setting, "Small", _TRUNCATE); g_plugin.addFont(&fontid); // do last for silly dyna plugin diff --git a/src/mir_app/src/chat_opts.cpp b/src/mir_app/src/chat_opts.cpp index 6850899677..30145b13b3 100644 --- a/src/mir_app/src/chat_opts.cpp +++ b/src/mir_app/src/chat_opts.cpp @@ -135,7 +135,7 @@ void RegisterFonts(void) SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(lfDefault), &lfDefault, FALSE); - FontIDW fontid = { sizeof(fontid) }; + FontIDW fontid = {}; fontid.flags = FIDF_ALLOWREREGISTER | FIDF_DEFAULTVALID | FIDF_NEEDRESTART; wcsncpy_s(fontid.backgroundGroup, g_szFontGroup, _TRUNCATE); wcsncpy_s(fontid.group, g_szFontGroup, _TRUNCATE); @@ -145,7 +145,7 @@ void RegisterFonts(void) strncpy_s(fontid.dbSettingsGroup, CHATFONT_MODULE, _TRUNCATE); wcsncpy_s(fontid.name, FO.szDescr, _TRUNCATE); - mir_snprintf(fontid.prefix, "Font%d", index); + mir_snprintf(fontid.setting, "Font%d", index); fontid.order = index; switch (i) { diff --git a/utils/mir_fonts.cpp b/utils/mir_fonts.cpp index 8716e3c491..0f97ef2f5f 100644 --- a/utils/mir_fonts.cpp +++ b/utils/mir_fonts.cpp @@ -8,10 +8,9 @@ int FontService_RegisterFont(const char *pszDbModule, const char *pszDbName, const wchar_t *pszSection, const wchar_t *pszDescription, const wchar_t *pszBackgroundGroup, const wchar_t *pszBackgroundName, int position, BOOL bAllowEffects, LOGFONT *plfDefault, COLORREF clrDefault) { - FontIDW fid = { 0 }; - fid.cbSize = sizeof(fid); + FontIDW fid = {}; mir_strncpy(fid.dbSettingsGroup, pszDbModule, sizeof(fid.dbSettingsGroup)); /* buffer safe */ - mir_strncpy(fid.prefix, pszDbName, sizeof(fid.prefix)); /* buffer safe */ + mir_strncpy(fid.setting, pszDbName, sizeof(fid.setting)); /* buffer safe */ mir_wstrncpy(fid.group, pszSection, _countof(fid.group)); /* buffer safe */ mir_wstrncpy(fid.name, pszDescription, _countof(fid.name)); /* buffer safe */ mir_wstrncpy(fid.backgroundGroup, pszBackgroundGroup, _countof(fid.backgroundGroup)); /* buffer safe */ @@ -36,8 +35,7 @@ int FontService_RegisterFont(const char *pszDbModule, const char *pszDbName, con int FontService_RegisterColor(const char *pszDbModule, const char *pszDbName, const wchar_t *pszSection, const wchar_t *pszDescription, COLORREF clrDefault) { - ColourIDW cid = { 0 }; - cid.cbSize = sizeof(cid); + ColourIDW cid = {}; cid.defcolour = clrDefault; mir_strncpy(cid.dbSettingsGroup, pszDbModule, sizeof(cid.dbSettingsGroup)); /* buffer safe */ mir_strncpy(cid.setting, pszDbName, sizeof(cid.setting)); /* buffer safe */ -- cgit v1.2.3