summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMataes <mataes2007@gmail.com>2018-03-11 23:58:07 +0300
committerMataes <mataes2007@gmail.com>2018-03-11 23:58:07 +0300
commit381dc58bd23e8466b6304387687c9d3a255f1efb (patch)
treebfb80e146bd4ccfcc8d2a97c25e5a87e5f435484
parentbebf2fea61c75e5b7d22857857157b7e9f086da6 (diff)
clist_nicer: change char to CMStringA
-rw-r--r--plugins/Clist_nicer/src/clcitems.cpp2
-rw-r--r--plugins/Clist_nicer/src/cluiframes.cpp84
-rw-r--r--plugins/Clist_nicer/src/extBackg.cpp90
3 files changed, 94 insertions, 82 deletions
diff --git a/plugins/Clist_nicer/src/clcitems.cpp b/plugins/Clist_nicer/src/clcitems.cpp
index 31649eee00..a85e549302 100644
--- a/plugins/Clist_nicer/src/clcitems.cpp
+++ b/plugins/Clist_nicer/src/clcitems.cpp
@@ -342,7 +342,7 @@ void LoadSkinItemToCache(TExtraCache *cEntry)
if (cEntry->status_item == nullptr)
cEntry->status_item = reinterpret_cast<StatusItems_t *>(malloc(sizeof(StatusItems_t)));
memset(cEntry->status_item, 0, sizeof(StatusItems_t));
- mir_strcpy(cEntry->status_item->szName, "{--CONTACT--}"); // mark as "per contact" item
+ strncpy_s(cEntry->status_item->szName, "{--CONTACT--}", _TRUNCATE); // mark as "per contact" item
cEntry->status_item->IGNORED = 0;
cEntry->status_item->TEXTCOLOR = db_get_dw(hContact, "EXTBK", "TEXT", RGB(20, 20, 20));
diff --git a/plugins/Clist_nicer/src/cluiframes.cpp b/plugins/Clist_nicer/src/cluiframes.cpp
index 97eae87e5f..2b28b797a7 100644
--- a/plugins/Clist_nicer/src/cluiframes.cpp
+++ b/plugins/Clist_nicer/src/cluiframes.cpp
@@ -394,74 +394,58 @@ void GetBorderSize(HWND hwnd, RECT *rect)
rect->bottom = wr.bottom - cr.bottom;
}
-//append string
-char __forceinline *AS(char *str, const char *setting, char *addstr)
-{
- if (str != nullptr) {
- mir_strcpy(str, setting);
- mir_strcat(str, addstr);
- }
- return str;
-}
-
int DBLoadFrameSettingsAtPos(int pos, int Frameid)
{
- char sadd[15];
- char buf[255];
-
- _itoa(pos, sadd, 10);
+ CMStringA buf;
- Frames[Frameid].collapsed = 0 != db_get_b(NULL, CLUIFrameModule, AS(buf, "Collapse", sadd), Frames[Frameid].collapsed);
+ Frames[Frameid].collapsed = 0 != db_get_b(NULL, CLUIFrameModule, buf.Format("Collapse%d", pos), Frames[Frameid].collapsed);
- Frames[Frameid].Locked = 0 != db_get_b(NULL, CLUIFrameModule, AS(buf, "Locked", sadd), Frames[Frameid].Locked);
- Frames[Frameid].visible = 0 != db_get_b(NULL, CLUIFrameModule, AS(buf, "Visible", sadd), Frames[Frameid].visible);
- Frames[Frameid].TitleBar.ShowTitleBar = 0 != db_get_b(NULL, CLUIFrameModule, AS(buf, "TBVisile", sadd), Frames[Frameid].TitleBar.ShowTitleBar);
+ Frames[Frameid].Locked = 0 != db_get_b(NULL, CLUIFrameModule, buf.Format("Locked%d", pos), Frames[Frameid].Locked);
+ Frames[Frameid].visible = 0 != db_get_b(NULL, CLUIFrameModule, buf.Format("Visible%d", pos), Frames[Frameid].visible);
+ Frames[Frameid].TitleBar.ShowTitleBar = 0 != db_get_b(NULL, CLUIFrameModule, buf.Format("TBVisile%d", pos), Frames[Frameid].TitleBar.ShowTitleBar);
- Frames[Frameid].height = db_get_w(NULL, CLUIFrameModule, AS(buf, "Height", sadd), Frames[Frameid].height);
- Frames[Frameid].HeightWhenCollapsed = db_get_w(NULL, CLUIFrameModule, AS(buf, "HeightCollapsed", sadd), 0);
- Frames[Frameid].align = db_get_w(NULL, CLUIFrameModule, AS(buf, "Align", sadd), Frames[Frameid].align);
+ Frames[Frameid].height = db_get_w(NULL, CLUIFrameModule, buf.Format("Height%d", pos), Frames[Frameid].height);
+ Frames[Frameid].HeightWhenCollapsed = db_get_w(NULL, CLUIFrameModule, buf.Format("HeightCollapsed%d", pos), 0);
+ Frames[Frameid].align = db_get_w(NULL, CLUIFrameModule, buf.Format("Align%d", pos), Frames[Frameid].align);
- Frames[Frameid].FloatingPos.x = DBGetContactSettingRangedWord(0, CLUIFrameModule, AS(buf, "FloatX", sadd), 100, 0, 1024);
- Frames[Frameid].FloatingPos.y = DBGetContactSettingRangedWord(0, CLUIFrameModule, AS(buf, "FloatY", sadd), 100, 0, 1024);
- Frames[Frameid].FloatingSize.x = DBGetContactSettingRangedWord(0, CLUIFrameModule, AS(buf, "FloatW", sadd), 100, 0, 1024);
- Frames[Frameid].FloatingSize.y = DBGetContactSettingRangedWord(0, CLUIFrameModule, AS(buf, "FloatH", sadd), 100, 0, 1024);
+ Frames[Frameid].FloatingPos.x = DBGetContactSettingRangedWord(0, CLUIFrameModule, buf.Format("FloatX%d", pos), 100, 0, 1024);
+ Frames[Frameid].FloatingPos.y = DBGetContactSettingRangedWord(0, CLUIFrameModule, buf.Format("FloatY%d", pos), 100, 0, 1024);
+ Frames[Frameid].FloatingSize.x = DBGetContactSettingRangedWord(0, CLUIFrameModule, buf.Format("FloatW%d", pos), 100, 0, 1024);
+ Frames[Frameid].FloatingSize.y = DBGetContactSettingRangedWord(0, CLUIFrameModule, buf.Format("FloatH%d", pos), 100, 0, 1024);
- Frames[Frameid].floating = 0 != db_get_b(NULL, CLUIFrameModule, AS(buf, "Floating", sadd), 0);
- Frames[Frameid].order = db_get_w(NULL, CLUIFrameModule, AS(buf, "Order", sadd), 0);
+ Frames[Frameid].floating = 0 != db_get_b(NULL, CLUIFrameModule, buf.Format("Floating%d", pos), 0);
+ Frames[Frameid].order = db_get_w(NULL, CLUIFrameModule, buf.Format("Order%d", pos), 0);
- Frames[Frameid].UseBorder = 0 != db_get_b(NULL, CLUIFrameModule, AS(buf, "UseBorder", sadd), Frames[Frameid].UseBorder);
- Frames[Frameid].Skinned = 0 != db_get_b(NULL, CLUIFrameModule, AS(buf, "Skinned", sadd), Frames[Frameid].Skinned);
+ Frames[Frameid].UseBorder = 0 != db_get_b(NULL, CLUIFrameModule, buf.Format("UseBorder%d", pos), Frames[Frameid].UseBorder);
+ Frames[Frameid].Skinned = 0 != db_get_b(NULL, CLUIFrameModule, buf.Format("Skinned%d", pos), Frames[Frameid].Skinned);
return 0;
}
int DBStoreFrameSettingsAtPos(int pos, int Frameid)
{
- char sadd[16];
- char buf[255];
-
- _itoa(pos, sadd, 10);
+ CMStringA buf;
- db_set_ws(0, CLUIFrameModule, AS(buf, "Name", sadd), Frames[Frameid].name);
+ db_set_ws(0, CLUIFrameModule, buf.Format("Name%d", pos), Frames[Frameid].name);
//boolean
- db_set_b(0, CLUIFrameModule, AS(buf, "Collapse", sadd), (BYTE)btoint(Frames[Frameid].collapsed));
- db_set_b(0, CLUIFrameModule, AS(buf, "Locked", sadd), (BYTE)btoint(Frames[Frameid].Locked));
- db_set_b(0, CLUIFrameModule, AS(buf, "Visible", sadd), (BYTE)btoint(Frames[Frameid].visible));
- db_set_b(0, CLUIFrameModule, AS(buf, "TBVisile", sadd), (BYTE)btoint(Frames[Frameid].TitleBar.ShowTitleBar));
-
- db_set_w(NULL, CLUIFrameModule, AS(buf, "Height", sadd), (WORD)Frames[Frameid].height);
- db_set_w(NULL, CLUIFrameModule, AS(buf, "HeightCollapsed", sadd), (WORD)Frames[Frameid].HeightWhenCollapsed);
- db_set_w(NULL, CLUIFrameModule, AS(buf, "Align", sadd), (WORD)Frames[Frameid].align);
+ db_set_b(0, CLUIFrameModule, buf.Format("Collapse%d", pos), (BYTE)btoint(Frames[Frameid].collapsed));
+ db_set_b(0, CLUIFrameModule, buf.Format("Locked%d", pos), (BYTE)btoint(Frames[Frameid].Locked));
+ db_set_b(0, CLUIFrameModule, buf.Format("Visible%d", pos), (BYTE)btoint(Frames[Frameid].visible));
+ db_set_b(0, CLUIFrameModule, buf.Format("TBVisile%d", pos), (BYTE)btoint(Frames[Frameid].TitleBar.ShowTitleBar));
+
+ db_set_w(NULL, CLUIFrameModule, buf.Format("Height%d", pos), (WORD)Frames[Frameid].height);
+ db_set_w(NULL, CLUIFrameModule, buf.Format("HeightCollapsed%d", pos), (WORD)Frames[Frameid].HeightWhenCollapsed);
+ db_set_w(NULL, CLUIFrameModule, buf.Format("Align%d", pos), (WORD)Frames[Frameid].align);
//FloatingPos
- db_set_w(NULL, CLUIFrameModule, AS(buf, "FloatX", sadd), (WORD)Frames[Frameid].FloatingPos.x);
- db_set_w(NULL, CLUIFrameModule, AS(buf, "FloatY", sadd), (WORD)Frames[Frameid].FloatingPos.y);
- db_set_w(NULL, CLUIFrameModule, AS(buf, "FloatW", sadd), (WORD)Frames[Frameid].FloatingSize.x);
- db_set_w(0, CLUIFrameModule, AS(buf, "FloatH", sadd), (WORD)Frames[Frameid].FloatingSize.y);
+ db_set_w(NULL, CLUIFrameModule, buf.Format("FloatX%d", pos), (WORD)Frames[Frameid].FloatingPos.x);
+ db_set_w(NULL, CLUIFrameModule, buf.Format("FloatY%d", pos), (WORD)Frames[Frameid].FloatingPos.y);
+ db_set_w(NULL, CLUIFrameModule, buf.Format("FloatW%d", pos), (WORD)Frames[Frameid].FloatingSize.x);
+ db_set_w(0, CLUIFrameModule, buf.Format("FloatH%d", pos), (WORD)Frames[Frameid].FloatingSize.y);
- db_set_b(0, CLUIFrameModule, AS(buf, "Floating", sadd), (BYTE)btoint(Frames[Frameid].floating));
- db_set_b(0, CLUIFrameModule, AS(buf, "UseBorder", sadd), (BYTE)btoint(Frames[Frameid].UseBorder));
- db_set_w(0, CLUIFrameModule, AS(buf, "Order", sadd), (WORD)Frames[Frameid].order);
+ db_set_b(0, CLUIFrameModule, buf.Format("Floating%d", pos), (BYTE)btoint(Frames[Frameid].floating));
+ db_set_b(0, CLUIFrameModule, buf.Format("UseBorder%d", pos), (BYTE)btoint(Frames[Frameid].UseBorder));
+ db_set_w(0, CLUIFrameModule, buf.Format("Order%d", pos), (WORD)Frames[Frameid].order);
- db_set_b(NULL, CLUIFrameModule, AS(buf, "Skinned", sadd), Frames[Frameid].Skinned);
+ db_set_b(NULL, CLUIFrameModule, buf.Format("Skinned%d", pos), Frames[Frameid].Skinned);
return 0;
}
diff --git a/plugins/Clist_nicer/src/extBackg.cpp b/plugins/Clist_nicer/src/extBackg.cpp
index 913cd0ed4a..8a6229c1ba 100644
--- a/plugins/Clist_nicer/src/extBackg.cpp
+++ b/plugins/Clist_nicer/src/extBackg.cpp
@@ -300,20 +300,33 @@ void LoadExtBkSettingsFromDB()
continue;
p->imageItem = nullptr;
- char buffer[255], *pszEnd = buffer + mir_snprintf(buffer, "%s_", p->szDBname);
- mir_strcpy(pszEnd, "IGNORE"); p->IGNORED = (BYTE)db_get_b(NULL, "CLCExt", buffer, p->IGNORED);
- mir_strcpy(pszEnd, "GRADIENT"); p->GRADIENT = (BYTE)db_get_dw(NULL, "CLCExt", buffer, p->GRADIENT);
- mir_strcpy(pszEnd, "CORNER"); p->CORNER = (BYTE)db_get_dw(NULL, "CLCExt", buffer, p->CORNER);
- mir_strcpy(pszEnd, "COLOR"); p->COLOR = db_get_dw(NULL, "CLCExt", buffer, p->COLOR);
- mir_strcpy(pszEnd, "COLOR2"); p->COLOR2 = db_get_dw(NULL, "CLCExt", buffer, p->COLOR2);
- mir_strcpy(pszEnd, "COLOR2_TRANSPARENT"); p->COLOR2_TRANSPARENT = (BYTE)db_get_b(NULL, "CLCExt", buffer, p->COLOR2_TRANSPARENT);
- mir_strcpy(pszEnd, "TEXTCOLOR"); p->TEXTCOLOR = db_get_dw(NULL, "CLCExt", buffer, p->TEXTCOLOR);
- mir_strcpy(pszEnd, "ALPHA"); p->ALPHA = db_get_b(NULL, "CLCExt", buffer, p->ALPHA);
- mir_strcpy(pszEnd, "MRGN_LEFT"); p->MARGIN_LEFT = db_get_b(NULL, "CLCExt", buffer, p->MARGIN_LEFT);
- mir_strcpy(pszEnd, "MRGN_TOP"); p->MARGIN_TOP = db_get_b(NULL, "CLCExt", buffer, p->MARGIN_TOP);
- mir_strcpy(pszEnd, "MRGN_RIGHT"); p->MARGIN_RIGHT = db_get_b(NULL, "CLCExt", buffer, p->MARGIN_RIGHT);
- mir_strcpy(pszEnd, "MRGN_BOTTOM"); p->MARGIN_BOTTOM = db_get_b(NULL, "CLCExt", buffer, p->MARGIN_BOTTOM);
- mir_strcpy(pszEnd, "BDRSTYLE"); p->BORDERSTYLE = db_get_dw(NULL, "CLCExt", buffer, p->BORDERSTYLE);
+ CMStringA buffer;
+ buffer.Format("%s_IGNORE", p->szDBname);
+ p->IGNORED = (BYTE)db_get_b(NULL, "CLCExt", buffer, p->IGNORED);
+ buffer.Format("%s_GRADIENT", p->szDBname);
+ p->GRADIENT = (BYTE)db_get_dw(NULL, "CLCExt", buffer, p->GRADIENT);
+ buffer.Format("%s_CORNER", p->szDBname);
+ p->CORNER = (BYTE)db_get_dw(NULL, "CLCExt", buffer, p->CORNER);
+ buffer.Format("%s_COLOR", p->szDBname);
+ p->COLOR = db_get_dw(NULL, "CLCExt", buffer, p->COLOR);
+ buffer.Format("%s_COLOR2", p->szDBname);
+ p->COLOR2 = db_get_dw(NULL, "CLCExt", buffer, p->COLOR2);
+ buffer.Format("%s_COLOR2_TRANSPARENT", p->szDBname);
+ p->COLOR2_TRANSPARENT = (BYTE)db_get_b(NULL, "CLCExt", buffer, p->COLOR2_TRANSPARENT);
+ buffer.Format("%s_TEXTCOLOR", p->szDBname);
+ p->TEXTCOLOR = db_get_dw(NULL, "CLCExt", buffer, p->TEXTCOLOR);
+ buffer.Format("%s_ALPHA", p->szDBname);
+ p->ALPHA = db_get_b(NULL, "CLCExt", buffer, p->ALPHA);
+ buffer.Format("%s_MRGN_LEFT", p->szDBname);
+ p->MARGIN_LEFT = db_get_b(NULL, "CLCExt", buffer, p->MARGIN_LEFT);
+ buffer.Format("%s_MRGN_TOP", p->szDBname);
+ p->MARGIN_TOP = db_get_b(NULL, "CLCExt", buffer, p->MARGIN_TOP);
+ buffer.Format("%s_MRGN_RIGHT", p->szDBname);
+ p->MARGIN_RIGHT = db_get_b(NULL, "CLCExt", buffer, p->MARGIN_RIGHT);
+ buffer.Format("%s_MRGN_BOTTOM", p->szDBname);
+ p->MARGIN_BOTTOM = db_get_b(NULL, "CLCExt", buffer, p->MARGIN_BOTTOM);
+ buffer.Format("%s_BDRSTYLE", p->szDBname);
+ p->BORDERSTYLE = db_get_dw(NULL, "CLCExt", buffer, p->BORDERSTYLE);
}
if (cfg::dat.bFirstRun) {
@@ -453,7 +466,7 @@ struct { char *szModule; char *szSetting; unsigned int size; int defaultval; } _
void extbk_export(char *file)
{
int i, n;
- char buffer[255];
+ CMStringA buffer;
char szSection[255];
char szKey[255];
DBVARIANT dbv = { 0 };
@@ -466,20 +479,32 @@ void extbk_export(char *file)
if (p->statusID == ID_EXTBKSEPARATOR)
continue;
- char *pszEnd = buffer + mir_snprintf(buffer, "%s_", p->szDBname);
- mir_strcpy(pszEnd, "ALPHA"); WritePrivateProfileStructA("ExtBKSettings", buffer, &(p->ALPHA), sizeof(p->ALPHA), file);
- mir_strcpy(pszEnd, "COLOR"); WritePrivateProfileStructA("ExtBKSettings", buffer, &(p->COLOR), sizeof(p->COLOR), file);
- mir_strcpy(pszEnd, "COLOR2"); WritePrivateProfileStructA("ExtBKSettings", buffer, &(p->COLOR2), sizeof(p->COLOR2), file);
- mir_strcpy(pszEnd, "COLOR2_TRANSPARENT"); WritePrivateProfileStructA("ExtBKSettings", buffer, &(p->COLOR2_TRANSPARENT), sizeof(p->COLOR2_TRANSPARENT), file);
- mir_strcpy(pszEnd, "TEXTCOLOR"); WritePrivateProfileStructA("ExtBKSettings", buffer, &(p->TEXTCOLOR), sizeof(p->TEXTCOLOR), file);
- mir_strcpy(pszEnd, "CORNER"); WritePrivateProfileStructA("ExtBKSettings", buffer, &(p->CORNER), sizeof(p->CORNER), file);
- mir_strcpy(pszEnd, "GRADIENT"); WritePrivateProfileStructA("ExtBKSettings", buffer, &(p->GRADIENT), sizeof(p->GRADIENT), file);
- mir_strcpy(pszEnd, "IGNORED"); WritePrivateProfileStructA("ExtBKSettings", buffer, &(p->IGNORED), sizeof(p->IGNORED), file);
- mir_strcpy(pszEnd, "MARGIN_BOTTOM"); WritePrivateProfileStructA("ExtBKSettings", buffer, &(p->MARGIN_BOTTOM), sizeof(p->MARGIN_BOTTOM), file);
- mir_strcpy(pszEnd, "MARGIN_LEFT"); WritePrivateProfileStructA("ExtBKSettings", buffer, &(p->MARGIN_LEFT), sizeof(p->MARGIN_LEFT), file);
- mir_strcpy(pszEnd, "MARGIN_RIGHT"); WritePrivateProfileStructA("ExtBKSettings", buffer, &(p->MARGIN_RIGHT), sizeof(p->MARGIN_RIGHT), file);
- mir_strcpy(pszEnd, "MARGIN_TOP"); WritePrivateProfileStructA("ExtBKSettings", buffer, &(p->MARGIN_TOP), sizeof(p->MARGIN_TOP), file);
- mir_strcpy(pszEnd, "BORDERSTYLE"); WritePrivateProfileStructA("ExtBKSettings", buffer, &(p->BORDERSTYLE), sizeof(p->BORDERSTYLE), file);
+ buffer.Format("%s_ALPHA", p->szDBname);
+ WritePrivateProfileStructA("ExtBKSettings", buffer, &(p->ALPHA), sizeof(p->ALPHA), file);
+ buffer.Format("%s_COLOR", p->szDBname);
+ WritePrivateProfileStructA("ExtBKSettings", buffer, &(p->COLOR), sizeof(p->COLOR), file);
+ buffer.Format("%s_COLOR2", p->szDBname);
+ WritePrivateProfileStructA("ExtBKSettings", buffer, &(p->COLOR2), sizeof(p->COLOR2), file);
+ buffer.Format("%s_COLOR2_TRANSPARENT", p->szDBname);
+ WritePrivateProfileStructA("ExtBKSettings", buffer, &(p->COLOR2_TRANSPARENT), sizeof(p->COLOR2_TRANSPARENT), file);
+ buffer.Format("%s_TEXTCOLOR", p->szDBname);
+ WritePrivateProfileStructA("ExtBKSettings", buffer, &(p->TEXTCOLOR), sizeof(p->TEXTCOLOR), file);
+ buffer.Format("%s_CORNER", p->szDBname);
+ WritePrivateProfileStructA("ExtBKSettings", buffer, &(p->CORNER), sizeof(p->CORNER), file);
+ buffer.Format("%s_GRADIENT", p->szDBname);
+ WritePrivateProfileStructA("ExtBKSettings", buffer, &(p->GRADIENT), sizeof(p->GRADIENT), file);
+ buffer.Format("%s_IGNORED", p->szDBname);
+ WritePrivateProfileStructA("ExtBKSettings", buffer, &(p->IGNORED), sizeof(p->IGNORED), file);
+ buffer.Format("%s_MARGIN_BOTTOM", p->szDBname);
+ WritePrivateProfileStructA("ExtBKSettings", buffer, &(p->MARGIN_BOTTOM), sizeof(p->MARGIN_BOTTOM), file);
+ buffer.Format("%s_MARGIN_LEFT", p->szDBname);
+ WritePrivateProfileStructA("ExtBKSettings", buffer, &(p->MARGIN_LEFT), sizeof(p->MARGIN_LEFT), file);
+ buffer.Format("%s_MARGIN_RIGHT", p->szDBname);
+ WritePrivateProfileStructA("ExtBKSettings", buffer, &(p->MARGIN_RIGHT), sizeof(p->MARGIN_RIGHT), file);
+ buffer.Format("%s_MARGIN_TOP", p->szDBname);
+ WritePrivateProfileStructA("ExtBKSettings", buffer, &(p->MARGIN_TOP), sizeof(p->MARGIN_TOP), file);
+ buffer.Format("%s_BORDERSTYLE", p->szDBname);
+ WritePrivateProfileStructA("ExtBKSettings", buffer, &(p->BORDERSTYLE), sizeof(p->BORDERSTYLE), file);
}
for (n = 0; n <= FONTID_LAST; n++) {
@@ -1057,10 +1082,13 @@ static void BTN_ReadItem(char *itemName, char *file)
tmpItem.dwFlags |= BUTTON_DBACTIONONCONTACT;
for (n = 0; n <= 1; n++) {
- char szKey[20];
+ CMStringA szKey;
BYTE *pValue;
- mir_strcpy(szKey, n == 0 ? "dbonpush" : "dbonrelease");
+ if (n == 0)
+ szKey = "dbonpush";
+ else
+ szKey = "dbonrelease";
pValue = (n == 0 ? tmpItem.bValuePush : tmpItem.bValueRelease);
GetPrivateProfileStringA(itemName, szKey, "None", szBuffer, 1000, file);